SA-MP Forums Archive
Ask about new fuction. - 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: Ask about new fuction. (/showthread.php?tid=119175)



Ask about new fuction. - boynumber5 - 07.01.2010

i'm confuse between fuction strcmp with new fuction dcmd.

any fuction is good more than and help explain about dcmd.

sorry for my bad english.


Re: Ask about new fuction. - introzen - 07.01.2010

I don't think anyone understands what you just wrote. Could you try to be more specific and explain more.

Sorry.


Re: Ask about new fuction. - BP13 - 07.01.2010

Quote:
Originally Posted by boynumber5
i'm confuse between fuction strcmp with new fuction dcmd.

any fuction is good more than and help explain about dcmd.

sorry for my bad english.
Quote:
Originally Posted by IntrozeN
I don't think anyone understands what you just wrote. Could you try to be more specific and explain more.

Sorry.
He is confused with strcmp and dcmd command systems. He is wondering which one is better and he needs help explaining about how to use dcmd and how it works.


Re: Ask about new fuction. - boynumber5 - 09.01.2010

yes, can you explain that for me please !!


Re: Ask about new fuction. - dice7 - 09.01.2010

You put this on the top of your gm
pawn Код:
#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
Creating the command
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(heal, 4, cmdtext); //this is the same as if(strcmp(cmdtext, "/heal", true) == 0)
    return 0;
}

The actual command itself. Put this on the very bottom of your script
This command will heal a player of your choice (the same example as on wiki)

playerid is the same as the player who typed the command
params, which is always a string!, is the text the player typed AFTER /heal.
So if the player typed "/heal 25", params will be "25"

pawn Код:
dcmd_heal(playerid, params[])
{
    if (strlen(params)) //if the lenght of "params" is more then zero (if the player actually typed anything after /heal)
    {
        id = strval(params);
        if (IsPlayerConnected(id))
        {
            SetPlayerHealth(id, 100.0);
            SendClientMessage(id, 0x00FF00AA, "You have been healed");
            SendClientMessage(playerid, 0x00FF00AA, "Player healed");
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "Usage: /heal <playerid>");
    }
    return 1;
}