18.07.2012, 13:32
Hey there guys,
I'm kind of new to sscanf and ZCMD altogether, but I just wanted to ask a quick question.
Here's my /kick command:
Okay, so let's just say that if I tried to kick someone for a reason, it would appear as normal. As you may have noticed, I have if(!strlen(reason)) in my script, telling it to return as 'No Reason', but I still get the Syntax Error above it. So how would I go about making it, so that if they didn't enter a reason, it would return as 'No Reason', but if they DID enter it, it would function as normal?
I appreciate any help you can offer and will gladly give rep upon request to any helpers.
Regards,
clarencecuzz.
I'm kind of new to sscanf and ZCMD altogether, but I just wanted to ask a quick question.
Here's my /kick command:
pawn Код:
CMD:kick(playerid,params[])
{
new id, reason[60];
if(!IsPlayerAdmin(playerid) && Player[playerid][Admin] < 4) return SendClientMessage(playerid, red, "ERROR: {FFFFFF}You Have Entered An Invalid Command. Read {00FF00}/CMDS{FFFFFF}.");
if(sscanf(params,"us[60]",id,reason) || sscanf(params,"u",id)) return SendClientMessage(playerid, red, "SYNTAX ERROR: {00FF00}/KICK {FFFF00}<PlayerID> <Reason>");
if(strlen(reason) > 60) return SendClientMessage(playerid, red, "ERROR: {FFFFFF}Reason Must Be Below 60 Characters.");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "ERROR: {FFFFFF}Player Is Not Connected.");
if(!strlen(reason))
{
reason = "No Reason.";
}
new string[134], string2[177];
if(Player[playerid][Hidden] == 0)
{
format(string,sizeof(string),"You Have Been Kicked By Administrator %s | Reason: %s", pName(playerid), reason);
format(string,sizeof(string),"Player %s Has Been Kicked From The Server By Administrator %s | Reason: %s",pName(id),pName(playerid),reason);
}
else
{
format(string,sizeof(string),"You Have Been Kicked From The Server | Reason: %s", reason);
format(string2,sizeof(string2),"Player %s Has Been Kicked From The Server | Reason: %s",pName(id),reason);
}
SendClientMessage(id, red, string);
SendClientMessage(id, orange, "If You Think This Is A Mistake Or You Are Being Treated Unfairly, Post A Report At 'WWW.AWPGAMING.COM/FORUMS'");
format(string,sizeof(string),"You Have Kicked %s From The Server | Reason: %s", pName(id), reason);
SendClientMessage(playerid, yellow, string);
format(string,sizeof(string),"Administrator %s Has Kicked Player %s | Reason: %s",pName(playerid), pName(id), reason);
Kick(id);
SendClientMessageToAll(red,string2);
return 1;
}
I appreciate any help you can offer and will gladly give rep upon request to any helpers.
Regards,
clarencecuzz.