Problem with strlen. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with strlen. (
/showthread.php?tid=132330)
Problem with strlen. -
Carlton - 07.03.2010
I'm having a small problem when I add strlen. When I compile the script, the compiler automaticly crashes. The code is below:
Код:
new slength = Strlen(itemname);
if(PlayerBackpack[playerid][0][Itemstored] == 0) { strins(PlayerBackpack[playerid][0][Item], itemname, slength ); }
if(PlayerBackpack[playerid][1][Itemstored] == 0) { strins(PlayerBackpack[playerid][1][Item], itemname, slength ); }
if(PlayerBackpack[playerid][2][Itemstored] == 0) { strins(PlayerBackpack[playerid][2][Item], itemname, slength ); }
if(PlayerBackpack[playerid][3][Itemstored] == 0) { strins(PlayerBackpack[playerid][3][Item], itemname, slength ); }
if(PlayerBackpack[playerid][4][Itemstored] == 0) { strins(PlayerBackpack[playerid][4][Item], itemname, slength ); }
Re: Problem with strlen. -
¤Adas¤ - 07.03.2010
There is something wrong, it can not be "PlayerBackpack[playerid][0][Item]", it can be "PlayerBackpack[playerid][Item][0]".
pawn Код:
new slength = Strlen(itemname);
if(PlayerBackpack[playerid][Itemstored][0]) strins(PlayerBackpack[playerid][Item][0], itemname, slength);
if(PlayerBackpack[playerid][Itemstored][1]) strins(PlayerBackpack[playerid][Item][1], itemname, slength);
if(PlayerBackpack[playerid][Itemstored][2]) strins(PlayerBackpack[playerid][Item][2], itemname, slength);
if(PlayerBackpack[playerid][Itemstored][3]) strins(PlayerBackpack[playerid][Item][3], itemname, slength);
if(PlayerBackpack[playerid][Itemstored][4]) strins(PlayerBackpack[playerid][Item][4], itemname, slength);
Re: Problem with strlen. -
Carlton - 07.03.2010
Quote:
Originally Posted by ¤Adas¤
Maybe this will work...
pawn Код:
new slength = Strlen(itemname); if(PlayerBackpack[playerid][0][Itemstored]) strins(PlayerBackpack[playerid][0][Item], itemname, slength); if(PlayerBackpack[playerid][1][Itemstored]) strins(PlayerBackpack[playerid][1][Item], itemname, slength); if(PlayerBackpack[playerid][2][Itemstored]) strins(PlayerBackpack[playerid][2][Item], itemname, slength); if(PlayerBackpack[playerid][3][Itemstored]) strins(PlayerBackpack[playerid][3][Item], itemname, slength); if(PlayerBackpack[playerid][4][Itemstored]) strins(PlayerBackpack[playerid][4][Item], itemname, slength);
|
The code still crashes my compiler.
Re: Problem with strlen. -
¤Adas¤ - 07.03.2010
I have edited my previsious post
↑↑↑
Re: Problem with strlen. -
Carlton - 07.03.2010
Quote:
Originally Posted by ¤Adas¤
I have edited my previsious post ↑↑↑
|
The compiler is still crashing, and there's no point of switching it around like that, even though I tried it, and got the same result.
Re: Problem with strlen. -
¤Adas¤ - 07.03.2010
Show me the lines, where are these variables creating...
Re: Problem with strlen. -
Carlton - 07.03.2010
Код:
enum backinfo
{
Item[128],
Itemstored
}
new PlayerBackpack[MAX_PLAYERS][backinfo][MAX_ITEMS_ALLOWED];
I switched backinfo and MAX_ITEMS_ALLOWED.
Re: Problem with strlen. -
¤Adas¤ - 07.03.2010
Problem is simple. Pawn compiler can not process variables with more than 3 indexes. Can it?
You have to find another way to do this...