Rank system
#1

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

Код:
// 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.
Reply
#3

No no i mean when like the system check every time player kill 50 players it rank up him
Reply
#4

You could just have a "stock"(a term that should not be used)

such as
PHP код:
CheckPlayerKills(playerid)
{
      
//just do the code that @Hansrutger

Reply
#5

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

You don't need to use timer for that, if a player is killed it will trigger OnPlayerDeath callback.
Reply
#7

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(playeridkilleridreason)
{
       
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
Reply
#8

You can't understand me i mean every 50 kills the player get rank up
Reply
#9

and it only meant you didn't read the code
PHP код:
public OnPlayerDeath(playeridkilleridreason

       
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(playeridCOLOR_RED"Oho shit. Holla there n*gg*. You did some tight shit and got fifty heads.");
        
SCM(playeridCOLOR_RED"You oughta have some kind of reward. Here foo take this.")
        
SCM(playeridCOLOR_RED"You have ranked up.");
                
//add some theatrics and some shit and your good.
        
PlayerData[playerid][rank] += 1// or rank++
    
}
    return 
1;

Reply
#10

Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
and it only meant you didn't read the code
PHP код:
public OnPlayerDeath(playeridkilleridreason

       
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(playeridCOLOR_RED"Oho shit. Holla there n*gg*. You did some tight shit and got fifty heads.");
        
SCM(playeridCOLOR_RED"You oughta have some kind of reward. Here foo take this.")
        
SCM(playeridCOLOR_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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)