10.12.2012, 10:36
@nicholas1
- You're using playerid as a result you'll kick/ban the person who typed the command. You will need strtok for the id. However, strcmp and strtok are too damn slow and outdated. I'd recomment you to use ZCMD + sscanf as it's an amazing combination and it's really fast/easy.
That's also wrong.
Sscanf specifiers: "is". It's "r" or "u" for ID/Part Of Name and "s[size]". Otherwise, it will give you error by sscanf in the server window. The messages are wrong and you kick player in both. And Player name's limit is 24, not 60..
- You're using playerid as a result you'll kick/ban the person who typed the command. You will need strtok for the id. However, strcmp and strtok are too damn slow and outdated. I'd recomment you to use ZCMD + sscanf as it's an amazing combination and it's really fast/easy.
pawn Код:
CMD:kick( playerid, params[ ] )
{
if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not an Admin!" );
new
id,
reason[ 64 ]
;
if( sscanf( params, "rs[64]", id, reason ) ) return SendClientMessage( playerid, -1, "Usage: /kick <ID/Part Of Name>" );
if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not connected!" );
new
name[ MAX_PLAYER_NAME ],
string[ 128 ]
;
GetPlayerName( id, name, MAX_PLAYER_NAME );
format( string, sizeof( string ), "%s has been kicked by Administrator! (Reason: %s)", name, reason );
SendClientMessageToAll( -1, string );
Kick( id );
return 1;
}
CMD:ban( playerid, params[ ] )
{
if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not an Admin!" );
new
id,
reason[ 64 ]
;
if( sscanf( params, "rs[64]", id, reason ) ) return SendClientMessage( playerid, -1, "Usage: /ban <ID/Part Of Name>" );
if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not connected!" );
new
name[ MAX_PLAYER_NAME ],
string[ 128 ]
;
GetPlayerName( id, name, MAX_PLAYER_NAME );
format( string, sizeof( string ), "%s has been banned by Administrator! (Reason: %s)", name, reason );
SendClientMessageToAll( -1, string );
Ban( id );
return 1;
}
Quote:
1- thats wrong, the player won't get the unban when time finish
2- he didn't ask for the time Code: Kick: pawn Код:
pawn Код:
|
Sscanf specifiers: "is". It's "r" or "u" for ID/Part Of Name and "s[size]". Otherwise, it will give you error by sscanf in the server window. The messages are wrong and you kick player in both. And Player name's limit is 24, not 60..