Need Help With A Command.
#1

Hey guy's how are you all,

I'm a very new guy to scripting and I'm starting to learn what things are.

I was wondering are there different ways to script a function which does the same thing?
For an example I would like the command /kill which instantly kills the player.

How would the code look like, also does it matter where I put this code in my GameMode script?

Thanks in advance!
Reply
#2

you got many ways to create a /kill there are many ways to create a command like :
Dcmd
Zcmd
and normal OnPlayerCommandText
i'll give u an example for dcmd :

Код:
dcmd_kill(playerid,params[])
{
      SetPlayerHealth(playerid,0.0);
      return 1;
}
but u will also need to define dcmd by adding this :
Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
under your includes (top of the script)

then add under "OnPlayerCommandText" :
Код:
dcmd(kill,4,cmdtext);
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/kill", cmdtext, true) == 0)
    {
        SetPlayerHealth(playerid, 0);
        SendClientMessage(playerid, Color, "You Killed YourSelf"); //Change The Color You Can Also Send Message to all
        return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)