Remake code
#1

Can someone remake this code to 0.3x version? To show reason of ban and kick.

Код:
CMD:kick( playerid, params[ ] )
{
    new
        id,
        reason[ 64 ]
    ;
    if( PlayerInfo[ playerid ][ pAdmin ] < 1 ) return SendClientMessage( playerid, 0xFF0000AA, "Tu ne administratorius!" );
    if(sscanf( params, "us[64]", id, reason ) ) return SendClientMessage( playerid, 0xDEEE20FF, "Naudojimas: /kick [Nick] [Prieћastis]" );
    if( !IsPlayerConnected( id ) || id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, 0xDEEE20FF, "Tokio ћaidėjo nėra" );
    new
        str[ 128 ],
        pName[ MAX_PLAYER_NAME ],
        aName[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, aName, MAX_PLAYER_NAME );
    GetPlayerName( id, pName, MAX_PLAYER_NAME );
    format( str, sizeof( str ), "Administratorius %s iљmetė ћaidėją %s. Prieћastis: %s ", aName, pName, reason );
    SendClientMessageToAll( 0xDEEE20FF, str );
    Kick( id );
    return 1;
}

CMD:ban( playerid, params[ ] )
{
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage( playerid, -1, "Tu ne administratorius!" );
    new
        id,
        reason[ 64 ]
    ;
    if(sscanf( params, "us[64]", id, reason ) ) return SendClientMessage( playerid, -1, "Naudojimas: /ban [Nickas] [Prieћastis]" );
    if( !IsPlayerConnected( id ) || id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Tokio ћaidėjo nėra." );
    if(PlayerInfo[id][pPadmin] == 1) return SendClientMessage(playerid, -1, "Ką čia darai?");
    new
        str[ 128 ],
        pName[ MAX_PLAYER_NAME ],
        aName[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, aName, MAX_PLAYER_NAME );
    GetPlayerName( id, pName, MAX_PLAYER_NAME );
    format( str, sizeof( str ), "%s Uћblokavo ћaidėją %s. (Prieћastis: %s)", aName, pName, reason );
    SendClientMessageToAll( -1, str );
    BanEx( id,str);
    return 1;
}
Reply
#2

Any ideas?
Reply
#3

It's supposed to be the same code.. The only thing you need to change from version to version is the new server package, from there just copy all your files to the same place.
Reply
#4

I might be wrong but I think in 0.3x you don't see the message anymore. So I guess to solve this just create a timer which calls Kick for the player. I guess this should fix this.
Reply
#5

I don't know how it looks like (timer which kall Kick) can somebody show?
Reply
#6

Here ya go:


pawn Код:
//In order to display a message (eg. reason) for the player before the connection is closed you have to use a delay:
 
forward KickPublic(playerid);
public KickPublic(playerid) { Kick(playerid); }
 
stock KickWithMessage(playerid, message[])
{
    SendClientMessage(playerid, 0xFF4444FF, message);
    SetTimerEx("KickPublic", 1000, 0, "d", playerid);   //Delay of 1 second before kicking the player so he recieves the message
}
 
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/kickme", true) == 0)
    {
        //Kicks the player who the executed this command
        KickWithMessage(playerid, "You have been kicked.");
        return 1;
    }
    return 0;
}
//by Kye
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)