SA-MP Forums Archive
Enum question #2! - 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: Enum question #2! (/showthread.php?tid=555067)



Enum question #2! - TheTerminator - 06.01.2015

When you use:


PlayerInfo[playerid][pDeaths]++;


It adds 1 more into your previous deaths in the .ini file.

How can I limit that?
I want to limit that(pDeaths) to, say, max. 10.

I.E So that in the .ini file of the user, the max number that can get reached is 10, and not more.
Oh and that it can't go down from 0, just to reach 0 and that's it.


Re: Enum question #2! - Divergent - 06.01.2015

In your save function.

If(0 < PlayerInfo[playerid][pDeaths] < 10)
then save deaths.


Re: Enum question #2! - viddo - 06.01.2015

Make it save from 0 until it reaches 10 only. I.E: if (PlayerInfo[playerid][pDeaths] >= 0 || PlayerInfo[playerid][pDeaths<=10) then save... this will make it only save from 0 to 10 deaths.


Re: Enum question #2! - TheTerminator - 06.01.2015

Quote:
Originally Posted by Divergent
Посмотреть сообщение
In your save function.

If(0 < PlayerInfo[playerid][pDeaths] < 10)
then save deaths.
I don't quite understand where this should go, can you pretend I'm an idiot and be a bit more precise? :S


Do you mean here?

pawn Код:
enum pInfo
{
    pBan,
    pHuman,
    pZombie,
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}



Re: Enum question #2! - Threshold - 06.01.2015

pawn Код:
if(PlayerInfo[playerid][pDeaths]++ >= 10) PlayerInfo[playerid][pDeaths] = 10;
??


Re: Enum question #2! - RedFusion - 06.01.2015

pawn Код:
if(PlayerInfo[playerid][pDeaths] < 10)
 PlayerInfo[playerid][pDeaths] ++;
Put this code inside your OnPlayerDeath callback, then save the variable to a file when the player disconnects


Re: Enum question #2! - danish007 - 06.01.2015

pawn Код:
PlayerInfo[playerid][pDeaths] ++;

if(PlayerInfo[playerid][pDeaths] == 10)
{
//msg that you want to add...
PlayerInfo[playerid][pDeaths] = 0;//your deaths willbe 0 again after 10 deaths.
}



Re: Enum question #2! - TheTerminator - 06.01.2015

It worked thanks to you all, now tell me how do I REP+ you?


Re: Enum question #2! - RedFusion - 06.01.2015

no need for that, glad i could help