whats wrong with this?
#1

im tryin 2 make a dcmd cmd but some bullshit error?


Код:
dcmd_kick(playerid, params[])
{
 	new pName[MAX_PLAYER_NAME]; // Here we are defining the kicking's name
    GetPlayerName(targetid, pName, sizeof(pName));//<-- line 357
    if(!IsPlayerAdmin(playerid)) return 0; // Checking if the player is rcon.
    new targetid = strval(params);
	new reason[64], string[128]; // targetid is also a pName
    if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /kick [playerid] [reason]");
	//if(targetid == playerid) return SendClientMessage(playerid,COLOR_RED,"You Cant Kick Yourself!"); // here it tells the player to use /kick playerid reason or /kick partofname reason
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This Player Isnt Online"); // This is if the player is not connected, or you can't kick yourself.
    format(string, sizeof(string), "{FF66FF}**KICK: %s (ADMIN KICK) Reason: %s",pName, reason);
    SendClientMessageToAll(COLOR_RED, string); // The yellow define will be up!
    Kick(targetid);
 	return 1;
}
Код:
C:\Users/**********\Desktop\********\gamemodes\lvdm.pwn(357) : error 017: undefined symbol "targetid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
please help ^^
Reply
#2

Put
pawn Код:
new targetid;
under
pawn Код:
new pName[MAX_PLAYERS];
and remove the
pawn Код:
new targetid = strval(params);
under
pawn Код:
if(!IsPlayerAdmin(playerid)) return 0; // Checking if the player is rcon.
Reply
#3

pawn Код:
new targetid = strval(params);
Change to:
pawn Код:
new targetid;
And put it below
pawn Код:
new pName[ MAX_PLAYER_NAME ];
Not under IsPlayerAdmin
So the full code is:

pawn Код:
dcmd_kick(playerid, params[])
{
    new pName[MAX_PLAYER_NAME], targetid; // Here we are defining the kicking's name
    if(!IsPlayerAdmin(playerid)) return 0; // Checking if the player is rcon.
    new reason[64], string[128]; // targetid is also a pName
    if(sscanf(params, "us[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /kick [playerid] [reason]");
    GetPlayerName(targetid, pName, sizeof(pName));//<-- line 357
    //if(targetid == playerid) return SendClientMessage(playerid,COLOR_RED,"You Cant Kick Yourself!"); // here it tells the player to use /kick playerid reason or /kick partofname reason
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This Player Isnt Online"); // This is if the player is not connected, or you can't kick yourself.
    format(string, sizeof(string), "{FF66FF}**KICK: %s (ADMIN KICK) Reason: %s",pName, reason);
    SendClientMessageToAll(COLOR_RED, string); // The yellow define will be up!
    Kick(targetid);
    return 1;
}
Reply
#4

Quote:
Originally Posted by Mean
Посмотреть сообщение
pawn Код:
new targetid = strval(params);
Change to:
pawn Код:
new targetid;
@Ghost, no that won't work...
I know, i didnt see he used sscanf so..
Reply
#5

I edited, it would work but it's more efficient this way.
Reply
#6

pawn Код:
dcmd_kick(playerid, params[])
{
    if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /kick [playerid] [reason]");
    else
    {
        new pName[MAX_PLAYER_NAME]; // Here we are defining the kicking's name
        GetPlayerName(targetid, pName, sizeof(pName));//<-- line 357
        if(!IsPlayerAdmin(playerid)) return 0; // Checking if the player is rcon.
        else
        {
            new targetid = strval(params);
            new reason[64], string[128]; // targetid is also a pName
            //if(targetid == playerid) return SendClientMessage(playerid,COLOR_RED,"You Cant Kick Yourself!"); // here it tells the player to use /kick playerid reason or /kick partofname reason
            if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This Player Isnt Online"); // This is if the player is not connected, or you can't kick yourself.
            format(string, sizeof(string), "{FF66FF}**KICK: %s (ADMIN KICK) Reason: %s",pName, reason);
            SendClientMessageToAll(COLOR_RED, string); // The yellow define will be up!
            Kick(targetid);
        }
       }
       return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)