What's wrong with Kick ? -
SiJ - 25.01.2010
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);
Re: What's wrong with Kick ? -
SiJ - 25.01.2010
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.....
Re: What's wrong with Kick ? -
-Rebel Son- - 25.01.2010
I think you can do Kick(); instead of Using playerid variable. try that.
Re: What's wrong with Kick ? -
KnooL - 25.01.2010
You have stated,
"You have been kicked" in your main post but I can't seem to find it in your script.
Re: What's wrong with Kick ? -
SiJ - 26.01.2010
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
Re: What's wrong with Kick ? -
Calgon - 26.01.2010
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 ) );
}
}
Re: What's wrong with Kick ? -
SiJ - 26.01.2010
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..
Re: What's wrong with Kick ? -
Calgon - 26.01.2010
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 );
Re: What's wrong with Kick ? -
SiJ - 26.01.2010
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..
Re: What's wrong with Kick ? -
Calgon - 27.01.2010
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.