[Tutorial] Kill/heal command
#1

Hey, how's everybody doing? In this BEGINNER FRIENDLY tutorial, I will teach you how to make a suicide command using ZCMD. For this tutorial, you pretty much need to know the basics of Pawno and you're ready to go.

________________________
Step 1. To make a suicide command, we're going to use ZCMD. You can use another command processor but I prefer using ZCMD. This is the format of ZCMD:

pawn Code:
COMMAND:mycommand(playerid, params[])
{
  // Do something
  return 1;
}
We'll need to change it to something like this:

pawn Code:
COMMAND:kill(playerid, params[])
{
  // Do something
  return 1;
}
Step 2. Now that we have the basic command, we'll need to set the player's health to 0, in order for him to die. For that, we'll use the SetPlayerHealth function. This function has 2 parameters.
  1. playerid The ID of the player to set the health of.
  2. health The value to set the player's health to.
Let's insert the function in our code. For that, let's remove the comment from above ("// Do something") and replace it with our function.

pawn Code:
COMMAND:kill(playerid, params[])
{
  SetPlayerHealth(playerid, 0);
  return 1;
}
And there you have your /kill command.

________________________
Now, for our healing command, we'll use the same structure but instead of setting the player's health to 0, we'll set it to 100.

pawn Code:
COMMAND:heal(playerid, params[])
{
  SetPlayerHealth(playerid, 100);
  return 1;
}
Reply
#2

repeated many many times ! we don't need old tutorials to be doubleposted ! people can just visite old threads that have Heal / Kill
Reply
#3

There are milions tutorials about those two commands , why do you thing your is different from others ?
Reply
#4

Yeah, most of these don't explain what to do in depth, simply give away a code.
Reply
#5

You could add messages to notify them like:
pawn Code:
SendClientMessage(playerid,-1,"You have committed a suicide!");
//and
SendClientMessage(playerid,-1,"You have healed yourself!");
And instead of writing COMMAND you may write CMD.
Reply
#6

Wtf is this playerid is the id of a player so basically you told newbie scripters that you would have to do this

SetPlayerHealth(playerid0,0);
SetPlayerHealth(playerid1,100);

Now all we need is some newbies asking for help in the
Scripting help section because you confused them what playerid really means

Playerid basically just means player...

And dont they have the same cmd in the wiki
Reply
#7

How do i set to so that it is restricted to an admin level?
Reply
#8

Quote:
Originally Posted by Nahin
View Post
How do i set to so that it is restricted to an admin level?
pawn Code:
COMMAND:heal(playerid, params[])
{
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "This command is only for RCON admins.");
  SetPlayerHealth(playerid, 100);
  return 1;
}
Reply
#9

Quote:
Originally Posted by zeeshanaayan07
View Post
Thanks for sharing a great information
Yes, it helped me a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)