SA-MP Forums Archive
If statement question - 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: If statement question (/showthread.php?tid=427510)



If statement question - BittleRyan - 02.04.2013

Here is my code:

pawn Код:
if(pInfo[playerid][pGender] == "male")
                {
                    new size = sizeof(RandMaleReg);
                    new randn = random(size);
                    new randomskin = RandMaleReg[randn];
                    pInfo[playerid][pSkinID] = randomskin;
                }
                if(pInfo[playerid][pGender] == "female")
                {
                    new size = sizeof(RandFemaleReg);
                    new randn = random(size);
                    new randomskin = RandFemaleReg[randn];
                    pInfo[playerid][pSkinID] = randomskin;
                }
I am getting these errors:
Код:
error 033: array must be indexed (variable "-unknown-")
 error 033: array must be indexed (variable "-unknown-")
Both of those are on lines " if(pInfo[playerid][pGender] == "female")" and "if(pInfo[playerid][pGender] == "male")"

How do I make it check for male and female?


Re: If statement question - Nathan_Taylor - 02.04.2013

Use STRCMP.

pawn Код:
if(!strcmp(pInfo[playerid[pGender], "male", true, 4))
                {
                    new size = sizeof(RandMaleReg);
                    new randn = random(size);
                    new randomskin = RandMaleReg[randn];
                    pInfo[playerid][pSkinID] = randomskin;
                }
                if(!strcmp(pInfo[playerid[pGender], "female", true, 6))
                {
                    new size = sizeof(RandFemaleReg);
                    new randn = random(size);
                    new randomskin = RandFemaleReg[randn];
                    pInfo[playerid][pSkinID] = randomskin;
                }
That work for you? Cause you are comparing two strings.


Re: If statement question - BittleRyan - 02.04.2013

Fantastic! That works!

I thought about using it but I thought it had to be in a variable to compare it. Learned something new