[Tutorial] Using basic functions to make commands
#1

So ALOT of people go and look for FS's to add to a server. But in my opinion if you want a server, learn to script?
Which is how i wound up making this, for people to use or edit. Also if you do decide to use any of these i dont require credits, just leave a comment telling me what you think.

So first i'm gonna start with the most basic /kill command.

Go and open pawno then go down to
Code:
public OnPlayerCommandText(playerid, cmdtext[])
And now the first function we are going to use is
Code:
SetPlayerHealth(playerid, health);
Then we are gonna start making the command.
Code:
	if (strcmp("/kill", cmdtext, true, 10) == 0)
	{
		return 1;
		SetPlayerHealth(playerid, 0);
	}
Hit Compile? No.
Can you see what i did wrong?

I put the "return" before the function(and yes i have seen some people do this).

So now we need to edit it to come out like the following:
Code:
	if (strcmp("/kill", cmdtext, true, 10) == 0)
	{
		SetPlayerHealth(playerid, 0);
		return 1;
	}
Now we can hit compile
And with no errors this time.

Congrats you have made you first command.

Now we can move on to something else, which will be sending messages.

There are a few types
A.)SendClientMessage(playerid, color, "message");
This can be used like the following:
Code:
SendClientMessage(playerid, RED, "Banana's!");
B.)SendClientMessageToAll(color, "message");
This will send a message to the whole server, so like:
Code:
SendClientMessageToAll(RED, "Banana's x 2");
C.)SendPlayerMessageToAll(color, "message");
This is the last function i will go over , and it sends something someone types to all players:
Code:
SendPlayerMessageToAll(RED, "Hi!");
Also you might wana add this at the top:
Code:
#define RED 0xFF0000AA
And if anyone has some tips for me, please give.
As its 4:30am i am tired, so i might sleep will add some more tutorials tomorrow, including more cmds and functions.
Good luck guys!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)