#1

Currently, I have a cop system using numbers 0-8, I want to make a /rank system that would return the players rank.
So for example players rank is 5 and 5 would be Sergeant, how can I make a command like this?
Reply
#2

pawn Код:
new PoliceRanks[2][24] =
{
    {"Sergeant"},
    {"Captain"}
};
Your cops variable?
Reply
#3

Here, I used Varthshenon's example to show you what to do.

pawn Код:
new PoliceRanks[][32] =
{
    {"Rank1"},//Count starts from 0 so this would actually be 0. Rank0 (mabye Officer)
    {"Rank2"},
    {"Rank3"},
    {"Rank4"},
    {"Rank5"},
    {"Rank6"},
};

COMMAND:rank(playerid, params[])
{
    new rank = your rank variable;
    format(string,sizeof(string),"Your rank is %s",PoliceRanks[rank]);
    SendClientMessage(playerid,-1,string);
    return 1;
}
Reply
#4

Thank you, what about a command like /rank id ?

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
Your cops variable?
What do you mean with this?
Reply
#5

pawn Код:
new PoliceRanks[][32] =
{
    {"Rank1"},//Count starts from 0 so this would actually be 0. Rank0 (mabye Officer)
    {"Rank2"},
    {"Rank3"},
    {"Rank4"},
    {"Rank5"},
    {"Rank6"},
};

COMMAND:getrank(playerid, params[])
{
    new id,rank = your rank variable;
    if(sscanf(params,"u",id))return SendClientMessage(playerid,-1,"Usage: /getrank [id / part of name]");
    format(string,sizeof(string),"%s's rank is %s",GetName(id),PoliceRanks[rank]);
    SendClientMessage(playerid,-1,string);
    return 1;
}

stock GetName(playerid)
{
    new n[24];
    GetPlayerName(playerid,n,sizeof(n));
    return n;
}
Reply
#6

Quote:
Originally Posted by Tee
Посмотреть сообщение
pawn Код:
new id,rank = your rank variable;
What should I fill in here? D:
Reply
#7

The variable that stores ranks. Like PlayerInfo[id][Rank]....

pawn Код:
new PoliceRanks[][32] =
{
    {"Rank1"},//Count starts from 0 so this would actually be 0. Rank0 (mabye Officer)
    {"Rank2"},
    {"Rank3"},
    {"Rank4"},
    {"Rank5"},
    {"Rank6"},
};

COMMAND:getrank(playerid, params[])
{
    new id,rank = PlayerInfo[id][Rank];//Change that to your rank variable.
    if(sscanf(params,"u",id))return SendClientMessage(playerid,-1,"Usage: /getrank [id / part of name]");
    format(string,sizeof(string),"%s's rank is %s",GetName(id),PoliceRanks[rank]);
    SendClientMessage(playerid,-1,string);
    return 1;
}

stock GetName(playerid)
{
    new n[24];
    GetPlayerName(playerid,n,sizeof(n));
    return n;
}
Reply
#8

Ah alright, I got it, but gives me one error
error 017: undefined symbol "params"

pawn Код:
if(strcmp(cmd, "/rank", true) == 0)
    {
        new id,rank = AccountInfo[playerid][wspd];
        if(sscanf(params,"u",id))return SendClientMessage(playerid,-1,"Usage: /rank [id / part of name]");
        format(string,sizeof(string),"%s's rank is %s",GetName(id),PoliceRanks[rank]);
        SendClientMessage(playerid,-1,string);
        return 1;
    }
Reply
#9

Are you using strtok?
Reply
#10

Yes I prefer strcmp and strtok :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)