[Question] Ban
#1

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?
Reply
#2

" 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]");
Reply
#3

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)
Reply
#4

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;
}
Reply
#5

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.
Reply
#6

Did it kick you or the player?
Reply
#7

Me :/
Admin Javad has kicked Javad [Reason:a]
Reply
#8

But who were you targeting?
Reply
#9

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

Facepalm, I just realised...

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


Forum Jump:


Users browsing this thread: 11 Guest(s)