Page 1 of 1
How do data types work in multiplayer?
Posted: Sun Jul 06, 2014 4:04 am
by Flaminglacier
So If I have a script thats declares an integer to be 1 and then a script activates and it causes the int to equal 2 will this change the integer value for all players or just the player activating the script,
For example if I had something like this
Code: Select all
Script 1 (void)
{
int ASS = 1
if(CheckInventory("Money") > 100)
Print(s:"You can afford this lap dance!");
int ASS = 2;
else
Print(s:"Sorry you can afford dat ass");
}
Would a player activating the script shortly after another player had activated the script with 101 money cause the global int ASS to = 1? or does each activator get there own variant of the int ASS?
RE: How do data types work in multiplayer?
Posted: Sun Jul 06, 2014 4:36 am
by Catastrophe
Flaminglacier wrote:
Would a player activating the script shortly after another player had activated the script with 101 money cause the global int ASS to = 1?
Yes.
or does each activator get there own variant of the int ASS?
You can do this by creating an array with the size of 64 (because that's the max playerlimit currently). Then when someone executes the script all you'd have to do is myArray[playernumber()] = 2;
RE: How do data types work in multiplayer?
Posted: Sun Jul 06, 2014 5:54 am
by Flaminglacier
so it would be something like this:
Code: Select all
Script 1 (void)
{
int ASS[64]
if(CheckInventory("Money") > 100)
Print(s:"You can afford this lap dance!");
ASS[playernumber()] = 2;
else
Print(s:"Sorry you can afford dat ass");
}
RE: How do data types work in multiplayer?
Posted: Sun Jul 06, 2014 5:58 am
by Catastrophe
Yes except you should set ASS[64] into a global array instead because every time someone calls the script, ASS[64] will get reset.
RE: How do data types work in multiplayer?
Posted: Sun Jul 06, 2014 6:06 am
by Flaminglacier
Also if the player activating the script logs off will it effect the array? I am trying to make a quest system where a player can start a quest (making: int firstquest = 1 via array) and when they complete the quest the int changes to 2 so that way the player cannot do the quest again. I would use a simple if/else statement to check if the players quest int = 1 for started or 2 for finished.
That's why im wondering if a player with lets say player number 4 logs off and player 5 becomes player 4. If player 5 completed the quest will player 4 have that quest integer?
I assume the most I can do if this is the case is to have the quest int be reset at the end of the quest so that way other players can complete it with the same player number later.
RE: How do data types work in multiplayer?
Posted: Sun Jul 06, 2014 6:33 am
by Catastrophe
Say I came in the server and set TEST to 4. If I left and someone else took my player slot, he will be playing with TEST equating to 4.
Best think to do is to reset TEST to 0 using a disconnect script.