SA-MP Forums Archive
SetPVarInt - 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: SetPVarInt (/showthread.php?tid=371386)



SetPVarInt - SumX - 23.08.2012

Hello!
How can I set the maximum value of a PVar?
I have SetPVarInt(playerid,"Wanted",wantedlevel)
I made a wanted level system,but it goes to 40+...infinite)
How can I set the maximum wanted level as 10?


Re: SetPVarInt - detter - 23.08.2012

Код:
#define MAX_WANTED_LEVEL 10
then you just throw in IF and thats all


Re: SetPVarInt - clarencecuzz - 23.08.2012

Example:
pawn Код:
#define MAX_WANTED_LEVEL 10
//At the top near your includes, before any public functions.

//Your code here
if(wantedlevel > MAX_WANTED_LEVEL)
{
    wantedlevel = MAX_WANTED_LEVEL;
}
SetPVarInt(playerid,"Wanted",wantedlevel);
//Code continues...



Re: SetPVarInt - Vince - 23.08.2012

pawn Код:
native clamp(value, min=cellmin, max=cellmax);
pawn Код:
SetPVarInt(playerid, "Wanted", clamp(wantedlevel, 0, 10));