What's wrong with Kick ?
#1

Hey,
I got this function which suddenly stopped working:
pawn Код:
//OnPlayerConnect
if(CheckPlayerName(plName)==0)
  {
        ErrorMsg(playerid,"Didn't you noticed that this is a ROLEPLAY server??");
        KickPlayer(playerid,"Non-RP name!","Your name must be in FirstName_LastName format!");

  }

stock KickPlayer(playerid,reason1[128],reason2[256],kickerid=-255)
{
      if(IsPlayerConnected(playerid))
        {
            SendClientMessage(playerid,COLOR_ERROR,"____________________________________________________________");
            if(kickerid != -255)
            {
        SendFMessageToAll(COLOR_ERROR,"%s has been kicked by %s",pName[playerid],pName[kickerid]);
            }
            else
            {
                SendFMessageToAll(COLOR_ERROR,"%s has been kicked!",pName[playerid]);
            }
            new str[512];
            format(str,512,"Reason: %s",reason1);
            SendClientMessageToAllEx(playerid,COLOR_ERROR,str);
            SendFMessage(playerid,COLOR_ERROR,"Reason: %s",reason2);
            SendClientMessage(playerid,COLOR_ERROR,"____________________________________________________________");
            Kick(playerid); // THIS SHOULD KICK THE PLAYER
      }
}
Player get's all messages ("You have been kicked...") but it doesn't get's kicked... I have to kick them manually using /kick command (it works perfectly), which uses the same Kick(id);
Reply
#2

Nobody replied.. Personally, I cannot see any errors in the code I've posted, but it just stopped working and it won't kick the players.. :\
As I said /kick uses the same Kick(playerid); which works in there.....
Reply
#3

I think you can do Kick(); instead of Using playerid variable. try that.
Reply
#4

You have stated,

"You have been kicked" in your main post but I can't seem to find it in your script.
Reply
#5

Quote:
Originally Posted by KnooL
You have stated,

"You have been kicked" in your main post but I can't seem to find it in your script.
Oops.. I was talking about this message: SendFMessageToAll(COLOR_ERROR,"%s has been kicked by %s",pName[playerid],pName[kickerid]);
It shows up, but player doesn't get kicked...

Quote:
Originally Posted by [N
Dakota ]
I think you can do Kick(); instead of Using playerid variable. try that.
How can you use Kick without playerid parameter? :O
Reply
#6

pawn Код:
stock KickPlayer( playerid, Reason[], playerwhokicked )
{
    if( IsPlayerConnected( playerid ) )
    {
        new string[ 128 ], Name[ MAX_PLAYER_NAME ];

        GetPlayerName( playerid, Name, sizeof( Name ) );

        if( playerwhokicked == -255 )
        {
          format( string, sizeof( string ), "AdmCmd: %s has been kicked, reason: %s", Name, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          Kick( playerid );
          print( string );
        }
        else
        {
          new KickerName[ MAX_PLAYER_NAME ];
          GetPlayerName( playerwhokicked, KickerName, sizeof( KickerName ) );
          format( string, sizeof( string ), "AdmCmd: %s has been kicked by %s, reason: %s", Name, KickerName, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          Kick( playerid );
          print( string );
        }
    }
    else
    {
      printf( "KickPlayer() was called, but the playerid (%d) inserted into the function wasn't a valid ID.", playerid ) );
    }
}
Reply
#7

Quote:
Originally Posted by CalgonX
pawn Код:
stock KickPlayer( playerid, Reason[], playerwhokicked )
{
    if( IsPlayerConnected( playerid ) )
    {
        new string[ 128 ], Name[ MAX_PLAYER_NAME ];

        GetPlayerName( playerid, Name, sizeof( Name ) );

        if( playerwhokicked == -255 )
        {
          format( string, sizeof( string ), "AdmCmd: %s has been kicked, reason: %s", Name, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          Kick( playerid );
          print( string );
        }
        else
        {
          new KickerName[ MAX_PLAYER_NAME ];
          GetPlayerName( playerwhokicked, KickerName, sizeof( KickerName ) );
          format( string, sizeof( string ), "AdmCmd: %s has been kicked by %s, reason: %s", Name, KickerName, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          Kick( playerid );
          print( string );
        }
    }
    else
    {
      printf( "KickPlayer() was called, but the playerid (%d) inserted into the function wasn't a valid ID.", playerid ) );
    }
}
I need two reasons in that function.. One will be shown only for player, another will be shown for everyone..
And SendFMessage is SendPlayerFormattedMessage from useful functions, it works..
Reply
#8

pawn Код:
stock KickPlayer( playerid, Reason[], Reason2[], playerwhokicked )
{
    if( IsPlayerConnected( playerid ) )
    {
        new string[ 128 ], Name[ MAX_PLAYER_NAME ];

        GetPlayerName( playerid, Name, sizeof( Name ) );

        if( playerwhokicked == -255 )
        {
          format( string, sizeof( string ), "AdmCmd: %s has been kicked, reason: %s", Name, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          format( string, sizeof( string ), "You have been kicked for %s.", Reason2 );
          Kick( playerid );
          print( string );
        }
        else
        {
          new KickerName[ MAX_PLAYER_NAME ];
          GetPlayerName( playerwhokicked, KickerName, sizeof( KickerName ) );
          format( string, sizeof( string ), "AdmCmd: %s has been kicked by %s, reason: %s", Name, KickerName, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          format( string, sizeof( string ), "You have been kicked for %s.", Reason2 );
          Kick( playerid );
          print( string );
        }
    }
    else
    {
      printf( "KickPlayer() was called, but the playerid (%d) inserted into the function wasn't a valid ID.", playerid ) );
    }
}

//KickPlayer( playerid, "DMing", "Deathmatching", -255 );
Reply
#9

Quote:
Originally Posted by CalgonX
pawn Код:
stock KickPlayer( playerid, Reason[], Reason2[], playerwhokicked )
{
    if( IsPlayerConnected( playerid ) )
    {
        new string[ 128 ], Name[ MAX_PLAYER_NAME ];

        GetPlayerName( playerid, Name, sizeof( Name ) );

        if( playerwhokicked == -255 )
        {
          format( string, sizeof( string ), "AdmCmd: %s has been kicked, reason: %s", Name, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          format( string, sizeof( string ), "You have been kicked for %s.", Reason2 );
          Kick( playerid );
          print( string );
        }
        else
        {
          new KickerName[ MAX_PLAYER_NAME ];
          GetPlayerName( playerwhokicked, KickerName, sizeof( KickerName ) );
          format( string, sizeof( string ), "AdmCmd: %s has been kicked by %s, reason: %s", Name, KickerName, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          format( string, sizeof( string ), "You have been kicked for %s.", Reason2 );
          Kick( playerid );
          print( string );
        }
    }
    else
    {
      printf( "KickPlayer() was called, but the playerid (%d) inserted into the function wasn't a valid ID.", playerid ) );
    }
}

//KickPlayer( playerid, "DMing", "Deathmatching", -255 );
So what was wrong with my code.. :\
You just did the same thing as in my code, but in other way..
Reply
#10

Quote:
Originally Posted by SiJ
Quote:
Originally Posted by CalgonX
pawn Код:
stock KickPlayer( playerid, Reason[], Reason2[], playerwhokicked )
{
    if( IsPlayerConnected( playerid ) )
    {
        new string[ 128 ], Name[ MAX_PLAYER_NAME ];

        GetPlayerName( playerid, Name, sizeof( Name ) );

        if( playerwhokicked == -255 )
        {
          format( string, sizeof( string ), "AdmCmd: %s has been kicked, reason: %s", Name, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          format( string, sizeof( string ), "You have been kicked for %s.", Reason2 );
          Kick( playerid );
          print( string );
        }
        else
        {
          new KickerName[ MAX_PLAYER_NAME ];
          GetPlayerName( playerwhokicked, KickerName, sizeof( KickerName ) );
          format( string, sizeof( string ), "AdmCmd: %s has been kicked by %s, reason: %s", Name, KickerName, Reason );
          SendClientMessageToAll( COLOR_RED, string );
          format( string, sizeof( string ), "You have been kicked for %s.", Reason2 );
          Kick( playerid );
          print( string );
        }
    }
    else
    {
      printf( "KickPlayer() was called, but the playerid (%d) inserted into the function wasn't a valid ID.", playerid ) );
    }
}

//KickPlayer( playerid, "DMing", "Deathmatching", -255 );
So what was wrong with my code.. :\
You just did the same thing as in my code, but in other way..
Yours is poorly constructed and has a billion useless cells.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)