[Include] Smart Command Processor (Scripter-friendly, feature rich and fast) (aka iZCMD+)
#41

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'?
Reply
#42

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.
Reply
#43

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>
Reply
#44

Having your OnGameModeInit hooked with y_hooks will cause the following example:
PHP код:
public OnGameModeInit()
{
      for(new 
GetTotalCommandCount(); >=0i--)
      {
             new 
flags GetCommandFlags(i);
             if(
flags ACMD1AdminLevel[i] = 1;
             else if(
flags ACMD2AdminLevel[i] = 2;
             else if(
flags ACMD3AdminLevel[i] = 3;
             else if(
flags ACMD4AdminLevel[i] = 4;
             else if(
flags ACMD5AdminLevel[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 = (GetTotalCommandCount() - 1); >= 0i--) 
fixes that. I thought it was worth mentioning.
Reply
#45

GetTotalCommandCount() returns total number of commands. The highest id will be GetTotalCommandCount()-1.

Fixed in the topic. Thank You.
Reply
#46

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;
}
Reply
#47

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.
Reply
#48

I think change this;

CMD_SUCCESS

I prefer return 1;
Reply
#49

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.
Reply
#50

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.
Reply
#51

v0.3 beta 14th November
Changes:
  1. You can return integers in command functions (Usage of CMD_SUCCESS, CMD_FAILURE is made optional)
  2. Flags are now tagged variables ('flags' is the tag)
  3. 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!
Reply
#52

Quote:
Originally Posted by Yashas
Посмотреть сообщение
v0.3 beta 14th November
Changes:
  1. You can return integers in command functions (Usage of CMD_SUCCESS, CMD_FAILURE is made optional)
  2. Flags are now tagged variables ('flags' is the tag)
  3. 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.
Reply
#53

17th November beta

Changes:
  • Removed flags tag
This will probably be the final beta unless someone suggests something or reports a bug.

View Include

Full credits to Y_Less.
Reply
#54

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?
Reply
#55

Код:
return cmd_kiss(cid_kiss, playerid, "");
@Yashas: A great include with many features, very nice!
Reply
#56

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.
Reply
#57

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
Reply
#58

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.
Reply
#59

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 :/
Reply
#60

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)