SA-MP Forums Archive
[Tutorial] Making a few very simple commands - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Making a few very simple commands (/showthread.php?tid=396584)



Making a few very simple commands - bensmart469 - 01.12.2012

Hello guys! This is bensmart469 presenting you a simple tutorial on how to make simple commands
First of all, you will need to have zcmd, make sure to add this onto the top too
PHP код:
#include <zcmd> 
There are many other command processors but for now, we will use this.

First of all, we will make the simple /help command
Firstly, define color_yellow or any color which you want (replace the color_yellow with color_NAMEHERE and then the html color code)
WARNING, IF USING A FILTERSCRIPT USE #define filterscript
PHP код:
#define COLOR_YELLOW 0xFFFF00FF 
Here is the command, don't worry if you don't understand it! It will be described
PHP код:
CMD:help(playeridparams[])
{
    
SendClientMessage(playeridCOLOR_YELLOW"welcome to the test server!");
    return 
1;

PHP код:
    SendClientMessage(playeridCOLOR_YELLOW"welcome to the test server!"); 
Sends the player a message (playerid)

Now, we will make a /fullhealth command


PHP код:
CMD:fullhealth(playeridparams[])
{
        
SetPlayerHealth(playerid100);
        
SendClientMessage(playeridCOLOR_YELLOW,  "You have set your health to 100");
        return 
1;

PHP код:
        SetPlayerHealth(playerid100); 
This is to set the player's health to 100
PHP код:
    SendClientMessage(playeridCOLOR_YELLOW,  "You have set your health to 100"); 
This is to send the player a message
If you are looking for a few more, better commands, there is one below which takes money from you and gives you full health and armor in exchange
PHP код:
CMD:refillhealth(playerid,params[])
{
      if(
GetPlayerMoney(playerid) < 500) return SendClientMessage(playeridCOLOR_YELLOW"You need 500 dollars in order to use this command");
      
GivePlayerMoney(playerid,-500);
      
SetPlayerHealth(playerid100);
      
SetPlayerArmour(playerid100);
      
SendClientMessage(playeridCOLOR_YELLOW"You have payed 500 dollars to be healed");
      return 
1;

PHP код:
      if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playeridCOLOR_YELLOW"You need 500 dollars in order to use this command"); 
This checks if the player does not have enough money for the health, if they don't, it will send them a message
PHP код:
      GivePlayerMoney(playerid,-500); 
This takes 500 dollars from the player
PHP код:
      SetPlayerHealth(playerid100);
      
SetPlayerArmour(playerid100); 
These set the player's health and armor to 100
PHP код:
      SendClientMessage(playeridCOLOR_YELLOW"You have payed 500 dollars to be healed"); 
This is to send the player a message to say that they have been healed

These commands were only for those who are new to scripting, I may make another tutorial soon for those who are more experienced with scripting.
And any bugs or compiling errors, post below, i will help you as soon as possible


Re: Making a few very simple commands - zohartrejx - 01.12.2012

Nice and useful for newbie


Re: Making a few very simple commands - [GF]Logic - 01.12.2012

are you spamming ? cause i can see the same commands on wiki ?!


Re: Making a few very simple commands - bensmart469 - 01.12.2012

i didnt see these cmds on the wiki, post a link please


Re: Making a few very simple commands - IceBilizard - 03.12.2012

Nice tut


Re: Making a few very simple commands - Guest4390857394857 - 24.02.2014

better for newbies!


Re: Making a few very simple commands - ACI - 24.02.2014

Quote:

are you spamming ? cause i can see the same commands on wiki ?!

You're discouraging new people.


Re: Making a few very simple commands - Ozil - 26.02.2014

nice tutorial for a beginner...


Re: Making a few very simple commands - OnPlayerText - 26.02.2014

Pretty usefull for learners


Re: Making a few very simple commands - alimash - 27.02.2014

Thank you very much