Problem when I'm kicking player -
Lirbo - 20.04.2014
pawn Код:
COMMAND:kick(playerid,params[]){
if(!Logged{playerid}) return 0;
if(DOF2_GetInt(RFile(playerid),"Admin") <1){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You not allowed to use this command!"); return 1;}
else{
if(!sscanf(params,"us",p1,Reason)){
if(!IsPlayerConnected(p1)){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Invalid ID"); return 1;}
GetPlayerName(playerid, AName,sizeof(AName));
GetPlayerName(p1, Name,sizeof(Name));
format(String,sizeof(String),"[ADMIN] {FF6969}%s has been KICKED %s: %s",AName,Name,Reason);
SendClientMessageToAll(COLOR_DENIED,String);
Kick(p1);}else{
SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Usage: /Kick <ID> <REASON>");}}return 1;}
It's not shows the message to the kicked player. but it's shows to everyone else
Re: Problem when I'm kicking player -
PrivatioBoni - 20.04.2014
You need to put the kick function into a timer of let's say, 500ms - 1 second.
pawn Код:
forward KickTimer(playerid);
public KickTimer(playerid)
{
Kick(playerid);
}
SetTimerEx("KickTimer", 1000, 0, "d", p1);
Re: Problem when I'm kicking player -
biker122 - 20.04.2014
Yes, It won't show it to the kicked player, because you're not setting a timer to kick. Use this
pawn Код:
forward KickPlayer();
public KickPlayer()
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
Kick(i);
}
}
return 1;
}
Put this anywhere in your script ^
The command:
pawn Код:
COMMAND:kick(playerid,params[]){
if(!Logged{playerid}) return 0;
if(DOF2_GetInt(RFile(playerid),"Admin") <1){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You not allowed to use this command!"); return 1;}
else{
if(!sscanf(params,"us",p1,Reason)){
if(!IsPlayerConnected(p1)){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Invalid ID"); return 1;}
GetPlayerName(playerid, AName,sizeof(AName));
GetPlayerName(p1, Name,sizeof(Name));
format(String,sizeof(String),"[ADMIN] {FF6969}%s has been KICKED %s: %s",AName,Name,Reason);
SendClientMessageToAll(COLOR_DENIED,String);
("KickPlayer",700,false,"i",p1);;}else{
SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Usage: /Kick <ID> <REASON>");}}return 1;}
Re: Problem when I'm kicking player -
QuaTTrO - 20.04.2014
Quote:
Originally Posted by biker122
Yes, It won't show it to the kicked player, because you're not setting a timer to kick. Use this
pawn Код:
forward KickPlayer(); public KickPlayer() { for(new i=0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { Kick(i); } } return 1; }
Put this anywhere in your script ^
The command:
pawn Код:
COMMAND:kick(playerid,params[]){ if(!Logged{playerid}) return 0; if(DOF2_GetInt(RFile(playerid),"Admin") <1){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You not allowed to use this command!"); return 1;} else{ if(!sscanf(params,"us",p1,Reason)){ if(!IsPlayerConnected(p1)){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Invalid ID"); return 1;} GetPlayerName(playerid, AName,sizeof(AName)); GetPlayerName(p1, Name,sizeof(Name)); format(String,sizeof(String),"[ADMIN] {FF6969}%s has been KICKED %s: %s",AName,Name,Reason); SendClientMessageToAll(COLOR_DENIED,String); ("KickPlayer",700,false,"i",p1);;}else{ SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Usage: /Kick <ID> <REASON>");}}return 1;}
|
Why do you want to kick all players?
Re: Problem when I'm kicking player -
Lirbo - 20.04.2014
Quote:
Originally Posted by biker122
Yes, It won't show it to the kicked player, because you're not setting a timer to kick. Use this
pawn Код:
forward KickPlayer(); public KickPlayer() { for(new i=0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { Kick(i); } } return 1; }
Put this anywhere in your script ^
The command:
pawn Код:
COMMAND:kick(playerid,params[]){ if(!Logged{playerid}) return 0; if(DOF2_GetInt(RFile(playerid),"Admin") <1){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You not allowed to use this command!"); return 1;} else{ if(!sscanf(params,"us",p1,Reason)){ if(!IsPlayerConnected(p1)){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Invalid ID"); return 1;} GetPlayerName(playerid, AName,sizeof(AName)); GetPlayerName(p1, Name,sizeof(Name)); format(String,sizeof(String),"[ADMIN] {FF6969}%s has been KICKED %s: %s",AName,Name,Reason); SendClientMessageToAll(COLOR_DENIED,String); ("KickPlayer",700,false,"i",p1);;}else{ SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Usage: /Kick <ID> <REASON>");}}return 1;}
|
warning 215: expression has no effect
In the starting timer line (in the command)
Re: Problem when I'm kicking player -
PrivatioBoni - 20.04.2014
Use mine then.
Re: Problem when I'm kicking player -
Lirbo - 20.04.2014
Quote:
Originally Posted by PrivatioBoni
Use mine then.
|
Works
![Cheesy](images/smilies/biggrin.png)
thanks a lot
Re: Problem when I'm kicking player -
biker122 - 20.04.2014
Made a small mistake, It won't seriously kick everyone.
SetTimerEx("EndAntiSpawnKill", 5000, false, "i", playerid);
// EndAntiSpawnKill - The function that will be called
// 5000 - 5000 MS (5 seconds). This is the interval. The timer will be called after 5 seconds.
// false - Not repeating. Will only be called once.
// "i" - I stands for integer (whole number). We are passing an integer (a player ID) to the function.
// playerid - The value to pass. This is the integer specified in the previous parameter.
pawn Код:
forward KickPlayer();
public KickPlayer()
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
Kick(i);
}
}
return 1;
}
Put this anywhere in your script ^
The command:
pawn Код:
COMMAND:kick(playerid,params[]){
if(!Logged{playerid}) return 0;
if(DOF2_GetInt(RFile(playerid),"Admin") <1){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You not allowed to use this command!"); return 1;}
else{
if(!sscanf(params,"us",p1,Reason)){
if(!IsPlayerConnected(p1)){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Invalid ID"); return 1;}
GetPlayerName(playerid, AName,sizeof(AName));
GetPlayerName(p1, Name,sizeof(Name));
format(String,sizeof(String),"[ADMIN] {FF6969}%s has been KICKED %s: %s",AName,Name,Reason);
SendClientMessageToAll(COLOR_DENIED,String);
SetTimerEx("KickPlayer",700,false,"i",p1);;}else{
SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Usage: /Kick <ID> <REASON>");}}return 1;}
Re: Problem when I'm kicking player -
arakuta - 20.04.2014
@biker122
You made a fucked up big mistake, and your code still will kick everyone.
And indentation exists.
Re: Problem when I'm kicking player -
Eshaan - 20.04.2014
Quote:
Originally Posted by biker122
Made a small mistake, It won't seriously kick everyone.
SetTimerEx("EndAntiSpawnKill", 5000, false, "i", playerid);
// EndAntiSpawnKill - The function that will be called
// 5000 - 5000 MS (5 seconds). This is the interval. The timer will be called after 5 seconds.
// false - Not repeating. Will only be called once.
// "i" - I stands for integer (whole number). We are passing an integer (a player ID) to the function.
// playerid - The value to pass. This is the integer specified in the previous parameter.
pawn Код:
forward KickPlayer(); public KickPlayer() { for(new i=0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { Kick(i); } } return 1; }
Put this anywhere in your script ^
The command:
pawn Код:
COMMAND:kick(playerid,params[]){ if(!Logged{playerid}) return 0; if(DOF2_GetInt(RFile(playerid),"Admin") <1){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}You not allowed to use this command!"); return 1;} else{ if(!sscanf(params,"us",p1,Reason)){ if(!IsPlayerConnected(p1)){SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Invalid ID"); return 1;} GetPlayerName(playerid, AName,sizeof(AName)); GetPlayerName(p1, Name,sizeof(Name)); format(String,sizeof(String),"[ADMIN] {FF6969}%s has been KICKED %s: %s",AName,Name,Reason); SendClientMessageToAll(COLOR_DENIED,String); SetTimerEx("KickPlayer",700,false,"i",p1);;}else{ SendClientMessage(playerid,COLOR_DENIED,"[ERROR] {FF6969}Usage: /Kick <ID> <REASON>");}}return 1;}
|
This code will kick every connected player -_-
& rather use foreach instead of that for loop! It's faster!