Rank system -
Loinal - 16.02.2017
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?
Re: Rank system -
Hansrutger - 16.02.2017
Код:
// Inside OnPlayerDeath
switch (KillAmounts[killerid])
{
case 50:
{
// do something to promote player
}
case 100:
{
// do something to promote to lvl 2
}
}
That's the principle. You could also use if statements (not that it matters in pawn, it does in other languages) but I personally like switches as they look a bit better and it's easier to read most of the time.
Re: Rank system -
Loinal - 16.02.2017
No no i mean when like the system check every time player kill 50 players it rank up him
Re: Rank system -
JesterlJoker - 16.02.2017
You could just have a "stock"(a term that should not be used)
such as
PHP код:
CheckPlayerKills(playerid)
{
//just do the code that @Hansrutger
}
Re: Rank system -
Loinal - 16.02.2017
Quote:
Originally Posted by JesterlJoker
You could just have a "stock"(a term that should not be used)
such as
PHP код:
CheckPlayerKills(playerid)
{
//just do the code that @Hansrutger
}
|
Not like this
i mean
every 2 sec it checks if player kills 50 it give him rank 1 if he killed onther 50 it give him rank 2
Re: Rank system -
X337 - 16.02.2017
You don't need to use timer for that, if a player is killed it will trigger OnPlayerDeath callback.
Re: Rank system -
JesterlJoker - 16.02.2017
a timer as in timer like?
PHP код:
task twosecondtimer[2000]()
{
//all your functions here.
}
That's unethical in a way because you could just trigger a function on OnPlayerDeath that checks the achievements.
just like what X337 said
Quote:
Originally Posted by X337
You don't need to use timer for that, if a player is killed it will trigger OnPlayerDeath callback.
|
PHP код:
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;
}
simplifying it would need to use switch-case
Re: Rank system -
Loinal - 16.02.2017
You can't understand me i mean every 50 kills the player get rank up
Re: Rank system -
JesterlJoker - 16.02.2017
and it only meant you didn't read the code
PHP код:
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;
}
I specified the killerid not the playerid which means I indicated whoever the killer is.
Now if that is called correctly and I am assuming that you have set you players enums to a kills
ie.
PHP код:
enum pInfo
{
ID,
Name[MAX_PLAYER_NAME],
Kills,
Deaths,
}
new PlayerData[MAX_PLAYERS][pInfo]
now you do this on checkplayerkills
PHP код:
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;
}
Re: Rank system -
Loinal - 16.02.2017
Quote:
Originally Posted by JesterlJoker
and it only meant you didn't read the code
PHP код:
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;
}
I specified the killerid not the playerid which means I indicated whoever the killer is.
Now if that is called correctly and I am assuming that you have set you players enums to a kills
ie.
PHP код:
enum pInfo
{
ID,
Name[MAX_PLAYER_NAME],
Kills,
Deaths,
}
new PlayerData[MAX_PLAYERS][pInfo]
now you do this on checkplayerkills
PHP код:
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;
}
|
I read it but i ignored cause
You said this
Код:
if(PlayerData[playerid][Kills] == 50)
And i need every 50 kills it rank up