a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
ACI - 20.04.2013
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:
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
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
TheArcher - 20.04.2013
Who do you think is gonna use this? o.O
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
MP2 - 20.04.2013
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).
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
ACI - 21.04.2013
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]:
To:
But dont forget to edit in 'OnPlayerACommandText'.
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
Scenario - 21.04.2013
strcmp... yuck!
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
ACI - 21.04.2013
Quote:
Originally Posted by RealCop228
strcmp... yuck!
|
-_-, Try to make a command processor for it. What ever blah blah.
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
Scenario - 21.04.2013
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!
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
ACI - 21.04.2013
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.
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
JaKe Elite - 21.04.2013
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.
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
TheArcher - 21.04.2013
Yea but nobody is going to use this just because you can change the commands from slash "/" to anything you want. It's pointless.
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
LeeXian99 - 21.04.2013
It's not a wise choice to use this. :/
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
sKgaL - 21.04.2013
useless include EVER FOUND!
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
Jochemd - 21.04.2013
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.
Re: a_commands - Now commands get executed if '@' is at the first! [Not '/'] -
Kar - 21.04.2013
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!