Discuss all aspects related to modding Zandronum here.
-
Flaminglacier
-
- Posts: 65
- Joined: Thu Jun 21, 2012 9:28 pm
#1
Post
by Flaminglacier » Sun Jul 06, 2014 4:04 am
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?
Last edited by
Flaminglacier on Sun Jul 06, 2014 4:06 am, edited 1 time in total.
-
Catastrophe
- Retired Staff / Community Team Member
- Posts: 2571
- Joined: Sat Jun 02, 2012 2:44 am
#2
Post
by Catastrophe » Sun Jul 06, 2014 4:36 am
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;
Last edited by
Catastrophe on Sun Jul 06, 2014 4:37 am, edited 1 time in total.
-
Flaminglacier
-
- Posts: 65
- Joined: Thu Jun 21, 2012 9:28 pm
#3
Post
by Flaminglacier » Sun Jul 06, 2014 5:54 am
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");
}
Last edited by
Flaminglacier on Sun Jul 06, 2014 5:54 am, edited 1 time in total.
-
Catastrophe
- Retired Staff / Community Team Member
- Posts: 2571
- Joined: Sat Jun 02, 2012 2:44 am
#4
Post
by Catastrophe » Sun Jul 06, 2014 5:58 am
Yes except you should set ASS[64] into a global array instead because every time someone calls the script, ASS[64] will get reset.
-
Flaminglacier
-
- Posts: 65
- Joined: Thu Jun 21, 2012 9:28 pm
#5
Post
by Flaminglacier » Sun Jul 06, 2014 6:06 am
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.
Last edited by
Flaminglacier on Sun Jul 06, 2014 6:08 am, edited 1 time in total.
-
Catastrophe
- Retired Staff / Community Team Member
- Posts: 2571
- Joined: Sat Jun 02, 2012 2:44 am
#6
Post
by Catastrophe » Sun Jul 06, 2014 6:33 am
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.