29.03.2013, 23:56
Hello, how can I create the command /asay [text] for this variable: if(PlayerInfo[playerid][AdminLevel] >= 1) (All lvls, form 1 to 5). Thanks
CMD:asay(playerid, params[])
{
new String[100];
if(PlayerInfo[playerid][AdminLevel] < 1)
return SendClientMessage(playerid, -1, "You need to be an Adminstrator to use this command!");
else if(sscanf(params, "s[100]", String))
return SendClientMessage(playerid, -1, "Usage: /asay <text>");
else
{
GameTextForAll(String, 4000, 3);
}
return 1;
}
Using ZCMD, sscanf :
pawn Код:
Next time ask on https://sampforum.blast.hk/showthread.php?tid=413556 please. |
COMMAND:asay(playerid,params[])
{
#pragma unused params
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
new text[128];
if(sscanf(params, "s[128]", text))
{
SendClientMessage(playerid,RED,"Usage: /asay <message>");
return 1;
}
new string[128];
format(string, sizeof(string), "* Admin %s: %s", GetName(playerid), text);
SendClientMessageToAll(RED,string);
}
else
{
SendClientMessage(playerid, RED,"You can't use this commands!");
}
return 1;
} // If you want it but with SendClientMessage
pawn Код:
|
pwn(1542) : error 017: undefined symbol "GetName"
CMD:asay(playerid, params[])
{
new String[100];
if(PlayerInfo[playerid][AdminLevel] < 1)
return SendClientMessage(playerid, -1, "You need to be an Adminstrator to use this command!");
else if(sscanf(params, "s[100]", String))
return SendClientMessage(playerid, -1, "Usage: /asay <text>");
else
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(String, 100, "Adminstrator %s : %s", pName, String);
SendClientMessageToAll(-1, String);
}
return 1;
}
CMD:asay(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] < 1) return 0;
if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /asay <text>");
new
text[ 128 ]
;
format(text, 128, "ADMIN: %s", params);
SendClientMessageToAll(-1, text);
return 1;
}
pawn Код:
|