Looping through 2D variable - 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: Looping through 2D variable (
/showthread.php?tid=409080)
Looping through 2D variable -
Income - 20.01.2013
Hey there!
I'm trying to create a command that will give you some specific weapons (their ID's).
I'm having a problem that the pawno does't recognize the var and I don't know why..
What am I doing wrong here? Am I coding the variable wrong?
PHP код:
CMD:spawnweapons(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1 && Logged[playerid])
{
new weaponlist[] = { 24, 27, 31, 34, 35, 43 };
for(new i = 0; i < sizeof(weaponlist); i++) //<- line 2413
{
GivePlayerWeapon(playerid, i, 10010);
}
GameTextForPlayer(playerid,"~w~Weapons ~g~Gained", 5000, 1);
}
else return SendErrorMessage(playerid, ERROR_ADMIN);
return 1;
}
PHP код:
GameModes.pwn(2413) : warning 204: symbol is assigned a value that is never used: "weaponlist"
Re: Looping through 2D variable -
Vince - 20.01.2013
It does recognize it alright, it just tells you that you created a variable but didn't use it.
pawn Код:
GivePlayerWeapon(playerid, i, 10010);
That will just give the player weapons with ids 0 through 5. Not the ones that you specified.
pawn Код:
GivePlayerWeapon(playerid, weaponlist[i], 10010);
Re: Looping through 2D variable -
Income - 20.01.2013
I understand my mistake. Silly me hehe
Thank you very much!