Need Help With A Command. - 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: Need Help With A Command. (
/showthread.php?tid=244212)
Need Help With A Command. -
Azzy - 26.03.2011
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!
Re: Need Help With A Command. -
aircombat - 26.03.2011
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);
Re: Need Help With A Command. -
Mr_Scripter - 26.03.2011
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;
}