How to check if the player typed a param or if its empty? - 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 the player typed a param or if its empty? (
/showthread.php?tid=315734)
How to check if the player typed a param or if its empty? -
milanosie - 04.02.2012
Hi there, how to check if a reason for this /kick is given?
I mean, how to make it so that if no reason is given it will send No Reason Given
pawn Код:
CMD:kick(playerid, params[])
{
new id;
new reason;
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
if(!sscanf(params, "uz", id, reason))
{
new string[256];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Administrator %s has just kicked %s for reason %s", name, PlayerName, reason);
ProxDetector(10000000000.0, playerid, string, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF);
Kick(id);
return 1;
}
else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /kick [PlayerId/PartOfName] (Reason)");
}
else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command.");
}
Re: How to check if the player typed a param or if its empty? -
Konstantinos - 04.02.2012
"z" was removed, use S(string)[length] instead.
Re: How to check if the player typed a param or if its empty? -
milanosie - 04.02.2012
z is removed,
So I have to use a BIG letter s?
and how to check if its empty or not?
Re: How to check if the player typed a param or if its empty? -
Babul - 04.02.2012
this
pawn Код:
CMD:kick(playerid, params[])
{
new id;
new reason[64];
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
if(!sscanf(params, "uS(no Reason given)[64]", id, reason))
{
new string[256];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Administrator %s has just kicked %s for reason %s", name, PlayerName, reason);
ProxDetector(10000000000.0, playerid, string, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF);
Kick(id);
return 1;
}
else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /kick [PlayerId/PartOfName] (Reason)");
}
else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command.");
}
Re: How to check if the player typed a param or if its empty? -
milanosie - 04.02.2012
Quote:
Originally Posted by Babul
this
pawn Код:
CMD:kick(playerid, params[]) { new id; new reason[64]; if(PlayerInfo[playerid][AdminLevel] >= 1) { if(!sscanf(params, "uS(no Reason given)[64]", id, reason)) { new string[256]; new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(id, PlayerName, sizeof(PlayerName)); format(string, sizeof(string), "Administrator %s has just kicked %s for reason %s", name, PlayerName, reason); ProxDetector(10000000000.0, playerid, string, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF); Kick(id); return 1; } else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /kick [PlayerId/PartOfName] (Reason)"); } else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command."); }
|
thanks