05.12.2018, 13:12
Quote:
Hello, i have this command and i want to make these variables ( if pFaction == 0) format(the name )
In this command the names for factions are locals, in this command, and i want to make them globals to use them on another commands. And i dont want to define everytime in every command the names of the factions. Код:
CMD:stats(playerid, params[]) { new string[128], fNume[128]; SCM(playerid, 0xFFD080FF, "___________________________________"); SCM(playerid, -1, ""); if(PlayerInfo[playerid][pFaction] == 0) format(fNume, 128, "Civil"); if(PlayerInfo[playerid][pFaction] == 1) format(fNume, 128, "Police Departament"); if(PlayerInfo[playerid][pFaction] == 2) format(fNume, 128, "Paramedic Departament"); if(PlayerInfo[playerid][pFaction] == 3) format(fNume, 128, "Taxi Company"); format(string, sizeof(string), "{FFD080}%s{E6E6E6}: Level: {FFD080}%d {E6E6E6}| Faction: {FFD080}%s {E6E6E6}| Ping:{FFD080}%d", GetName(playerid), GetPlayerScore(playerid), fNume, GetPlayerPing(playerid)); SCM(playerid, 0xFFD080FF, string); SCM(playerid, 0xFFD080FF, "___________________________________"); return 1; |
PHP код:
GetFactionName(faction)
{
new string[24];
switch(faction)
{
case 0: string = 'Civil';
case 1: string = 'Police Departament';
case 2: string = 'Paramedic Departament';
case 3: string = 'Taxi Company';
//continue
}
return string;
}
//Use
new string[128];
format(string, 128, "Faccion: %s", GetFactionName(PlayerData[playerid][faction]);