[Tutorial] [BEGINNER] Simple Commands & Functions
#1

Simple Commands & Functions
Client & Server

Before you decide you want to script for your server, Make sure you have the latest server files from here: www.sa-mp.com/download.php and make sure your client is up to date too (Currently 0.3x is the latest).

Pawno

So, Make sure to have opened your server folder and have opened a program called 'Pawno'. Pawno is a complex scripting program used by mainly SA-MP scripters for handling and editing their server. Some people are obviously on different levels of expertise than others on scripting, So therefore this is a starters guide for those who may need help.

Simple Command

So, Under:

Code:
OnPlayerCommandText
{
    return 1;
}
Write a function, Telling the program to send a message to a specific player, So start off with the function, Like so:

Code:
    SendClientMessage
The above function declares to the program to send a message, But you have not specified a player (Target), So lets do that now:

Code:
    SendClientMessage(playerid, 0xFFFFFF, "Replace me");
And voila!

Lets get that straight.

Code:
   SendClientMessage(playerid, 0xFFFFFF, "Replace me");

   [The Function][Open Bracket][Target][comma][The colour][comma][speech marks][Text][speech marks][Close      bracket][Semi Colon]
That is a simple SendClientMessage function. All it does is send a message to the player who types the command in, The full command is below:

Code:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		SendClientMessage(playerid, 0xFFFFFF, "Replace me");
		return 1;
	}
Conclusion

I hope that this will help those beginners to understand the meaning of "scripting" and now have a bit of knowledge about functions and declarations. More tutorials will be posted soon. Need help? PM me.

You are welcome to give me any feedback
Reply
#2

You should really add some more commands.
Reply
#3

Why are beginners supposed to start with the oldest and - in most cases - slowest methods? Either teach the current methods or don't make a topic at all. Sorry to be harsh, but it needs to be said.

I assume you are knowledgeable on this subject, so please tell me what the 10 symbolizes in this line:
pawn Code:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
@Beneath me: Thank you, but I was awaiting a response from the OP. If he doesn't (or didn't) know what it is for then he's not knowledgeable on the subject and therefore shouldn't have made a tutorial.
Reply
#4

I believe that '10' is the number of characters the command has (includes the slash). If the command was /kill, it'd be:

pawn Code:
if (strcmp("/kill", cmdtext, true, 5) == 0)
Not sure If I am correct though, I'm a beginner.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)