SA-MP Forums Archive
How To Create A Command [ For Begginers ] - 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: How To Create A Command [ For Begginers ] (/showthread.php?tid=104456)



How To Create A Command [ For Begginers ] - Fresh_X - 24.10.2009

Simple Command

Introduction
A Command is Something You can Type Into Chat Box using a / In Front of the word.

Step 1:
In pawno open up a new file and scroll down until you see this.

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  {
    // Do something here
    return 1;
  }
  return 0;
}

Step 2:


This is the basis of your command, first off i'll teach you how to make a simple /kill command, for commiting suicide.

Ok, so first of all you need to change the "mycommand" part, change it to /kill. Then where you see the "10" change that to 5 because there is 4 letters in kill and 1 /. It should not look like this…

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/kill", cmdtext, true, 5) == 0)
  {
    // Do something here
    return 1;
  }
  return 0;
}
Step 3:
Once you have done that correctly you can now move on to the next part, in this command we want to set the players health to "0" so we mush use the function called SetPlayerHealth(…), take a look at the command now

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/kill", cmdtext, true, 5) == 0)
  {
    SetPlayerHealth(playerid, 0.0);
    return 1;
  }
  return 0;
}
Last Step:

Notice how i set the second part of the function to "0.0" the .0 shows that the number is a float, you dont need to worry too much about that at this stage.

Save your script, compile and test it, did it work? If yes then try setting it too 100.0 and changing /kill to /heal! and if you look through the includes list on the right hand side of pawno, you could even set their armour!



Re: How To Create A Command [ For Begginers ] - Rickyboy30 - 24.10.2009

How to post [ For Beginners ]

Please use code's!
Their like this:
Код:
Код:
 'your text or code'
USE THEM!


Re: How To Create A Command [ For Begginers ] - Virtual1ty - 24.10.2009

Quote:
Originally Posted by Rickyboy30
How to post [ For Beginners ]

Please use code's!
Their like this:
Код:
Код:
 'your text or code'
USE THEM!
actually no.. use tags!


Re: How To Create A Command [ For Begginers ] - Fresh_X - 24.10.2009

What's Your Opinion?


Re: How To Create A Command [ For Begginers ] - [mad]MLK - 24.10.2009

dcmd is better, i used it the day i started coding lol


Re: How To Create A Command [ For Begginers ] - (.Aztec); - 25.10.2009

Quote:
Originally Posted by ★Chris.
dcmd is better, i used it the day i started coding lol
I prefer ZCMD, more efficient.


Re: How To Create A Command [ For Begginers ] - Fresh_X - 25.10.2009

Well I Will create more tutorials for advanced players as this is my first tutorial


Re: How To Create A Command [ For Begginers ] - logan7058 - 03.11.2009

how do you make more then one command help me plz!!!!! im a newb


Re: How To Create A Command [ For Begginers ] - Jeffry - 03.11.2009

Quote:
Originally Posted by Fresh_X
Ok, so first of all you need to change the "mycommand" part, change it to /kill. Then where you see the "10" change that to 5 because there is 4 letters in kill and 1 /. It should not look like this…
I have the 10 on all my commands, and they are working fine, how that?