SA-MP Forums Archive
[HELP] DCMD (/akill) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] DCMD (/akill) (/showthread.php?tid=211505)



[HELP] DCMD (/akill) - Larsey123IsMe - 15.01.2011

Hi i'm trying to use DCMD for first time, but i failed :P

I'll get few errors, "undefined symbol "targetid""

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(akill, 5, cmdtext);
    return 0;
}

dcmd_akill(playerid, params[])
{
    new pName [MAX_PLAYER_NAME], tName [MAX_PLAYER_NAME], string [128];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(targetid, tName, MAX_PLAYER_NAME);
   
    new Reason;
    if(!sscanf(params,"ds", playerid, Reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /akill [playerid] [reason]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
    if(playerid) return SendClientMessage(playerid,COLOR_RED,"You can`t KILL yourself");

    format(string, sizeof(string), "ADMIN KILL: %s(%d) killed %s(%d) %d", pName, playerid, tName, targetid, reason);
    SendClientMessageToAll(COLOR_RED, string);
   
    SetPlayerHealth(targetid, 0.0);
    return 1;
}



Re: [HELP] DCMD (/akill) - DeadAhead - 15.01.2011

Firstly: Get SSCANF2, I HIGHLY Recommend it. Its way better than SSCANF1 or Commands with none, SSCANF1 used to Use Too much Memory, so SSCANF2 can now limit the cell number.

Case 1) If you are using SSCANF2 (Thats a plugin) You need to limit the number of cells, Example:
Код:
    if(!sscanf(params,"ds[50]", playerid, Reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /akill [playerid] [reason]");
Oh and the fix to your code btw
Код:
    if(!sscanf(params,"ds", targetid, Reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /akill [playerid] [reason]");
Instead of targetid you put playerid, Also:

i think you didnt do

Код:
new targetid;



Re: [HELP] DCMD (/akill) - Lorenc_ - 15.01.2011

um? make a variable targetid?


Re: [HELP] DCMD (/akill) - DeadAhead - 15.01.2011

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
um? make a variable targetid?
my post there, i accidently posted it unfinished, but i edited it, its got the fix.


Re: [HELP] DCMD (/akill) - Larsey123IsMe - 15.01.2011

Hmm, It looks like it dont find the ID somethimes, and

This work:

/akill 0 h

This DONT work:

/akill 0 hello

pawn Код:
#include <a_samp>
#include <sscanf>

#define COLOR_RED 0xFF0000AA

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(akill, 5, cmdtext);
    return 0;
}

dcmd_akill(playerid, params[])
{
    new targetid, reason;
   
    new pName [MAX_PLAYER_NAME], tName [MAX_PLAYER_NAME], string [128];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(targetid, tName, MAX_PLAYER_NAME);

    if(sscanf(params,"ds", targetid, reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /akill [playerid] [reason]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");

    format(string, sizeof(string), "ADMIN KILL: %s(%d) killed %s(%d) %s", pName, playerid, tName, targetid, reason);
    SendClientMessageToAll(COLOR_RED, string);
   
    SetPlayerHealth(targetid, 0.0);
    return 1;
}