Player variables - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Player variables (
/showthread.php?tid=397392)
Player variables -
Lz - 04.12.2012
Is there a way to increase the value of a variable for each player..
For example..
Player types /yes
increases that one players value to 1
another player types /yes
also increases only his value to 1
Re: Player variables -
tyler12 - 04.12.2012
new Variable[MAX_PLAYERS];
/yes
Variable[playerid]++;
Re: Player variables -
CoaPsyFactor - 04.12.2012
SetPVarInt(playerid, "yesvar", GetPVarInt(playerid, "yesvar") +1);
Re: Player variables -
Feastahashi - 04.12.2012
Code:
new variable[MAX_PLAYERS];
// Now on the command: /yes
variable[playerid] += 1; // Increases the actual value in +1
Re: Player variables -
Lz - 04.12.2012
Thanks all, Also im pretty new to scripting atm but im just developing a small unique script which will be easier to test using a player variable (i think) But once i've released it i'll update it to using an array (Also think)
And also im getting a few errors.. Heres my script (Blanked out as i don't want anyone copying my idea until i release it)
pawn Code:
CMD:XXX (playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, XXXXXXXXXXX))
{
CreateObject(XXXXXXXXXXXXXXXXXXXXXXXXXXXX);
pVariable[playerid] ++;
}
return 1;
}
Now heres the errors i get..
Code:
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(245) : error 017: undefined symbol "pVariable"
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(245) : warning 215: expression has no effect
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(245) : error 001: expected token: ";", but found "]"
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(245) : error 029: invalid expression, assumed zero
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(245) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Weird because i did define my variable and also set the value to 0..
new pVariable=0[MAX_PLAYERS];
Re: Player variables -
Bakr - 04.12.2012
Initializing an array has a different syntax than that of regular variables:
pawn Code:
new pVariable[MAX_PLAYERS] = { 0, ... };
Though that isn't necessarily needed, as all Pawn variables default to 0.
Re: Player variables -
Konstantinos - 04.12.2012
You cannot use this and get it works.
pawn Code:
new pVariable=0[MAX_PLAYERS];
You should define it as a global variable and set a value after, either inside a callback/custom function or command.
pawn Code:
// Global variable
new
pVariable[ MAX_PLAYERS ]
;
// OnPlayerConnect
pVariable[ playerid ] = 0;
// There you want to increase the value by one
pVariable[ playerid ]++;