Usage: gms_script_set_p2p ( script_id )


Sets the script that should be executed when receiving a p2p-message.

The script should take 3 arguments:
argument0: P2P-message id
argument1: Sender's player_id
argument2: a ds_list with all values sent.


//Sets the script scr_p2p to be executed when a new p2p-message is received.

Replies (5)

Last message on 16 Apr 2017

Dublann on 3 Apr 2017, 20:57:05
Size, is mandatory to have the argument1 defined? I'm figuring out how one player can know it if there are more than 1 player connected.
Size43 (Administrator) on 16 Apr 2017, 16:26:02
You might be better off using gms_other_count to check for this.
RefresherTowel on 29 Sep 2015, 07:05:26
Here is the script itself, scr_p2p_received:

//See switch(argument0)
case p2p_kill:
//Don't forget to actually ADD the statistics on the site!
gms_statistic_set("kills", gms_statistic_get("kills") + 1);
RefresherTowel on 29 Sep 2015, 07:04:36
Hey size, I've been trying to get kill tracking working in my game but it keeps throwing up an error. This is the error:

action number 1
of Step Eventobj_pistol_bullet
for object obj_player:

Push :: Execution Error - Variable Get 100002.p2p_kill(100010, -2147483648)
at gml_Object_obj_player_Collision_1

I've got three different sections in my obj_player object that create the kill tracking.

In my collision event with the obj_pistol_bullet I've got:

if (other.owner != gms_self_playerid()) {
hp -= other.damage;
if (hp <= 0) {
gms_chat("was killed by " + gms_other_get_string(other.owner, "name"), c_red);
gms_p2p_send(p2p_kill, other.owner);
with (other) {

In the room start event I've got:


And finally, the script itself (scr_p2p_received) which won't fit in this comment, so I'll add another one with it.
Size43 (Administrator) on 2 Oct 2015, 13:19:32
You'll need to add p2p_kill as a constant / macro, and give it a numeric value between 0 and 255. The p2p-type (first argument) is just a number, but it's better to put those numbers in constants so you know what they actually mean. If you really wanted to, you could also replace all p2p_kills with a random number in 0 - 255.