Why does it kick myself?
#1

The cmd works fine except one thing;
When I type /kick 0, it kicks me... whilst I scripted not to kick my self, lol.

PHP код:
CMD:kick(playeridparams[])
{
   new 
targetplayer;
   if(
IsPlayerAdmin(playerid))
   {
    if(
sscanf(params"u"targetplayer))
    return 
SendClientMessage(playeridCOLOR_ORANGE"USAGE: /kick [ID] [REASON]");
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"Player is not connected!");
    if(
targetplayer == playerid)
    
SendClientMessage(playeridCOLOR_RED"You cannot kick yourself!");
    
    new 
string[64];
    
format(stringsizeof string"%s has been kicked by an admin!"Kick(targetplayer));
    
SendClientMessageToAll(COLOR_LIGHTBLUEstring);
   }
    else
   {
    
SendClientMessage(playerid, -1"SERVER: Unknown command.");
   }
   return 
1;

Reply
#2

First, you should use GetPlayerName to display the name in the format.
Second, you should use a timer of about 100 ms before you kick the player, otherwise the message wont get displayed to the kicked player.
Reply
#3

Try this:
PHP код:
CMD:kick(playeridparams[]) 

   new 
targetplayer
   if(
IsPlayerAdmin(playerid)) 
   { 
    if(
sscanf(params"u"targetplayer)) 
    return 
SendClientMessage(playeridCOLOR_ORANGE"USAGE: /kick [ID] [REASON]"); 
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"Player is not connected!"); 
    if(
targetplayer == playerid) return SendClientMessage(playeridCOLOR_RED"You cannot kick yourself!"); 
     
    new 
string[64]; 
    
format(stringsizeof string"%s has been kicked by an admin!"Kick(targetplayer)); 
    
SendClientMessageToAll(COLOR_LIGHTBLUEstring); 
   } 
    else 
   { 
    
SendClientMessage(playerid, -1"SERVER: Unknown command."); 
   } 
   return 
1

Reply
#4

PHP код:
#include <a_samp>
#include <zcmd> // need this
#include <sscanf> // need this
CMD:kick(playerid,params[])
{
    new 
targetid,name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],msg[128],msg2[128],msg3[128];
    {
        if(
sscanf(params,"u",targetid)) return SendCLientMessage(playerid,-1,"syntax: /kick [ID/name]");
        if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You are not admin");
        if(
IsPlayerAdmin(ID)) return SendClientMessage(playerid,-1,"You cannot kick other administrators");
        else if(
targetid == playerid) return SendClientMessage(playerid,-1,"You cannot kick yourself");
        else
        {
            
GetPlayerName(ID,name,sizeof(name)); // We take targetid's name
            
format(msg,sizeof(poruka),"You kicked %s from the server",name); // formating messages which will be sent to you
            
SendClientMessage(playerid,-1,poruka); // sent
            
GetPlayerName(playerid,name2,sizeof(name2)); //we take your name
            
format(msg2,sizeof(poruka2),"%s just kicked you from the server",name); // we send message to target
            
SendClientMessage(ID,-1,poruka2); // sent
            
format(msg3,sizeof(msg3),"%s kicked %s from the server",name2,name); // formating message to send for all
            
SendClientMessageToAll(-1,msg3); // sent
            
{
                
Kick(ID);
            }
        }
        return 
1;
    }

Here is an example. If you give me your enum i can make it more complicate.
Reply
#5

This has been fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)