if(PlayerInfo[playerid][pAdmin] == 1)
{
SendClientMessage(playerid, YOUR_COLOR, "You`re: Moderator");
}
else if(PlayerInfo[playerid][pAdmin] == 2)
{
SendClientMessage(playerid, YOUR_COLOR, "You`re: Supporter");
}
else if(PlayerInfo[playerid][pAdmin] == 3)
{
SendClientMessage(playerid, YOUR_COLOR, "You`re: Administrator");
}
Result for Rank 2: "You`re Supporter"
GetPlayerAdminName(playerid)
{
new result[14];
switch(PlayerInfo[playerid][pAdmin])
{
case 0:{result="No Admin";}
case 1:{result="Moderator";}
case 2:{result="Supporter";}
case 3:{result="Administrator";}
}
return result;
}
new string[64];
format(string,sizeof(string),"You`re: %s",GetPlayerAdminName(playerid));
SendClientMessage(playerid, YOUR_COLOR, string);
Result for Rank 2: "You`re: Supporter"
GetPlayerAdminName(playerid) //Giving the function a name. Can be anything.
{
new result[14]; //creating a string where the output will be stored in.
switch(PlayerInfo[playerid][pAdmin]) //switching the variable. In this case we switch the players adminrank.
{
case 0:{result="No Admin";}//in the case the player got the adminrank zero, we would call him "No Admin"
case 1:{result="Moderator";}//in the case 1, moderator.
case 2:{result="Supporter";}//etc...
case 3:{result="Administrator";}
}
return result;//after the switch is done, and the "result" is now filled with the players adminname, we return the result.
}
// global
new const gAdminLevel[][] = {
"None", // 0
"Mod", // 1
"Support", // 2
"Admin" // 3
};
//where ever
new string[64];
format(string,sizeof(string),"You`re: %s", gAdminLevel[PlayerInfo[playerid][pAdmin]]);
SendClientMessage(playerid, YOUR_COLOR, string);
I reckon that a constant array is shorter, still. But I don't know if it will actually be faster.
PHP Code:
PHP Code:
![]() |