How To Create A Command [ For Begginers ]
#1

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!
Reply
#2

How to post [ For Beginners ]

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

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!
Reply
#4

What's Your Opinion?
Reply
#5

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

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

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

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)