SA-MP Forums Archive
Variables in Pawno. - 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: Variables in Pawno. (/showthread.php?tid=356798)



Variables in Pawno. - Snip3d - 04.07.2012

Hello, I'm having the hardest time in the world grasping variables in pawno, they are much more complicated then other languages IMO.

How in the world do you define an int and a string? My guess is
Код:
new pScore[3] = 0; //Int
new pSkin[MAX_PLAYERS] //String
Also, how do you use variables in functions for example
Код:
SetPlayerSkin(playerid, pSkin);
doesn't compile for me.

another thing I'm struggling to understand is having a variable for every player, I know you use MAX_PLAYERS for this but could someone dumb it down for me?


EDIT: Got it compiling by changing the the variables to
Код:
new	pScore[MAX_PLAYERS] = 0; //Score
new pSkin[MAX_PLAYERS] = 0; // Skin
Код:
SetPlayerSkin(playerid, pSkin[playerid]);
Are my variables ints because I set them to 0? are they strings if I don't set them to 0?


Re: Variables in Pawno. - Tee - 04.07.2012

Take a look here https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables


Re: Variables in Pawno. - Vince - 04.07.2012

All strings (except literal) are arrays, but not all arrays are strings.
pawn Код:
new myString[6] = "Hello";
new myString[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
new myString[6] = {72, 101, 108, 108, 111, 0};
Are all equivalent.