/kick command only usable by a name
#1

helo, i need a /kick command script that only a person by a CERTAIN name can use it,

like the name u need to be is blah and someone tries to use it which name is PiE it wont work, so only "blah" can /kick?

help plz
Reply
#2

pawn Код:
if(strcmp(cmdtext,"/kick",true))
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid,name,sizeof(name));
  if(strcmp(name,"MenaceX",true)) return SendClientMessage(playerid,color,"You are not allowed to use this command.");
  // then the rest of the code.
}
Reply
#3

Quote:
Originally Posted by MenaceX^
pawn Код:
if(strcmp(cmdtext,"/kick",true))
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid,name,sizeof(name));
  if(strcmp(name,"MenaceX",true)) return SendClientMessage(playerid,color,"You are not allowed to use this command.");
  // then the rest of the code.
}
You would want to add somthing like

pawn Код:
if(AccountInfo[LoggedIn][playerid] =1)
Otherwise anyone could come in the sevrer under that name, not log in, and still use the command.
Reply
#4

Your code will give errors, the syntax itself is not even good..
Don't post it while you can't code it.

Reply
#5

Quote:
Originally Posted by MenaceX^
pawn Код:
if(strcmp(cmdtext,"/kick",true))
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid,name,sizeof(name));
  if(strcmp(name,"MenaceX",true)) return SendClientMessage(playerid,color,"You are not allowed to use this command.");
  // then the rest of the code.
}
thnx, but when i added the rest of my kick command it didnt work, wel, it did, but it kicked me lol...
can u give me full code plz?
Reply
#6

Sure.
pawn Код:
new cmd[128];
if(!strcmp(cmdtext,"/kick",true))
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid,name,sizeof(name));
  if(strcmp(name,"[GF]sIdEkIcK",true)) return SendClientMessage(playerid,color,"You are not allowed to use this command.");
  cmd=strtok(cmdtext,idx);
  if(!strlen(cmd)) return SendClientMessage(playerid,color,"Syntax: /kick [playerid/name]");
  new id=ReturnUser(cmd);
  if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color,"Invalid player id/name");
  SendClientMessage(id,color,"Kicked.");
  Kick(id);
  return 1;
}
Reply
#7

Quote:
Originally Posted by MenaceX^
Sure.
pawn Код:
new cmd[128];
if(!strcmp(cmdtext,"/kick",true))
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid,name,sizeof(name));
  if(strcmp(name,"[GF]sIdEkIcK",true)) return SendClientMessage(playerid,color,"You are not allowed to use this command.");
  cmd=strtok(cmdtext,idx);
  if(!strlen(cmd)) return SendClientMessage(playerid,color,"Syntax: /kick [playerid/name]");
  new id=ReturnUser(cmd);
  if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color,"Invalid player id/name");
  SendClientMessage(id,color,"Kicked.");
  Kick(id);
  return 1;
}
thnx but i get one error:

C:\SAMPSE~1\FILTER~1\manhunt.pwn(161) : error 017: undefined symbol "ReturnUser"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#8

pawn Код:
stock ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21)
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos]))
    {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
                userid = INVALID_PLAYER_ID;
            else
                return userid; // A player was found
        }
    }
    new len = strlen(text[pos]);
    new count = 0;
    new name[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof (name));
            if (strcmp(name, text[pos], true, len) == 0)
            {
                if (len == strlen(name))
                    return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count)
                SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
            else
                SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Identiation is abit missed because it's copied.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)