16.06.2014, 07:36
(
Last edited by DaleWestbrook; 17/09/2014 at 03:01 AM.
)
Hey guys excuse me if this tutorial is badly explained or wrong as it is my first tutorial and i thought i might try it out
So this tutorial will hopefully help you to create a /sethp command which will look like /sethp [playerid] [health]
You will need two includes for this command. The first include is
ZCMD - by Zeex (https://sampforum.blast.hk/showthread.php?tid=91354)
and also
sscanf 2.8.1 - by Y_Less (https://sampforum.blast.hk/showthread.php?tid=91354)
You will need to open up the files and put ZCMD in your include folder which can be accessed by going into your scripts folder then into pawno and you should see include and just add it there but while you are there add the sscanf include aswell. You will then have to add the sscanf plugins which is easy again just go to your server folder and open the folder named plugins and insert the file. Lastly open your server.cfg file and add the plugins which should look like
Then you need to add the includes into the script with two simple lines
now lets get started:
navigate to where ever you want to write the command on your script. Also now with ZCMD the command format will not be under public OnPlayerCommandText(but it still can be) and the format of the command is now
or
Personally i use the first one as it is faster to type. now lets get to the actual command:
Your gonna wanna use a format for the command to type in so ill use CMD: which will make it
Were then gonna make it so only an admin can use this command so we will use IsPlayerAdmin so lets put it in the command
Got it so far?
Lets continue
Lets make it so the admin part actually does something so we need to open that part up like so:
This is what the command should end up looking like
So that is it for this tutorial i hope i helped. Feel free to correct or even just ask questions.
Edit: Thank you to the guys that commented
So this tutorial will hopefully help you to create a /sethp command which will look like /sethp [playerid] [health]
You will need two includes for this command. The first include is
ZCMD - by Zeex (https://sampforum.blast.hk/showthread.php?tid=91354)
and also
sscanf 2.8.1 - by Y_Less (https://sampforum.blast.hk/showthread.php?tid=91354)
You will need to open up the files and put ZCMD in your include folder which can be accessed by going into your scripts folder then into pawno and you should see include and just add it there but while you are there add the sscanf include aswell. You will then have to add the sscanf plugins which is easy again just go to your server folder and open the folder named plugins and insert the file. Lastly open your server.cfg file and add the plugins which should look like
PHP Code:
plugins sscanf
PHP Code:
#include <ZCMD>
#include <sscanf2>
navigate to where ever you want to write the command on your script. Also now with ZCMD the command format will not be under public OnPlayerCommandText(but it still can be) and the format of the command is now
PHP Code:
CMD:command(playerid,params[])
{
return 1;
}
PHP Code:
COMMAND:command(playerid,params[])
{
return 1;
}
Your gonna wanna use a format for the command to type in so ill use CMD: which will make it
PHP Code:
CMD:sethp(playerid,params[])
{
return 1;
}
PHP Code:
CMD:sethp(playerid,params[])
{
if(IsPlayerAdmin(playerid)//You will need to use /rcon login in game to use the command or it wont work
return 1;
}
Lets continue
Lets make it so the admin part actually does something so we need to open that part up like so:
PHP Code:
CMD:sethp(playerid,params[])
{
if(IsPlayerAdmin(playerid)//You will need to use /rcon login in game to use the command or it wont work
{
new Health;// This will help with the amount of health
new PID;// This is the target
if(sscanf(params, "ud", PID, Health)) return SendClientMessage(playerid, -1, "USAGE: /sethp [playerid] [health]");//This is where sscanf comes in we will show that they need to type the player and also the amount of health
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, -1, "Player is not connected");//This is just checking if the target is online (! means not so !IsPlayerConnected is player not connected)
SetPlayerHealth(PID, Health);// We are setting the health for the target
}//closing the bracket for is the player is an admin
else SendClientMessage(playerid, -1, "You are not an admin");//This will send the command user a message stating that s/he is not an admin (the -1 means white)
return 1;//Just returning the command
}//Closing the command and your done
PHP Code:
CMD:sethp(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
new Health;
new PID;
if(sscanf(params, "ud", PID, Health)) return SendClientMessage(playerid, -1, "USAGE: /sethp [playerid] [health]");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, -1, "Player is not connected");
SetPlayerHealth(PID, Health);
}
else SendClientMessage(playerid, -1, "You are not authorized to use this command!");
return 1;
}
Edit: Thank you to the guys that commented