SA-MP Forums Archive
what's wrong? - 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: what's wrong? (/showthread.php?tid=324929)



what's wrong? - mineralo - 11.03.2012

pawn Код:
new old[256],yes[MAX_PLAYERS][256];
            GetPlayer2DZone(playerid,old,sizeof(old));
            if(ShitInfo[playerid][pBank] == 1)
            {
                format(old,sizeof(old),"LS Bank");
            }
            if(ShitInfo[playerid][pJail] == 1)
            {
                format(old,sizeof(old),"Jail");
            }
            if(ShitInfo[playerid][pAmmu] == 1)
            {
                format(old,sizeof(old),"Ammu-Nation");
            }
            if(ShitInfo[playerid][pCity] == 1)
            {
                format(old,sizeof(old),"Job House");
            }
            if(old != yes[playerid]) // line 8312
            {
                yes[playerid] = old;
                GameTextForPlayer(playerid,yes[playerid],2000,1);
            }
error code
Код:
D:\Programs\proecte ne terminate\samp 0.3d rc 2 server\gamemodes\rpg.pwn(8312) : error 033: array must be indexed (variable "old")
any idea? I know its says should be a variable but I used string, how I can do that with string? I need it


Re: what's wrong? - mineralo - 11.03.2012

no one can help me?


Re: what's wrong? - eesh - 11.03.2012

pawn Код:
new old[256],yes[MAX_PLAYERS][256];
            GetPlayer2DZone(playerid,old,sizeof(old));
            if(ShitInfo[playerid][pBank] == 1)
            {
                format(old,sizeof(old),"LS Bank");
            }
            if(ShitInfo[playerid][pJail] == 1)
            {
                format(old,sizeof(old),"Jail");
            }
            if(ShitInfo[playerid][pAmmu] == 1)
            {
                format(old,sizeof(old),"Ammu-Nation");
            }
            if(ShitInfo[playerid][pCity] == 1)
            {
                format(old,sizeof(old),"Job House");
            }
            if(strfind(old,yes,true) == -1) // line 8312
            {
                yes[playerid] = old;
                GameTextForPlayer(playerid,yes[playerid],2000,1);
            }
You cannot compare strings with if.


Re: what's wrong? - aco_SRBIJA - 11.03.2012

Strings is array(!) of chars...So you should use https://sampwiki.blast.hk/wiki/Strfind else loop.


Re: what's wrong? - mineralo - 11.03.2012

I found a function to compare strings, thx anyway
it was strcmp


Re: what's wrong? - eesh - 11.03.2012

Quote:
Originally Posted by mineralo
Посмотреть сообщение
I found a function to compare strings, thx anyway
it was strcmp
strfind does the job too