Admin Levels -
Lucky™ - 09.05.2013
Hello, I have small question again. Well Let's say in the script they are six admin levels [1,2,3,4,5,6] and when we're talking over /a, I need to show them as Junior Administraor [playername], General Administraor [playername], Server Owner [playername], like that.
Currently it's showing like Admin Level 1 [playername], Admin Level 2 [playername], so on.
Current /a code is
PHP код:
CMD:admin(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
/*if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
{
SendClientMessage(playerid,COLOR_WHITE, "You can only chat while off-duty. Type /aduty to go on-duty.");
return 1;
}*/
if(!isnull(params))
{
new szMessage[128];
format(szMessage, sizeof(szMessage), "* Level %d Admin %s: %s", PlayerInfo[playerid][pAdmin], GetPlayerNameEx(playerid), params);
ABroadCast(COLOR_YELLOW, szMessage, 1);
}
else SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/a)dmin [admin chat]");
}
return 1;
}
I tried some ways, Not working.
Re: Admin Levels -
Kwarde - 09.05.2013
Here you go:
pawn Код:
stock admName(level)
{
new output[50];
switch (level)
{
case 0: format(output, 50, "No admin"); //Admin level 0
case 1: format(output, 50, "Adm 1"); //Admin level 1
case 2: format(output, 50, "Adm 2"); //Admin level 2
default: format(output, 50, "Unknown"); //Name for undefined admin levels
}
return output;
}
In order to use, do this:
format(szMessage, 128, "* %s %s(%d): %s", admName(PlayerInfo[playerid][pAdmin]), GetPlayerNameEx(playerid, playerid, params);
This would return (if the admin level would be 2, playername 'Kwarde', ID 0 and 'params' = 'Hello'):
* Adm 1 Kwarde(0): Hello.
Off course you must edit this function; add more levels, edit current level names

. If you have admin-level names that contains more then 50 characters, change this too!
Re: Admin Levels -
Lucky™ - 09.05.2013
Quote:
Originally Posted by Kwarde
Here you go:
pawn Код:
stock admName(level) { new output[50]; switch (level) { case 0: format(output, 50, "No admin"); //Admin level 0 case 1: format(output, 50, "Adm 1"); //Admin level 1 case 2: format(output, 50, "Adm 2"); //Admin level 2 default: format(output, 50, "Unknown"); //Name for undefined admin levels } return output; }
In order to use, do this:
format(szMessage, 128, "* %s %s(%d): %s", admName(PlayerInfo[playerid][pAdmin]), GetPlayerNameEx(playerid, playerid, params);
This would return (if the admin level would be 2, playername 'Kwarde', ID 0 and 'params' = 'Hello'):
* Adm 1 Kwarde(0): Hello.
Off course you must edit this function; add more levels, edit current level names  . If you have admin-level names that contains more then 50 characters, change this too!
|
C:\Users\xxx\Desktop\xxx\xxx\xxx\gamemodes\xxx.pwn (3854) : error 040: duplicate "case" label (value 2)
C:\Users\xxx\Desktop\xxx\xxx\xxx\gamemodes\xxx.pwn (36531) : warning 202: number of arguments does not match definition
C:\Users\xxx\Desktop\xxx\xxx\xxx\gamemodes\xxx.pwn (36531) : warning 202: number of arguments does not match definition
C:\Users\xxx\Desktop\xxx\xxx\xxx\gamemodes\xxx.pwn (36531) : error 001: expected token: ",", but found ";"
and the here's the line 36531 code:
format(szMessage, 128, "* %s %s(%d): %s", admName(PlayerInfo[playerid][pAdmin]), GetPlayerNameEx(playerid, playerid, params); (the one you gave)
Re: Admin Levels -
Kwarde - 09.05.2013
I see that 'GetPlayerNameEx(playerid,' should be 'GetPlayerNameEx(playerid),'.
Also, you could use this stock, too:
pawn Код:
stock admName(playerid)
{
new output[50];
switch (PlayerInfo[playerid][pAdmin])
{
case 0: format(output, 50, "No admin");
case 1: format(output, 50, "Adm 1");
case 2: format(output, 50, "Adm 2"); //Etc!
default: format(output, 50, "Unknown");
}
return output;
}
And you don't
have to use what I posted, the format was an example

.
Just use the stock I provided (I tested the first one I posted and it worked for me) and futher just use
admName(playerid) to show the admin name. Use the first stock if you want to use
admName(PlayerInfo[playerid][pAdmin])
For the duplicated "case" (the first error), did you perhaps edit this function? For the next 'case' you must 'case 3', then 'case 4' etcetera. If you don't understand this, please post the admName function if you have editted it.
Re: Admin Levels -
Lucky™ - 09.05.2013
Aha, Yeah - Fixed it.
Thanks.
Re: Admin Levels -
Kwarde - 09.05.2013
You're welcome!
If you have any futher questions, don't hesitate to contact me

(Check my signature)