Enum question #2!
#1

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.
Reply
#2

In your save function.

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

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.
Reply
#4

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
}
Reply
#5

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

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
Reply
#7

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.
}
Reply
#8

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

no need for that, glad i could help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)