[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
#2

Who do you think is gonna use this? o.O
Reply
#3

Commands on every server, and many program's use a slash. What on earth wold possess you to use @?!

The only non-slash commands I've ever seen were on some stunt server years ago that used double-slashes for teleports (e.g. //DM) and exclamation marks for races (e.g. !drag).
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
Commands on every server, and many program's use a slash. What on earth wold possess you to use @?!

The only non-slash commands I've ever seen were on some stunt server years ago that used double-slashes for teleports (e.g. //DM) and exclamation marks for races (e.g. !drag).
Take me as a scripter who wants to change '@' to '!'. Here is how I will change it [I've also written a tip in the include]:

pawn Код:
#define Acmd_Char '@'
To:

pawn Код:
#define Acmd_Char '!'
But dont forget to edit in 'OnPlayerACommandText'.
Reply
#5

strcmp... yuck!
Reply
#6

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
strcmp... yuck!
-_-, Try to make a command processor for it. What ever blah blah.
Reply
#7

What is the point in making a new command processor when it's going to be much slower than the other ones that are out there?

This is basically the same as the standard commands with OnPlayerCommandText, except the command prefix is @ instead of /... The reason there are other command processors is for speed increases. ZCMD and YCMD are top-of-the-line processors with massive speed improvements.

Why would someone use this over anything else? Definitely not because of the changed command prefix! I could probably change ZCMD's command prefix to @ if I wanted to... but there's no point!
Reply
#8

You can change '@' to whatever you want. You know, I released it for this reason. If no one wants to use it, I dont care. And if someone wants to use it, Most-welcome.
Reply
#9

I know there is user somewhere will use this.
However, This is slow. It is just the same with the OnPlayerCommandText.
the difference is you rename the callback and use @ instead of /.
Just like what other said.
Reply
#10

Yea but nobody is going to use this just because you can change the commands from slash "/" to anything you want. It's pointless.
Reply
#11

It's not a wise choice to use this. :/
Reply
#12

useless include EVER FOUND!
Reply
#13

Commands with a '@' don't feel well for me because I got used to '/'. Nobody will use it but still rep+ because you took time to create a script.
Reply
#14

pawn Код:
#define Acmd_Char '@'
 
public OnPlayerText(playerid, text[])
{
        if(text[0] == Acmd_Char)
        {
                CallLocalFunction("OnPlayerACommandText", "ds", playerid, text[1]);
                return 0;
        }
        return 1;
}
pawn Код:
public OnPlayerACommandText(playerid, cmdtext[])
{
    if(strcmp("help", cmdtext, true, 4) == 0)
    {
        SendClientMessage(playerid, -1, "This is the @help command. Ask the players for help.");
        return 1;
    }
    return 0;
}
beats changing the first letter for every command!
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)