Player Rank by kills
#1

Hey guys

pawn Код:
CMD:stats(playerid, params[])
{
    new id;
    new Cash = PlayerInfo[id][pCash];
    new Deaths = PlayerInfo[id][pDeaths];
    new Kills = PlayerInfo[id][pKills];
    new Score = PlayerInfo[id][pScore];
    new pName[24];
    new string[128];
   
    if(sscanf(params, "u", id))
        return SendClientMessage(playerid, DEEPPINK, "USAGE: /stats <id>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
    {
        GetPlayerName(playerid, pName, sizeof pName);
        format(string, sizeof(string), "{00FF22}===============[Stats of {FFFFFF}%s{00FF22}]==============", pName);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Cash: {00FF22}%d $", Cash);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Deaths: {00FF22}%d {FFFFFF}| Kills: {00FF22}%d", Deaths, Kills);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Score: {00FF22}%d", Score);
        SendClientMessage(playerid, -1, string);
        SendClientMessage(playerid, -1, "{00FF22}================================================");
    }
    return 1;
}
This is my Stats cmd, i want to ask you guys how i can make a thing that would say -> Example: 10 kills = Rank: Noobie, 20 kills = Rank: Trainee, or sth like that, please help . . thanks
Reply
#2

Try this. This is how we do it.

pawn Код:
CMD:stats(playerid, params[])
{
    new id;
    new Cash = PlayerInfo[id][pCash];
    new Deaths = PlayerInfo[id][pDeaths];
    new Kills = PlayerInfo[id][pKills];
    new Score = PlayerInfo[id][pScore];
    new pName[24];
    new string[128];
        new rank[30];
    switch(Kills)
    {
        case 0..100: rank= "None";
        case 101..500: rank= "Savage Killer";
               //Setting the rank according to the kills
    }
   
    if(sscanf(params, "u", id))
        return SendClientMessage(playerid, DEEPPINK, "USAGE: /stats <id>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
    {
        GetPlayerName(playerid, pName, sizeof pName);
        format(string, sizeof(string), "{00FF22}===============[Stats of {FFFFFF}%s{00FF22}]==============", pName);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Cash: {00FF22}%d $ | {FFFFFF}Rank: {00FF22}%s", Cash , rank);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Deaths: {00FF22}%d {FFFFFF}| Kills: {00FF22}%d", Deaths, Kills);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Score: {00FF22}%d", Score);
        SendClientMessage(playerid, -1, string);
        SendClientMessage(playerid, -1, "{00FF22}================================================");
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
..
Should probably move it to a function since it's something that will probably be used in multiple places
Reply
#4

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
Should probably move it to a function since it's something that will probably be used in multiple places
Yo Antonia. Been a long time bro. You're right but it is a command he wants it to be in. Only in the statistics right. So added there only. His wish if he wants to make it a function and call it at many places.
Reply
#5

I used [playerid] with the rank variable to prevent the conflict of stats string showing if any occurs.
You may add this function: (just example)

pawn Код:
CMD:stats(playerid, params[])
{
    new Rank[playerid][100];
    new id;
    new Cash = PlayerInfo[id][pCash];
    new Deaths = PlayerInfo[id][pDeaths];
    new Kills = PlayerInfo[id][pKills];
    new Score = PlayerInfo[id][pScore];
    new pName[24];
    new string[128];
   
    if(GetPlayerScore(playerid)>=0)
    { Rank[playerid]="Noobie"}  
   
    if(sscanf(params, "u", id))
        return SendClientMessage(playerid, DEEPPINK, "USAGE: /stats <id>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
    {
        GetPlayerName(playerid, pName, sizeof pName);
        format(string, sizeof(string), "{00FF22}===============[Stats of {FFFFFF}%s{00FF22}]==============", pName);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Cash: {00FF22}%d $", Cash);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Deaths: {00FF22}%d {FFFFFF}| Kills: {00FF22}%d", Deaths, Kills);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Score: {00FF22}%d |{FFFFFF}Rank: {00FF22}%s", Score, Rank[playerid]);
        SendClientMessage(playerid, -1, string);
        SendClientMessage(playerid, -1, "{00FF22}================================================");
    }
    return 1;
}
Add more lines of this:
pawn Код:
if(GetPlayerScore(playerid)>=0)
{ Rank[playerid]="Noobie";  }
And set the string to a different rank name & the score required..
Reply
#6

Quote:
Originally Posted by Excel™
Посмотреть сообщение
I used [playerid] with the rank variable to prevent the conflict of stats string showing if any occurs.
You may add this function: (just example)

pawn Код:
CMD:stats(playerid, params[])
{
    new Rank[playerid][100];
    new id;
    new Cash = PlayerInfo[id][pCash];
    new Deaths = PlayerInfo[id][pDeaths];
    new Kills = PlayerInfo[id][pKills];
    new Score = PlayerInfo[id][pScore];
    new pName[24];
    new string[128];
   
    if(GetPlayerScore(playerid)>=0)
    { Rank[playerid]="Noobie"}  
   
    if(sscanf(params, "u", id))
        return SendClientMessage(playerid, DEEPPINK, "USAGE: /stats <id>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
    {
        GetPlayerName(playerid, pName, sizeof pName);
        format(string, sizeof(string), "{00FF22}===============[Stats of {FFFFFF}%s{00FF22}]==============", pName);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Cash: {00FF22}%d $", Cash);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Deaths: {00FF22}%d {FFFFFF}| Kills: {00FF22}%d", Deaths, Kills);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Score: {00FF22}%d |{FFFFFF}Rank: {00FF22}%s", Score, Rank[playerid]);
        SendClientMessage(playerid, -1, string);
        SendClientMessage(playerid, -1, "{00FF22}================================================");
    }
    return 1;
}
Add more lines of this:
pawn Код:
if(GetPlayerScore(playerid)>=0)
{ Rank[playerid]="Noobie";  }
And set the string to a different rank name & the score required..
You made no sense. Its actually the same. A local Array is executed faster then the Global arrays. If you're not aware of it. I also benchmarked it many times.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)