How to check if reason is not put? - 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: How to check if reason is not put? (
/showthread.php?tid=318712)
How to check if reason is not put? -
L0zaix - 16.02.2012
i'm making my first admin system.
How to check if the reason is empty so it will send to everyone like this
"PlayerName has been kicked by AdminName | Reason: N/A"
pawn Код:
CMD:kick(playerid, params[])
{
new string[128],
pname[MAX_PLAYER_NAME],
victimname[MAX_PLAYER_NAME],
victimid,
reason[30];
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(victimid, victimname, sizeof(victimname));
if(pInfo[playerid][alevel] > 1)
{
if(sscanf(params, "us", victimid, reason)) return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /kick <playername/id> <reason>");
if(victimid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid-ID!");
if(victimid == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot kick yourself!");
format(string, sizeof(string), "You kicked %s(ID:%d) | Reason: %s", victimname, victimid, reason);
SendClientMessage(playerid, COLOR_RED, string);
format(string, sizeof(string), "%s(ID:%d) has been kicked by %s(ID:%d) | Reason: %s", victimname, victimid, pname, playerid, reason);
SendClientMessageToAll(COLOR_RED, string);
format(string, sizeof(string), "You have been kicked by %s(ID:%d) | Reason: %s", pname, playerid, reason);
SendClientMessage(victimid, COLOR_RED, string);
Kick(victimid);
}
else return SendClientMessage(playerid, COLOR_RED, "You must be Administrator Level 1 or higher to use this command!");
return 1;
}
also tell me if the command is correct its untested
Re: How to check if reason is not put? -
emokidx - 16.02.2012
pawn Код:
if(sscanf(params, "uS(N/A)[128]", victimid, reason)) return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /kick <playername/id> <reason>");
as far as i know
it will make the reason optional, and if left empty will give the reason as "N/A"
Re: How to check if reason is not put? -
Wesley221 - 16.02.2012
pawn Код:
if(sscanf(params, "us(N/A)[30]", victimid, reason))
The [30] is for the string size, you forgot that one. The text between the ( & ) is the standard value.
Edit: Or switch the (N/A) with [30], not sure which one should come first