[Include] a_commands - Now commands get executed if '@' is at the first! [Not '/']
#1

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.

pawn Код:
#include "a_commands"
It is very easy. You just need to add its callback to your script. Here is how:

pawn Код:
public OnPlayerACommandText(playerid, cmdtext[])
{
    if(strcmp("@mycommandname", cmdtext, true, 10) == 0)
    {
        // Code here.
        return 1;
    }
    return 0;
}
Now lets make a '@help' command.

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;
}
OK, now lets add one more command. The '@rules' command.

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;
}
Now lets add the '@kill' command.

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;
}
It's very easy. A-bit same as OnPlayerCommandText.

LOG

Quote:

* [20/04/2013 - 19:13:00] Released 0.1

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
Reply


Messages In This Thread
a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by ACI - 20.04.2013, 16:25
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by TheArcher - 20.04.2013, 17:03
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by MP2 - 20.04.2013, 17:53
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by ACI - 21.04.2013, 03:31
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by Scenario - 21.04.2013, 04:14
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by ACI - 21.04.2013, 04:27
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by Scenario - 21.04.2013, 06:16
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by ACI - 21.04.2013, 06:45
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by JaKe Elite - 21.04.2013, 07:09
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by TheArcher - 21.04.2013, 11:45
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by LeeXian99 - 21.04.2013, 11:47
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by sKgaL - 21.04.2013, 12:20
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by Jochemd - 21.04.2013, 14:01
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] - by Kar - 21.04.2013, 19:07

Forum Jump:


Users browsing this thread: 1 Guest(s)