[Tutorial] How to make simple buy health and buy armour commands.
#1

Ok so this is my first tutorial so please tell me if i make any errors because I'm new to scripting.

Ok so the first command what we are going to make is /buyhealth
so what we will need is a zcmd include it can be found here.


we will place this at the top of our script so we get the cmds to work.
Code:
#include <zcmd>
We need to add this to start the cmd
Code:
CMD:buyhealth(playerid, params[])
{
ok so now were going to add this, what it is it takes the money off the player when they use the cmd /buyhealth
Code:
 if(GetPlayerMoney(playerid) > 5500)
{
     GivePlayerMoney(playerid, -5500);
}
now we are going to add the player 100 health.
Code:
        SetPlayerHealth(playerid,100); // this give him full health
now we are going to make a message to the player after he has bought the health
Code:
        SendClientMessage(playerid,-1,"You paid 5500$ to heal your self !"); // changeme : the color you wan't , COLOR_GREEN for example
now we are going to add a message that will send if the player does not have the required money amount.
Code:
 } else  SendClientMessage(playerid,-1,"You don't have 5500$ !");
Ok we are nearly done but we need to add this before we finish the command
Code:
 return 1;
}
and here is how the command should look like
Code:
CMD:buyhealth(playerid, params[])
{
if(GetPlayerMoney(playerid) > 5500)
{
     GivePlayerMoney(playerid, -5500);
}
        SetPlayerHealth(playerid,100); // we heal him a.k.a give him full health
        SendClientMessage(playerid,-1,"You paid 5500$ to heal your self !");
 } else  SendClientMessage(playerid,-1,"You don't have 5500$ !");
 return 1;
}
i hope this helped im sorry if i did it wrong as i said its my first tutorial and im new at scripting.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)