/Admins - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /Admins (
/showthread.php?tid=503277)
/Admins -
DerickClark - 28.03.2014
Command spam and not showing names?
pawn Код:
stock LevelName(playerid)
{
new Regular[128];
new Admin[128];
switch(PlayerInfo[playerid][pAdmin])
{
case 0: Regular = "Regular player";
case 1: Admin = "Moderator";
case 2: Admin = "Administrator";
}
return Admin;
}
CMD:admins(playerid)
{
new Count;
new str[45], Admin[MAX_PLAYER_NAME];
SendClientMessage(playerid, -1, "Online Staff Members:");
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(PlayerInfo[i][pAdmin] < 2)
{
Count ++;
GetPlayerName(i, Admin, MAX_PLAYER_NAME);
format(str, sizeof str, "%s ({FFFF00}%s{FFFFFF})",Admin, LevelName(i));
SendClientMessage(playerid, -1, str);
}
}
if(Count < 1) SendClientMessage(playerid, -1, "No Admins Online");
return 1;
}
[14:45:26] Test({FFFF00}{FFFFFF})
[14:45:26] Test({FFFF00}{FFFFFF})
[14:45:26] Test({FFFF00}{FFFFFF})
[14:45:26] Test({FFFF00}{FFFFFF})
[14:45:26] Test({FFFF00}{FFFFFF})
Re: /Admins -
Konstantinos - 28.03.2014
pawn Код:
stock LevelName(playerid)
{
new Admin[32];
switch (PlayerInfo[playerid][pAdmin])
{
case 0: Admin = "Regular player";
case 1: Admin = "Moderator";
case 2: Admin = "Administrator";
}
return Admin;
}
pawn Код:
CMD:admins(playerid)
{
new Count, str[64], Admin[MAX_PLAYER_NAME];
SendClientMessage(playerid, -1, "Online Staff Members:");
for (new i = 0; i < MAX_PLAYERS; i ++)
{
if (PlayerInfo[i][pAdmin] >= 2) // change "2" to the min admin level
{
Count ++;
GetPlayerName(i, Admin, MAX_PLAYER_NAME);
format(str, sizeof (str), "%s ({FFFF00}%s{FFFFFF})", Admin, LevelName(i));
SendClientMessage(playerid, -1, str);
}
}
if (!Count) SendClientMessage(playerid, -1, "No Admins Online");
return 1;
}
@AhmedMohamed: The problem was in the stock that if the pAdmin was 0, you set the admin name to the variable "Regular" but you returned "Admin" so in other words it's empty. Also the operator in the admin level in the command (in the loop) was incorrect.
Re: /Admins -
AhmedMohamed - 28.03.2014
what was the problem Konstantinos?
Re: /Admins -
DerickClark - 28.03.2014
Thank you.