SA-MP Forums Archive
Error 001 for new A1[20]; - 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: Error 001 for new A1[20]; (/showthread.php?tid=352133)



Error 001 for new A1[20]; - dholmes7512 - 18.06.2012

I keep getting:
Quote:

error 001: expected token: "-identifier-", but found "-integer value-"

For this piece of code:
Код:
	new A1[20];
	if(PlayerInfo[targetid][pAmount1] == 1) { A1 = PlayerInfo[targetid][pWood]; }
    else if(PlayerInfo[targetid][pAmount1] == 2) { A1 = PlayerInfo[targetid][pFruit]; }
    else if(PlayerInfo[targetid][pAmount1] == 3) { A1 = PlayerInfo[targetid][pSeeds]; }
    else if(PlayerInfo[targetid][pAmount1] == 4) { A1 = PlayerInfo[targetid][pLeather]; }
    else if(PlayerInfo[targetid][pAmount1] == 5) { A1 = PlayerInfo[targetid][pHide]; }
    else if(PlayerInfo[targetid][pAmount1] == 6) { A1 = PlayerInfo[targetid][pMeat]; }
    else if(PlayerInfo[targetid][pAmount1] == 7) { A1 = PlayerInfo[targetid][pClothes]; }
    else if(PlayerInfo[targetid][pAmount1] == 8) { A1 = PlayerInfo[targetid][pCopper]; }
    else if(PlayerInfo[targetid][pAmount1] == 9) { A1 = PlayerInfo[targetid][pIron]; }
    else if(PlayerInfo[targetid][pAmount1] == 10) { A1 = PlayerInfo[targetid][pGold]; }
    else if(PlayerInfo[targetid][pAmount1] == 11) { A1 = PlayerInfo[targetid][pCoal]; }
    else if(PlayerInfo[targetid][pAmount1] == 12) { A1 = PlayerInfo[targetid][pCookedFish]; }
    else if(PlayerInfo[targetid][pAmount1] == 13) { A1 = PlayerInfo[targetid][pPerch]; }
    else if(PlayerInfo[targetid][pAmount1] == 14) { A1 = PlayerInfo[targetid][pSalmon]; }
    else if(PlayerInfo[targetid][pAmount1] == 15) { A1 = PlayerInfo[targetid][pTuna]; }
    else if(PlayerInfo[targetid][pAmount1] == 16) { A1 = PlayerInfo[targetid][pSwordfish]; }
    else if(PlayerInfo[targetid][pAmount1] == 17) { A1 = PlayerInfo[targetid][pWheat]; }
    else if(PlayerInfo[targetid][pAmount1] == 18) { A1 = PlayerInfo[targetid][pBread]; }
    else if(PlayerInfo[targetid][pAmount1] == 19) { A1 = PlayerInfo[targetid][pString]; }
    else if(PlayerInfo[targetid][pAmount1] == 20) { A1 = PlayerInfo[targetid][pArrow]; }
    else if(PlayerInfo[targetid][pAmount1] == 21) { A1 = PlayerInfo[targetid][pWater]; }
    else { A1 = "Nothing"; }
I'm trying to make a inventory system where if one slot is not filled it fills it, and each item has a specific amount. Any ideas how to fix this?


Re: Error 001 for new A1[20]; - Randy More - 18.06.2012

Make the variable like that:

pawn Код:
new A1;



Re: Error 001 for new A1[20]; - dholmes7512 - 18.06.2012

Ah, never realised. Thanks, working now.


Re: Error 001 for new A1[20]; - Randy More - 18.06.2012

Just to make that clear, your values were not a string, they were integer, as for strings, you can do what you done in the original code.