SA-MP Forums Archive
[HELP] lvl code - 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: [HELP] lvl code (/showthread.php?tid=557615)



[HELP] lvl code - Luca12 - 14.01.2015

Hello I was made credit system for level each player level I mean 10 15 is bring new credit money

and know I want to make a code if player has lvl 45 and all to 70 for example he get dialog

if(code here for lvl - so I need here something like 45>70 if you know what I mean?
{
dialog
}


Re: [HELP] lvl code - Schneider - 14.01.2015

pawn Код:
if((Level[playerid] >= 0) && (Level[playerid] < 10)) {
    //stuff from 0 to 9
}
else if((Level[playerid] >= 10) && (Level[playerid] < 45)) {
   //stuff from 10 to 44
}
else if((Level[playerid] >= 45) && (Level[playerid] < 70)) {
  //stuff from 45 to 69
}
else if(Level[playerid] > 69) {
   // from 70 and higher
}
Or you could so a switch:

pawn Код:
switch(Level[playerid])
{
    case 0 .. 9:  { Dialog }
    case 10 .. 44: { Dialog }
    case 45 .. 70: { Dialog }
}



Re: [HELP] lvl code - Threshold - 14.01.2015

I always find it easier to do something like:
pawn Код:
if(minimum <= variable <= maximum)
Example (Using the above poster's variables):
pawn Код:
if(0 <= Level[playerid] <= 9)
{
    //stuff from 0 to 9
}
else if(10 <= Level[playerid] <= 44)
{
   //stuff from 10 to 44
}
else if(45 <= Level[playerid] <= 69)
{
  //stuff from 45 to 69
}
else if(Level[playerid] >= 70)
{
   // from 70 and higher
}



Re: [HELP] lvl code - Luca12 - 14.01.2015

else if(PlayerInfo[playerid][Level] == 45 <= PlayerInfo[playerid][Level] == <= 69)
{
//stuff from 45 to 69
}

can it go something like this above the text? Thanks


Re: [HELP] lvl code - Threshold - 14.01.2015

Why would you do that? That would just give you errors...
pawn Код:
if(45 <= PlayerInfo[playerid][Level] <= 69)
will be accepted for levels from 45 to 69.