16.02.2017, 13:10
I made rank system and putted it in onplayerdeath but instead of alot of codes i want to make it simple like when player get +50 he get +1 rank and when he get +100 kills he get rank 2 how?
// Inside OnPlayerDeath switch (KillAmounts[killerid]) { case 50: { // do something to promote player } case 100: { // do something to promote to lvl 2 } }
CheckPlayerKills(playerid)
{
//just do the code that @Hansrutger
}
You could just have a "stock"(a term that should not be used)
such as PHP код:
|
task twosecondtimer[2000]()
{
//all your functions here.
}
You don't need to use timer for that, if a player is killed it will trigger OnPlayerDeath callback.
|
public OnPlayerDeath(playerid, killerid, reason)
{
CheckPlayerKills(killerid); //but you'll still need codes inside this to make it work. No way around it
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
CheckPlayerKills(killerid); //but you'll still need codes inside this to make it work. No way around it
return 1;
}
enum pInfo
{
ID,
Name[MAX_PLAYER_NAME],
Kills,
Deaths,
}
new PlayerData[MAX_PLAYERS][pInfo]
CheckPlayerKills(playerid)
{
PlayerData[playerid][Kills]+=1;
if(PlayerData[playerid][Kills] == 50)
{
SCM(playerid, COLOR_RED, "Oho shit. Holla there n*gg*. You did some tight shit and got fifty heads.");
SCM(playerid, COLOR_RED, "You oughta have some kind of reward. Here foo take this.")
SCM(playerid, COLOR_RED, "You have ranked up.");
//add some theatrics and some shit and your good.
PlayerData[playerid][rank] += 1; // or rank++
}
return 1;
}
and it only meant you didn't read the code
PHP код:
Now if that is called correctly and I am assuming that you have set you players enums to a kills ie. PHP код:
PHP код:
|
if(PlayerData[playerid][Kills] == 50)