Help, /adminname -
volcaN131 - 05.07.2013
Hello guys,
This time I attepmted to make a /adminname command which will display when you do /admins.
/admins shows the admins online.
Example:
My name IG is James Colorado and I chose the /adminname to volcaN131
Then when I did /adminname volcaN131
It will display in /admins like this:
Adminrank name (adminname)
Head of Staff James Colorado (volcaN131).
This is what I got:
Код:
}
if (strcmp(cmd, "/admins", true) == 0)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COLOR_YELLOW,"__________________________________________________________");
SendClientMessage(playerid, COLOR_LIGHTYELLOW," Realism Roleplay Admministration team: ");
foreach (Player,i)
{
if(PlayerInfo[i][pHidden] == 0)
{
if(PlayerInfo[i][pAdmin] >= 1)
{
new admtext[64];
if(PlayerInfo[i][pAdmin] == 7) { admtext = "Head of Staff"; }
else if(PlayerInfo[i][pAdmin] == 5) { admtext = "Senior Administrator"; }
else if(PlayerInfo[i][pAdmin] == 4) { admtext = "Administrator Level 3"; }
else if(PlayerInfo[i][pAdmin] == 3) { admtext = "Administrator Level 2"; }
else if(PlayerInfo[i][pAdmin] == 1) { admtext = "Operator"; }
else if(PlayerInfo[i][pAdmin] == 6) { admtext = "Lead Administrator"; }
else { admtext = "Unknown rank"; }
GetPlayerName(i, sendername, sizeof(sendername));
if(PlayerInfo[i][pAdmin] == 11)
{
SendClientMessage(playerid, COLOR_LIGHTYELLOW, "[ONLINE]: Admin [ID: 501]");
}
else if(strcmp(PlayerInfo[i][pAdmName], "None", true) == 0)
{
if(AdminDuty[i] == 0)
{
format(string, 256, "[ONLINE]: %s: %s [ID: %d]", admtext, sendername, i);
SendClientMessage(playerid, COLOR_LIGHTYELLOW, string);
}
else if(AdminDuty[i] == 1)
{
format(string, 256, "[ONLINE]: %s: %s [ID: %d] (on duty)", admtext, sendername, i);
SendClientMessage(playerid, TEAM_VAGOS_COLOR, string);
}
}
else
{
if(AdminDuty[i] == 0)
{
format(string, 256, "[ONLINE]: %s (%s): %s [ID: %d]", admtext, PlayerInfo[i][pAdmName], sendername, i);
SendClientMessage(playerid, COLOR_LIGHTYELLOW, string);
}
else if(AdminDuty[i] == 1)
{
format(string, 256, "[ONLINE]: %s (%s): %s [ID: %d] (on duty)", admtext, PlayerInfo[i][pAdmName], sendername, i);
SendClientMessage(playerid, TEAM_VAGOS_COLOR, string);
}
}
}
}
}
}
SendClientMessage(playerid, COLOR_YELLOW,"__________________________________________________________");
return 1;
}
And:
Код:
if(strcmp(cmd,"/admimname",true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] == 0)
{
SendClientMessage(playerid,COLOR_GREY," You do not have access to this command !");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "{33CCFF}USAGE:{FFFFFF} /admiName [Text]");
return 1;
}
if(strcmp(PlayerInfo[playerid][pAdmName], "None", true) == 0)
{
strmid(PlayerInfo[playerid][pAdmName], result, 0, strlen(result), 255);
SendClientMessage(playerid,COLOR_GREY,"Name added.");
}
else
{
strmid(PlayerInfo[playerid][pAdmName], "None", 0, strlen("None"), 255);
SendClientMessage(playerid,COLOR_GREY,"Name removed.");
}
return 1;
}
When I compile, I get this:
Код:
C:\Users\Administrator\Desktop\New folder\gamemodes\U-RP.pwn(38359) : warning 213: tag mismatch
C:\Users\Administrator\Desktop\New folder\gamemodes\U-RP.pwn(63349) : error 028: invalid subscript (not an array or too many subscripts): "AdminDuty"
C:\Users\Administrator\Desktop\New folder\gamemodes\U-RP.pwn(63349) : warning 215: expression has no effect
C:\Users\Administrator\Desktop\New folder\gamemodes\U-RP.pwn(63349) : error 001: expected token: ";", but found "]"
C:\Users\Administrator\Desktop\New folder\gamemodes\U-RP.pwn(63349) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Desktop\New folder\gamemodes\U-RP.pwn(63349) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Please help

?
Re: Help, /adminname -
Sandiel - 05.07.2013
Create a new variable in your enumations containing the player's data, Ex:
pawn Код:
enum pInfo
{
....,
....,
AdminName[64],
}
new PlayerInfo[MAX_PLAYERS][pInfo];
// then in the /adminname command:
format(PlayerInfo[playerid][AdminName], 64, "%s", param); // off course change param to the one you've made in your cmd(/adminname [param]
// under the /admins cmd:
new string[128];
format(string, sizeof(string), "%s %s %s", AdminRank, PlayersName, PlayerInfo[playerid][AdminName]); // change admin rank and playersname to their respective values off course.
// Don't forget to save & load the player's adminname variable ;)
Hope it helps.