SA-MP Forums Archive
[Question] Ban - 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: [Question] Ban (/showthread.php?tid=585864)



[Question] Ban - javad - 17.08.2015

Hi,
I've made an script that ban players. It works fine but when i type 1 letter in reason, it will ban me.
Example: /ban 5 a
PHP код:
CMD:ban(playeridparams[])
{
    new
        
targetid,
        
Reason,
        
AdminName[MAX_PLAYERS],
        
TargetName[MAX_PLAYER_NAME],
        
banmsg[128];
    if(
PlayerInfo[pAdmin][playerid]>2)
    {
         if(
sscanf(params"is[50]"targetidReason)) return SendClientMessage(playerid0xE90A0AFF"[CMD] /ban [playerid] [reason]");
        if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid0xE90A0AFF"[ERROR] Invalid player ID.");
        
GetPlayerName(playeridAdminNamesizeof(AdminName));
        
GetPlayerName(targetidTargetNamesizeof(TargetName));
        
format(banmsgsizeof(banmsg), "[ADMIN] Admin %s has banned %s [Reason: %s]"AdminNameTargetNameReason);
        
SendClientMessageToAll(0xE90A0AFFbanmsg);
        
TextDrawShowForPlayer(targetidTextdraw0);
        
TextDrawShowForPlayer(targetidTextdraw1);
        
TextDrawShowForPlayer(targetidTextdraw2);
        
PlayerInfo[Banned][targetid] = 1;
        
Kick(targetid);
    }
    else
    {
        
SendClientMessage(playerid0xE90A0AFF"[ERROR] You are not authorized.");
    }
    return 
1;

I have the same problem with /kick
What's wrong?


Re: [Question] Ban - ZToPMaN - 17.08.2015

" i " = intger
" u " = id
you wrote the sscanf wrong.
the right way
if(sscanf(params, "us[50]", targetid, Reason)) return SendClientMessage(playerid, 0xE90A0AFF, "[CMD] /ban [playerid] [reason]");


Re: [Question] Ban - javad - 17.08.2015

PHP код:
CMD:ban(playeridparams[])
{
    new
        
targetid,
        
Reason,
        
AdminName[MAX_PLAYERS],
        
TargetName[MAX_PLAYER_NAME],
        
banmsg[128];
    if(
PlayerInfo[pAdmin][playerid]>2)
    {
         if(
sscanf(params"us[50]"targetidReason)) return SendClientMessage(playerid0xE90A0AFF"[CMD] /ban [playerid] [reason]");
        if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid0xE90A0AFF"[ERROR] Invalid player ID.");
        
GetPlayerName(playeridAdminNamesizeof(AdminName));
        
GetPlayerName(targetidTargetNamesizeof(TargetName));
        
format(banmsgsizeof(banmsg), "[ADMIN] Admin %s has banned %s [Reason: %s]"AdminNameTargetNameReason);
        
SendClientMessageToAll(0xE90A0AFFbanmsg);
        
TextDrawShowForPlayer(targetidTextdraw0);
        
TextDrawShowForPlayer(targetidTextdraw1);
        
TextDrawShowForPlayer(targetidTextdraw2);
        
PlayerInfo[Banned][targetid] = 1;
        
Kick(targetid);
    }
    else
    {
        
SendClientMessage(playerid0xE90A0AFF"[ERROR] You are not authorized.");
    }
    return 
1;

Still kick/ban me when i type "/kick [id] a" (every ID)


Re: [Question] Ban - Dokins - 17.08.2015

I remember people posting about this. The best thing to do with that is to put it into a timer for something like 100 ms. Here, use mine.

Reason:

Quote:

As of SA-MP 0.3x, any action taken directly before Kick() (such as sending a message with SendClientMessage) will not reach the player. A timer must be used to delay the kick.

pawn Код:
SetTimerEx("KickPlayer",500,false,"i",giveplayerid);// Kicks player in 500ms

forward KickPlayer(playerid);
public KickPlayer(playerid)
{
    Kick(playerid);
    return 1;
}



Re: [Question] Ban - javad - 17.08.2015

I did it, it only made one change:
The player that is kicking, can see the message announced:
Admin %s has kicked %s [Reason:%s]
My problem didn't solve.


Re: [Question] Ban - Dokins - 17.08.2015

Did it kick you or the player?


Re: [Question] Ban - javad - 17.08.2015

Me :/
Admin Javad has kicked Javad [Reason:a]


Re: [Question] Ban - Dokins - 17.08.2015

But who were you targeting?


Re: [Question] Ban - javad - 17.08.2015

No one
The player is not connected.
/kick 5 asdasdasd ========> [ERROR] Invalid ID.
/kick 5 g ===============> it kicks me


Re: [Question] Ban - Dokins - 17.08.2015

Facepalm, I just realised...

pawn Код:
Reason
Must be
pawn Код:
Reason[50];