Help with player variables

Posted by Seuphoria
I'm trying to create a pvp system and for that I need to get a variable ("pvp_enable") from the other player.
The problem is that I really don't understand how it works.

I created a textbox that let's you type a player_id (for the player you want to fight).
In the step event I added this code:

if (keyboard_check_pressed(vk_enter)) {
var pvp = gms_other_get(message, "pvp_enable")
if pvp == 1 {
game_end() //The game should close if it works

But nothing happens so that's why I need some help.

In my player object I have this code:
release G-key event:
gms_self_set( "pvp_enable", 1)

I don't undestand if the "pvp_enable" shoudl be a normal variable already in the object or a custom variable
available only in the gms_self_set/gms_other_get.

If you can help me with this I'd be very grateful.

P.S Happy Christmas!

Replies (2)

Last message on 28 Dec 2020

Size43 (Administrator) on 28 Dec 2020, 13:13:54
Is message a string by any chance? If so, you'll have to convert it to a number with real(message) before passing it to gms_other_get.

By the way, this sounds like it would be easier to implement this with p2p messages.
Seuphoria (Topicstarter) on 28 Dec 2020, 15:12:37
Yes, the string was the problem...
But still, thanks for telling me about p2p messages, it's a way better solution than the code I've made :)