Rank -
McCarthy - 17.09.2011
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?
Re: Rank -
=WoR=Varth - 17.09.2011
pawn Код:
new PoliceRanks[2][24] =
{
{"Sergeant"},
{"Captain"}
};
Your cops variable?
Re: Rank -
Tee - 17.09.2011
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;
}
Re: Rank -
McCarthy - 17.09.2011
Thank you, what about a command like /rank id ?
Quote:
Originally Posted by varthshenon
Your cops variable?
|
What do you mean with this?
Re: Rank -
Tee - 17.09.2011
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;
}
Re: Rank -
McCarthy - 17.09.2011
Quote:
Originally Posted by Tee
pawn Код:
new id,rank = your rank variable;
|
What should I fill in here? D:
Re: Rank -
Tee - 17.09.2011
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;
}
Re: Rank -
McCarthy - 17.09.2011
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;
}
Re: Rank -
=WoR=Varth - 17.09.2011
Are you using strtok?
Re: Rank -
McCarthy - 17.09.2011
Yes I prefer strcmp and strtok :3