20.04.2013, 16:25
Introduction
a_commands. An include which allows the commands to get executed if '@' is there at the first. For example; '@help', '@rules'.
How to script commands?
First you must download the include to make it work. Then you must add '#include' on the top of your script.
It is very easy. You just need to add its callback to your script. Here is how:
Now lets make a '@help' command.
OK, now lets add one more command. The '@rules' command.
Now lets add the '@kill' command.
It's very easy. A-bit same as OnPlayerCommandText.
LOG
Updates
* If an invalid command is executed, it will return a message; 'Unknown Command.'.
Download
NOTE: Save the include as 'a_commands.inc'
0.1: http://pastebin.com/2XScMeT3
a_commands. An include which allows the commands to get executed if '@' is there at the first. For example; '@help', '@rules'.
How to script commands?
First you must download the include to make it work. Then you must add '#include' on the top of your script.
pawn Код:
#include "a_commands"
pawn Код:
public OnPlayerACommandText(playerid, cmdtext[])
{
if(strcmp("@mycommandname", cmdtext, true, 10) == 0)
{
// Code here.
return 1;
}
return 0;
}
pawn Код:
public OnPlayerACommandText(playerid, cmdtext[])
{
if(strcmp("@help", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, -1, "This is the @help command. Ask the players for help.");
return 1;
}
return 0;
}
pawn Код:
public OnPlayerACommandText(playerid, cmdtext[])
{
if(strcmp("@help", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, -1, "This is the @help command. Ask the players for help.");
return 1;
}
if(strcmp("@rules", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, -1, "[SERVER RULES]: 1. Do not ....");
return 1;
}
return 0;
}
pawn Код:
public OnPlayerACommandText(playerid, cmdtext[])
{
if(strcmp("@help", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, -1, "This is the @help command. Ask the players for help.");
return 1;
}
if(strcmp("@rules", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, -1, "[SERVER RULES]: 1. Do not ....");
return 1;
}
if(strcmp("@kill", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, -1, "You killed yourself D:.");
SetPlayerHealth(playerid, 0);
return 1;
}
return 0;
}
LOG
Quote:
* [20/04/2013 - 19:13:00] Released 0.1 |
* If an invalid command is executed, it will return a message; 'Unknown Command.'.
Download
NOTE: Save the include as 'a_commands.inc'
0.1: http://pastebin.com/2XScMeT3