SA-MP Forums Archive
Code not working correctly? - 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: Code not working correctly? (/showthread.php?tid=380595)



Code not working correctly? - iLcke - 26.09.2012

This doesn't seem to work as I thought it would, anyone got any ideas?

pawn Код:
if (iNumber <= 12 && iNumber >= 100)
    {
    format(tut, sizeof(tut), "Character Questions: %s.", plname);
    ShowPlayerDialog(playerid, DIALOG_TUT_3, DIALOG_STYLE_LIST, tut, "American\nAfrican American\nHispanic\nAsian", "Contiune", "Quit");
    PlayerInfo[playerid][pAge]=iNumber;
    }
    else
    format(tut, sizeof(tut), "Character Questions: %s.", plname);
    ShowPlayerDialog(playerid,DIALOG_TUT_2, DIALOG_STYLE_INPUT, tut, "You have to pick a age between 12 and 100.", "Contiune", "Cancel");
    }



Re: Code not working correctly? - MarTaTa - 26.09.2012

Well when you test it what's the problem ?


Re: Code not working correctly? - iLcke - 26.09.2012

I haven't been scripting in awhile, so I'm not sure if I am doing it correctly.

If someone puts in a number lower than twelve, or higher than a 100 in the dialog, it should go towards the bottom and tell them to pick a number between 12-100. After they pick the number 12-100, there age gets set to the number they've choosen.


Re: Code not working correctly? - RedJohn - 26.09.2012

pawn Код:
if(iNumber <= 12 || iNumber >= 100)
{
    format(tut, sizeof(tut), "Character Questions: %s.", plname);
    ShowPlayerDialog(playerid, DIALOG_TUT_3, DIALOG_STYLE_LIST, tut, "American\nAfrican American\nHispanic\nAsian", "Contiune", "Quit");
    PlayerInfo[playerid][pAge]=iNumber;
}
else
{
    format(tut, sizeof(tut), "Character Questions: %s.", plname);
    ShowPlayerDialog(playerid,DIALOG_TUT_2, DIALOG_STYLE_INPUT, tut, "You have to pick a age between 12 and 100.", "Contiune", "Cancel");
}



Re: Code not working correctly? - iLcke - 26.09.2012

Adding that one little bracket actually gives me an error.
Quote:

error 029: invalid expression, assumed zero




Re: Code not working correctly? - RedJohn - 26.09.2012

Quote:
Originally Posted by iLcke
Посмотреть сообщение
Adding that one little bracket actually gives me an error.
On which line?

I assumed on this: PlayerInfo[playerid][pAge]=iNumber;


Re: Code not working correctly? - iLcke - 26.09.2012

The bracket you added, it winds up giving me that error.
iNumber is defined, it's fine.


Re: Code not working correctly? - Rimeau - 26.09.2012

This is never true:

pawn Код:
if (iNumber <= 12 && iNumber >= 100)
It would be true if iNumber was smaller than 13 AND bigger than 99 at the same time. Instead of &&, use ||

Btw, it's "an age"


Re: Code not working correctly? - RedJohn - 26.09.2012

You have to set PlayerInfo[playerid][pAge]=iNumber; on DIALOG_TUT response.


Re: Code not working correctly? - MarTaTa - 26.09.2012

Quote:
Originally Posted by Rimeau
Посмотреть сообщение
This is never true:

pawn Код:
if (iNumber <= 12 && iNumber >= 100)
It would be true if iNumber was smaller than 13 AND bigger than 99 at the same time. Instead of &&, use ||

Btw, it's "an age"
What he said you need to use
pawn Код:
if(iNumber <= 12 || iNumber >= 100)