SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/03/2018, 03:51 PM   #1
Lixyde
Big Clucker
 
Join Date: Feb 2018
Posts: 66
Reputation: 1
Default Kick Command Bug

So when my friend types a command that needs to kick me it needs to say:

<MYNAME> was kicked by <MYFRIENDNAME>.

But when my friend does the command on me i mean he type /kick <MYNAME>

It says <MYFRIENDNAME> was kicked by <MYFRIENDNAME> WHY??

Why it says when my friend kick me says that he kicked himself but he kicked me

Please help me.

Here is the command: (IGNORE THE BUGGED TEXT, IT WAS ON DIFFERENT LANGUAGE)

Code:
CMD:kick(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] >= 1)
   {
      new PID;
      new reason[64];
      new str[128];
      new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
      GetPlayerName(playerid, Adminname, sizeof(Adminname));
      GetPlayerName(PID, Playername, sizeof(Playername));
      if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_SYSTEM, "SERVER: {FF1E00}/kick [playerid] [причина]");
      if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_GREY, "Този играч не е в сървъра!");
      if(PID == playerid) return SendClientMessage(playerid, COLOR_GREY, "Не можете да използвате тази команда върху себе си!");
      format(str, sizeof(str), "{FF1E00}ADMIN: %s е кикнат от администратор %s. [Причина: %s]", Playername, Adminname, reason);
      SendClientMessageToAll(COLOR_SYSTEM, str);
      KickEx(PID);
   }
   else
   {
      SendClientMessage(playerid, COLOR_GREY, "Трябва да сте поне 1 левел Админ!");
   }
   return 1;
}
__________________
Code:
Hello!
Lixyde is offline   Reply With Quote
Old 24/03/2018, 04:29 PM   #2
David (Sabljak)
Huge Clucker
 
Join Date: Nov 2011
Posts: 277
Reputation: 11
Default Re: Kick Command Bug

PHP Code:
CMD:kick(playeridparams[])
{
   if(
PlayerInfo[playerid][pAdmin] >= 1)
   {
      new 
PID;
      new 
reason[64];
      new 
str[128];
      new 
KickedName[MAX_PLAYER_NAME], AdminName[MAX_PLAYER_NAME];
      
GetPlayerName(playeridAdminNamesizeof(AdminName));
      
GetPlayerName(PIDKickedNamesizeof(KickedName));
      if(
sscanf(params"us[64]"PID,reason)) return SendClientMessage(playeridCOLOR_SYSTEM"SERVER: {FF1E00}/kick [playerid] [reason]");
      if(!
IsPlayerConnected(PID)) return SendClientMessage(playeridCOLOR_GREY"????????");
      if(
PID == playerid) return SendClientMessage(playeridCOLOR_GREY"????????");
      
format(strsizeof(str), "{FF1E00}ADMIN: Player %s was kicked by Admin %s. [Reason: %s]"KickedNameAdminNamereason);
      
SendClientMessageToAll(COLOR_SYSTEMstr);
      
KickEx(PID);
   }
   else
   {
      
SendClientMessage(playeridCOLOR_GREY"????????");
   }
   return 
1;

Try with this?
David (Sabljak) is offline   Reply With Quote
Old 24/03/2018, 04:36 PM   #3
Maxandmov
Big Clucker
 
Maxandmov's Avatar
 
Join Date: Feb 2011
Location: Moscow, Russia.
Posts: 150
Reputation: 11
Default Re: Kick Command Bug

Ignore what David said, because it seems he didn't figure what the issue is.

Code:
GetPlayerName(PID, Playername, sizeof(Playername));
      if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_SYSTEM, "SERVER: {FF1E00}/kick [playerid] [причина]");
      if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_GREY, "Този играч не е в сървъра!");
      if(PID == playerid) return SendClientMessage(playerid, COLOR_GREY, "Не можете да използвате тази команда върху себе си!");
You didn't even go through sscanf to define what a PID is and you already do GetPlayerName. It must be like that:

Code:
      if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_SYSTEM, "SERVER: {FF1E00}/kick [playerid] [причина]");
      if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_GREY, "Този играч не е в сървъра!");
      if(PID == playerid) return SendClientMessage(playerid, COLOR_GREY, "Не можете да използвате тази команда върху себе си!");
     GetPlayerName(PID, Playername, sizeof(Playername));
Oh, and I can bet it was writing he kicked himself simply because his ID was 0, and upon definition, PID's value was equal 0.
Maxandmov is offline   Reply With Quote
Old 24/03/2018, 04:58 PM   #4
David (Sabljak)
Huge Clucker
 
Join Date: Nov 2011
Posts: 277
Reputation: 11
Default Re: Kick Command Bug

Quote:
Originally Posted by Maxandmov View Post
Ignore what David said, because it seems he didn't figure what the issue is.

Code:
GetPlayerName(PID, Playername, sizeof(Playername));
      if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_SYSTEM, "SERVER: {FF1E00}/kick [playerid] [причина]");
      if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_GREY, "Този играч не е в сървъра!");
      if(PID == playerid) return SendClientMessage(playerid, COLOR_GREY, "Не можете да използвате тази команда върху себе си!");
You didn't even go through sscanf to define what a PID is and you already do GetPlayerName. It must be like that:

Code:
      if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_SYSTEM, "SERVER: {FF1E00}/kick [playerid] [причина]");
      if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_GREY, "Този играч не е в сървъра!");
      if(PID == playerid) return SendClientMessage(playerid, COLOR_GREY, "Не можете да използвате тази команда върху себе си!");
     GetPlayerName(PID, Playername, sizeof(Playername));
Oh, and I can bet it was writing he kicked himself simply because his ID was 0, and upon definition, PID's value was equal 0.
Oh, yea, i didn't even think about it.. lol'z my bad.
David (Sabljak) is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kick command is kicking the player using the command Josh_Main Scripting Help 13 28/09/2014 04:02 PM
Kick Command Bost Scripting Help 11 31/12/2013 08:32 AM
Made /kick Command to Kick Player from Virtual World... MAFIAWARS Scripting Help 11 28/09/2013 03:39 PM
Kick Command Dare Devil..... Scripting Help 1 29/05/2013 11:49 AM


All times are GMT. The time now is 05:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.