Lil problem with dcmd
#1

hey scripters
before I tell you the problem ,please dont tell me to use ZCMD Cuz I hate it and I dont care if my script will be faster in 1 milisecond.
Ok so I got this cmd
Код:
dcmd_ban(playerid, params[])
{
    #pragma unused params
	small1;
	if(PlayerInfo[playerid][pAdminLevel] > 0)
	{
	    new id,reason[256];
	    if(sscanf(params,"ui",id,reason))
	    {
	        if(IsPlayerConnected(id))
			{
			new name[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],string[256],Year,Month,Day;
			GetPlayerName(id,aname,sizeof(aname));
			GetPlayerName(playerid,name,sizeof(name));

			getdate(Year,Month,Day);
			format(string,sizeof(string),"[URP] %d/%d/%d : You have banned %s.",Year,Month,Day,aname);
			SendClientMessage(playerid,COLOR_RED,string);
			format(string,sizeof(string),"[URP] %d/%d/%d : %s has been banned by Admin MR.%s. Reason : %s",Year,Month,Day,aname,name,reason);
			SendClientMessageToAll(COLOR_RED,string);
			BanLog(string);
			Ban(id);
			return 1;
			}else return notc(playerid);
	    }else return SendClientMessage(playerid,COLOR_RED,"[URP] : Usage : /ban [PLAYERID][REASON]");
	}
	return 1;
}
So No errors but , in the game , when I use /ban(just /ban no reason or playerid) it doesnt returns me the SendClientMessage(playerid,COLOR_RED,"[URP] : Usage : /ban [PLAYERID][REASON]");
and its auto bans me .
and at the
format(string,sizeof(string),"[URP] %d/%d/%d : %s has been banned by Admin MR.%s. Reason : %s",Year,Month,Day,aname,name,reason);
for some reason the reason thing doesnt working . I dont see the reason.
Reply
#2

Change

pawn Код:
if(sscanf(params,"ui",id,reason))
to

pawn Код:
if(!sscanf(params,"ui",id,reason))
since sscanf returns 0/false IF it matches, unlike any other function.
Reply
#3

I think ur wrong
why ui ? it supouse to be us because s = string in sscanf .
but I did what you told me to do so now when I do /ban 0 test
it returns me sendclient(blabla,balbal,"usage ban playerid")
if I make the reason an integet like /ban 0 13 it works ok.
I made it if(!sscanf(params,"us",id,reason)) and now its working
Reply
#4

pawn Код:
new reason[66];
pawn Код:
if(!sscanf(params,"us[65]",id,reason))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)