Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
AndySedeyn - 31.10.2016
Quote:
Originally Posted by Crayder
AndySedeyn, you're not checking it right. You should get the admin bit range from the command flags. If that's not zero then it's an admin command.
|
In 'commands'?
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Yashas - 01.11.2016
Quote:
Originally Posted by AndySedeyn
Is it possible to include the default CMD flag in every single command?
|
You can loop through all the commands in OnGameModeInit/OnFilterScriptInit and add the default flag.
If you have a neat syntax to do the same, let me know. Will see if that can be implemented. For the time being, use the Init callbacks.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
JJohnson1 - 01.11.2016
This .inc looks great Yashas.You've obviously spent alot of time with this and I'll definitely be checking this out in the near future.Thanks very much Yashas for all of Your work. <+rep'd>
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
AndySedeyn - 01.11.2016
Having your OnGameModeInit hooked with y_hooks will cause the following example:
PHP код:
public OnGameModeInit()
{
for(new i = GetTotalCommandCount(); i >=0; i--)
{
new flags = GetCommandFlags(i);
if(flags & ACMD1) AdminLevel[i] = 1;
else if(flags & ACMD2) AdminLevel[i] = 2;
else if(flags & ACMD3) AdminLevel[i] = 3;
else if(flags & ACMD4) AdminLevel[i] = 4;
else if(flags & ACMD5) AdminLevel[i] = 5;
}
}
To malfunction. It will not detect ANY command. But I figured that's supposed to happen.
And having
i = GetTotalCommandCount() will detect an extra non-existing command with flag:
Код:
11111111111111111111111111111111
and no name.
PHP код:
for(new i = (GetTotalCommandCount() - 1); i >= 0; i--)
fixes that. I thought it was worth mentioning.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Yashas - 01.11.2016
GetTotalCommandCount() returns total number of commands. The highest id will be GetTotalCommandCount()-1.
Fixed in the topic. Thank You.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Yashas - 04.11.2016
Update:
v0.3 beta November 4th
Adds command states/modes
View the include
This update requires you to return CMD_SUCCESS/CMD_FAILURE in all the commands to avoid tag mismatch warnings.
Код:
CMD:report[help](cmdid, playerid, params[]) return SendClientMessage(playerid, -1, "Reports the player to an administrator.");
CMD:report(cmdid, playerid, params[]) {...}
CMD:pm[help](cmdid, playerid, params[]) return SendClientMessage(playerid, -1, "Sends a private message to the given player.");
CMD:pm(cmdid, playerid, params[]) {...}
CMD:help[help](cmdid, playerid, params[]) return SendClientMessage(playerid, -1, "Access server help topics.");
CMD:help(cmdid, playerid, params[])
{
new success;
ExecuteCommand(params, "help", playerid, success, "");
switch(success)
{
case INVALID_COMMAND_ID: return SendClientMessage(playerid, RED, "The specified command does not exist.");
case cellmin: return SendClientMessage(playerid, RED, "The specified command does not have a help description.");
case 0: return SendClientMessage(playerid, RED, "Oops! Failed to fetch the description of the given command.");
//case 1: handled by the command which was executed, i.e: a description message was sent to the player
}
return CMD_SUCCESS;
}
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
kurta999 - 06.11.2016
This is fucking awesome!
It's nice to see that somebody also started to use flags. I redesigned zcmd for myself to support flags to quickly add situations to every command when it should work or not, but it's not as that advanced as yours.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Max_Andolini - 11.11.2016
I think change this;
CMD_SUCCESS
I prefer return 1;
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Yashas - 12.11.2016
That was planned to be done many days ago but haven't found a solution yet. Use CMD_SUCCESS for now.
Need to rework the defines to allow return 1 so it will take time. Once the include is updated, you can use Search & Replace dialog to replace all CMD_SUCCESS with return 1.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Max_Andolini - 13.11.2016
Quote:
Originally Posted by Yashas
That was planned to be done many days ago but haven't found a solution yet. Use CMD_SUCCESS for now.
Need to rework the defines to allow return 1 so it will take time. Once the include is updated, you can use Search & Replace dialog to replace all CMD_SUCCESS with return 1.
|
Fix please as soon as possible.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Yashas - 14.11.2016
v0.3 beta 14th November
Changes:- You can return integers in command functions (Usage of CMD_SUCCESS, CMD_FAILURE is made optional)
- Flags are now tagged variables ('flags' is the tag)
- ExecuteCommand return/success values changed.
Recommended to use the following structure for defining flags
Код:
enum flags (*=2)
{
ADMIN_COMMAND_FLAG = 1,
TEST1,
TEST2
}
View include
*The tag for command flags could be changed in future (before going out of beta)
*Open for suggestions
Lot of cookies for Y_Less for his support
here!
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Max_Andolini - 14.11.2016
Quote:
Originally Posted by Yashas
v0.3 beta 14th November
Changes:- You can return integers in command functions (Usage of CMD_SUCCESS, CMD_FAILURE is made optional)
- Flags are now tagged variables ('flags' is the tag)
- ExecuteCommand return/success values changed.
Recommended to use the following structure for defining flags
Код:
enum flags (*=2)
{
ADMIN_COMMAND_FLAG = 1,
TEST1,
TEST2
}
View include
*The tag for command flags could be changed in future (before going out of beta)
*Open for suggestions
|
Finally, thank you.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Yashas - 17.11.2016
17th November beta
Changes:
This will probably be the final beta unless someone suggests something or reports a bug.
View Include
Full credits to Y_Less.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
ReshiramZekrom - 21.11.2016
With zcmd, I used to return whole cmds with "return cmd_kiss(playerid, "");". If I try to do "return cmd_kiss(cmdid, playerid, "");" it give me error (error 017: undefined symbol "cmdid"). What should I do? I must use this function: GetCommandID?
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Konstantinos - 21.11.2016
Код:
return cmd_kiss(cid_kiss, playerid, "");
@Yashas: A great include with many features, very nice!
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Yashas - 22.11.2016
22nd November Update
Fixed a bug with ExecuteCommand (success parameter used to be set wrongly). No change in syntax.
View Include
---------------------------------------------------------------------------------------------------------------
Quote:
Originally Posted by ReshiramZekrom
With zcmd, I used to return whole cmds with "return cmd_kiss(playerid, "");". If I try to do "return cmd_kiss(cmdid, playerid, "");" it give me error (error 017: undefined symbol "cmdid"). What should I do? I must use this function: GetCommandID?
|
If you are trying to make an alternate name for a command, use the ALT syntax.
Do as Konstantinos said. If you get an undefined symbol error, use the following code:
Код:
static cmdid = -2;
if(cmdid == -2) cmdid = GetCommandID("urcmd");
cmd_urcmd(cmdid, playerid, params);
By the way, you can pass anything as cmdid as long as you don't use the command id parameter in the your command.
Код:
cmd_urcmd(1231231, playerid, params)
However, using the correct command id will future proof your code. The effect on performance is negligible if you make use of static variables to store the command id.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Nero_3D - 11.12.2016
Congratulations to your release but
- No idea why you added the cmdid parameter to the command
- Makes it harder to change the command processor
- Isn't even needed, you just could use cid_commandname
- You should change the prefix and macro names, makes it impossible to test in one go
Do it like in ycmd, only add a compatibility macro while using your own namespace
- Benchmark script is outdated (on first page) some functions are undefined
/\ just suggestions everything else works fine as it should
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Crayder - 11.12.2016
Quote:
Originally Posted by Nero_3D
You should change the prefix and macro names, makes it impossible to test in one go
Do it like in ycmd, only add a compatibility macro while using your own namespace
|
You know YCMD also uses "CMD" as well as "YCMD"?
Quote:
Originally Posted by Nero_3D
No idea why you added the cmdid parameter to the command
- Isn't even needed, you just could use cid_commandname
|
"cid_*" is a new thing, cmdid was a parameter long before it was added.
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Nero_3D - 11.12.2016
Quote:
Originally Posted by Crayder
You know YCMD also uses "CMD" as well as "YCMD"?
|
I know therefor I said "add a compatibility macro" then I could undef CMD and it still works without interfering
The other reason was about the prefix "cmd_", if you change something and it isn't compatible to the old format you should change the prefix too
Quote:
Originally Posted by Crayder
"cid_*" is a new thing, cmdid was a parameter long before it was added.
|
Couldn't know that since I just found this topic, so time to remove it?
"Long before it was added", topic created on 23.10.2016 :/
Re: Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+) -
Crayder - 12.12.2016
Quote:
Originally Posted by Nero_3D
Couldn't know that since I just found this topic, so time to remove it?
"Long before it was added", topic created on 23.10.2016 :/
|
I wasn't disagreeing with you, in fact I do agree it seemed useless.
I asked Yashas and he said it is needed for reassigning and stuff.