Ayuda con mensaje de kick
#1

Bueno, veran es que me ha gustado el mensaje de ban y kick de un gamemode y he decidido sacarlo e incorporarlo al mio, sucede que el /ban funciona bien, pero el kick no, solo pone "Server closed conection." sin la informaciуn que quiero, no se porque no funciona (el kick).

Aqui el ban (que si funciona)
pawn Код:
stock BanPlayer( DB:Database, PlayerID, AdminID, Reason[ ] )
{
    if ( Database )
    {
        new Query   [ 512 ],
            DBResult:Result,
            Name    [ MAX_PLAYER_NAME ],
            Banner  [ MAX_PLAYER_NAME ],
            pIP     [ 16 ],
            t1, t2, t3;
           
        if ( AdminID == 1000 )
            Banner = "Admin";

        else if ( AdminID == INVALID_PLAYER_ID )
            Banner = "Desconocido";

        else
            GetPlayerName( AdminID, Banner, MAX_PLAYER_NAME );
       
        gettime( t1, t2, t3 );
        GetPlayerName( PlayerID, Name, MAX_PLAYER_NAME );
        GetPlayerIp( PlayerID, pIP, 16 );
       
        format( Query, sizeof( Query ), "INSERT INTO lva_bans(name,reporter,reason,ip,time,type) values(\
            lower('%s'), '%s', '%s', '%s', strftime('%%s','now'),2\
        );\
        "
, Name, Banner, Reason, pIP );
       
        Result = db_query( Database, Query );
        db_free_result( Result );
       
        format( Query, sizeof( Query ), ">> %s (ID: %d) has banned %s (ID: %d) for: %s", Banner, AdminID, Name, PlayerID, Reason );
        SendClientMessageToAll( COLOR_ORANGE, Query );
       
        SendClientMessage( PlayerID, COLOR_YELLOW, ЎHAS SIDO BANEADO!");
       
        format( Query, sizeof( Query ), "
>> Admin : %s", Banner );
        SendClientMessage( PlayerID, COLOR_ORANGE, Query );
       
        format( Query, sizeof( Query ), "
>> Motivo: %s", Reason );
        SendClientMessage( PlayerID, COLOR_ORANGE, Query );

        SendClientMessage( PlayerID, COLOR_YELLOW, "
Comunica tu ban a un administrador si quieres recuperar tu cuenta" );
       
        if ( IsUserRegistered( Database, Name ) )
        {
            format( Query, sizeof( Query ), "
UPDATE `lva_users` SET `banned`=1 WHERE `name`=lower('%s')", Name );
           
            Result = db_query( Database, Query );
            db_free_result( Result );
           
            Kick( PlayerID );
           
            printf( "
[acc-ban] %s (IP: %s) baneado por %s por %s.", Name, pIP, Banner, Reason );
        }
        else
        {
            Ban         ( PlayerID );
            Kick        ( PlayerID );
            printf      ( "
[ip-ban] %s (IP: %s) was banned by %s for the reason %s.", Name, pIP, Banner, Reason );
        }
       
        format  ( Query, sizeof( Query ), "
[banreason] %s %s %s [IP:%s]", Banner, Name, Reason, pIP );
        add_log ( Query );
       
        return 1;
    }
    else
    {
        print( "
[ERROR] NO DATABASE!" );
        return 0;
    }
}
Aqui el kick (no funciona)
pawn Код:
stock KickPlayer( DB:Database, PlayerID, AdminID, Reason[ ] )
{
    if ( Database )
    {
        new Query   [ 512 ],
            DBResult:Result,
            Name    [ MAX_PLAYER_NAME ],
            Kicker  [ MAX_PLAYER_NAME ],
            pIP     [ 16 ],
            t1, t2, t3;

        if ( AdminID == 1000 )
            Kicker = "Admin";

        else if ( AdminID == INVALID_PLAYER_ID )
            Kicker = "Desconocido";

        else
            GetPlayerName( AdminID, Kicker, MAX_PLAYER_NAME );

        gettime( t1, t2, t3 );
        GetPlayerName( PlayerID, Name, MAX_PLAYER_NAME );
        GetPlayerIp( PlayerID, pIP, 16 );

        format( Query, sizeof( Query ), "INSERT INTO lva_bans(name,reporter,reason,ip,time,type) values(\
            '%s', '%s', '%s', '%s', strftime('%%s','now'),1\
        );\
        "
, Name, Kicker, Reason, pIP );
       
        Result = db_query( Database, Query );
        db_free_result( Result );
       
        format( Query, sizeof( Query ), ">> %s (ID: %d) expulsa a %s (ID: %d) por: %s", Kicker, AdminID, Name, PlayerID, Reason );
        SendClientMessageToAll( COLOR_ORANGE, Query );

        SendClientMessage( PlayerID, COLOR_YELLOW, "ЎHAS SIDO EXPULSADO!");

        format( Query, sizeof( Query ), ">> Admin : %s", Kicker );
        SendClientMessage( PlayerID, COLOR_ORANGE, Query );

        format( Query, sizeof( Query ), ">> Motivo: %s", Reason );
        SendClientMessage( PlayerID, COLOR_ORANGE, Query );

        SendClientMessage( PlayerID, COLOR_YELLOW, "Procura que no vuelva a suceder!" );

        Kick( PlayerID );
        printf( "[kick] %s (IP: %s) expulsado por %s por %s.", Name, pIP, Kicker, Reason );
       
        format( Query, sizeof( Query ), "[kickreason] %s %s %s [IP:%s]", Kicker, Name, Reason, pIP );
        add_log( Query );

        return 1;
    }
    else
    {
        print( "[ERROR] NO DATABASE!" );

        return 0;
    }
}
He intentado de varias maneras cambiando unas cosillas pero sigue igual, no funciona el kick y el ban si.
їAlguien me puede decir en que falla?

Saludos!
Reply
#2

Necesitas mandar el kick mediante un Timer ejemplo:
Код:
forward KickJugador(playerid);
public KickJugador(playerid)
{
Kick(playerid);
return 1;
}

public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, -1, "Expulsado!!");
SetTimerEx("KickJugador", 600, false, "i", playerid);
return 1;
}
En tu caso serнa algo como esto:
Код:
forward KickJugador(playerid);
public KickJugador(playerid)
{
	Kick(playerid);
	return 1;
}

stock KickPlayer( DB:Database, PlayerID, AdminID, Reason[ ] )
{
    if ( Database )
    {
        new Query   [ 512 ],
            DBResult:Result,
            Name    [ MAX_PLAYER_NAME ],
            Kicker  [ MAX_PLAYER_NAME ],
            pIP     [ 16 ],
            t1, t2, t3;

        if ( AdminID == 1000 )
            Kicker = "Admin";

        else if ( AdminID == INVALID_PLAYER_ID )
            Kicker = "Desconocido";

        else
            GetPlayerName( AdminID, Kicker, MAX_PLAYER_NAME );

        gettime( t1, t2, t3 );
        GetPlayerName( PlayerID, Name, MAX_PLAYER_NAME );
        GetPlayerIp( PlayerID, pIP, 16 );

        format( Query, sizeof( Query ), "INSERT INTO lva_bans(name,reporter,reason,ip,time,type) values(\
            '%s', '%s', '%s', '%s', strftime('%%s','now'),1\
        );\
        ", Name, Kicker, Reason, pIP );

        Result = db_query( Database, Query );
        db_free_result( Result );

        format( Query, sizeof( Query ), ">> %s (ID: %d) expulsa a %s (ID: %d) por: %s", Kicker, AdminID, Name, PlayerID, Reason );
        SendClientMessageToAll( COLOR_ORANGE, Query );

        SendClientMessage( PlayerID, COLOR_YELLOW, "ЎHAS SIDO EXPULSADO!");

        format( Query, sizeof( Query ), ">> Admin : %s", Kicker );
        SendClientMessage( PlayerID, COLOR_ORANGE, Query );

        format( Query, sizeof( Query ), ">> Motivo: %s", Reason );
        SendClientMessage( PlayerID, COLOR_ORANGE, Query );

        SendClientMessage( PlayerID, COLOR_YELLOW, "Procura que no vuelva a suceder!" );

        SetTimerEx("KickJugador", 1000, false, "i", PlayerID);
        
        printf( "[kick] %s (IP: %s) expulsado por %s por %s.", Name, pIP, Kicker, Reason );

        format( Query, sizeof( Query ), "[kickreason] %s %s %s [IP:%s]", Kicker, Name, Reason, pIP );
        add_log( Query );

        return 1;
    }
    else
    {
        print( "[ERROR] NO DATABASE!" );

        return 0;
    }
}
Reply
#3

Aun sigue sin dar el mensaje
Reply
#4

Revivo^^ por favor necesito ayuda
Reply
#5

pawn Код:
stock KickPlayer( DB:Database, PlayerID, AdminID, Reason[ ] )
{
    if ( Database )
    {
        new Query   [ 512 ],
            DBResult:Result,
            Name    [ MAX_PLAYER_NAME ],
            Kicker  [ MAX_PLAYER_NAME ],
            pIP     [ 16 ],
            t1, t2, t3;

        if ( AdminID == 1000 )
            Kicker = "Admin";

        else if ( AdminID == INVALID_PLAYER_ID )
            Kicker = "Desconocido";

        else
            GetPlayerName( AdminID, Kicker, MAX_PLAYER_NAME );

        gettime( t1, t2, t3 );
        GetPlayerName( PlayerID, Name, MAX_PLAYER_NAME );
        GetPlayerIp( PlayerID, pIP, 16 );

        format( Query, sizeof( Query ), "INSERT INTO lva_bans(name,reporter,reason,ip,time,type) values(\
            '%s', '%s', '%s', '%s', strftime('%%s','now'),1\
        );\
        "
, Name, Kicker, Reason, pIP );

        Result = db_query( Database, Query );
        db_free_result( Result );

        format( Query, sizeof( Query ), ">> %s (ID: %d) expulsa a %s (ID: %d) por: %s", Kicker, AdminID, Name, PlayerID, Reason );
        SendClientMessageToAll( COLOR_ORANGE, Query );

        SendClientMessage( PlayerID, COLOR_YELLOW, "ЎHAS SIDO EXPULSADO!");

        format( Query, sizeof( Query ), ">> Admin : %s", Kicker );
        SendClientMessage( PlayerID, COLOR_ORANGE, Query );

        format( Query, sizeof( Query ), ">> Motivo: %s", Reason );
        SendClientMessage( PlayerID, COLOR_ORANGE, Query );

        SendClientMessage( PlayerID, COLOR_YELLOW, "Procura que no vuelva a suceder!" );

        SetTimerEx("expulsar",500,false,"d",PlayerID);
       
        printf( "[kick] %s (IP: %s) expulsado por %s por %s.", Name, pIP, Kicker, Reason );

        format( Query, sizeof( Query ), "[kickreason] %s %s %s [IP:%s]", Kicker, Name, Reason, pIP );
        add_log( Query );

        return 1;
    }
    else
    {
        print( "[ERROR] NO DATABASE!" );

        return 0;
    }
}

forward expulsar(playerid);
public expulsar(playerid)
{
    Kick(playerid);
    return true;
}
Reply
#6

no te funciona por que....

https://sampwiki.blast.hk/wiki/Kick_ES
Quote:
Originally Posted by Nota Importante
A partir de SA-MP 0.3x, cualquier acciуn no funcionarб; se deberб de usar un timer para retrasar la funciуn Kick(). Por ejemplo, el envнo de un mensaje con SendClientMessage antes de Kick() no funcionarб.
solucion:

pawn Код:
stock Fix_Kick(playerid) SetTimerEx("kick_fix",1000,false,"d",playerid);
forward kick_fix(playerid); public kick_fix(playerid) Kick(playerid);
#define Fix_Kick Kick
saludos.
Reply
#7

ЎMuchas gracias, ya funciona!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)