SA-MP Forums Archive
Why people using variables like that? - 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: Why people using variables like that? (/showthread.php?tid=433643)



Why people using variables like that? - Activest - 28.04.2013

Hey, I want to ask you what are the differences between:
PHP код:
new string[128];
new 
string[128] = {false,...}
new 
Player[MAX_PLAYERS];
new 
Player[MAX_PLAYERS] = {INVALID_PLAYER_ID,...} 



Re: Why people using variables like that? - verlaj - 28.04.2013

here is 1 example of [MAX_PLAYERS]

pawn Код:
new InDM[MAX_PLAYERS];


CMD:dm1(playerid,Params[])
{
         if(InDM[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"You are already in DM."); //to check if player is already in that dm or not
         SetPlayerPos(playerid, 1541.4945,-1342.2010,329.4573);
         SendClientMessage(playerid,COLOR_RED,"Star tower DM");
         GetPlayerWeapon(playerid);
         GivePlayerWeapon(playerid,24,1000);
         GivePlayerWeapon(playerid,25,1000);
         SetPlayerArmour(playerid, 100);
         InDM[playerid] = 1; //this will tell that player is now in dm.
         return 1;
 }
by using InDm we can also create leave dm command.. i hope it helped you a bit.


AW: Why people using variables like that? - BigETI - 28.04.2013

pawn Код:
new array[3]; // <- In PAWN those are not initialized yet, so it keeps them zero

new array[3] = {1, 2, 3} // <- Initializes array with 1, 2, and 3

new array[3] = {3, ...} // <- Initializes the whole array with the value 3