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

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
  • 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 need it for reassigned commands.

Код:
//abc is not an alternate command to xyz but has it's command function reassigned to that of xyz
CMD:xyz(cmdid, playerid, params[])
{
      if(cmdid == cid_xyz) //directly using variables is faster than using GetCommandID
      {
              //player used /xyz
      }
      else if(cmdid == cid_abc) //cid_xyz and cid_abc are defined by SmartCMD
      {
             //player used /abc
      }
      return CMD_SUCCESS;
}
I can get rid of cmdid and introduce a new function, GetCurrentCommandID but this would dirty the code.

I will have to think about it.

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
[*]Benchmark script is outdated (on first page) some functions are undefined[/LIST]
Will update soon.

[QUOTE=Nero_3D;3811977][*]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[/LIST]
I have no clue how YCMD works nor did I understand what you tried to say.

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
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
Will think about it.
Reply
#62

Does it support accent? I mean й, у, ő, etc.
Reply
#63

SmartCMD does not allow you to use such characters. If I am not wrong, y_commands support such characters.
Reply
#64

This is really nice man i have 2 questions:

- do i need to check IsPlayerConnected in every command i make or do you do that in include?
- can you tell me what is this: enum (*=2)

Ty
Reply
#65

SmartCMD does not have any internal IsPlayerConnected. You can add one in OnPlayerCommandReceived.

enum(*2) tells the compiler to ensure that every entry inside the enum has twice the value of the entry preceding it.
Reply
#66

How many of you are using it?
Is everything working?

What do you think about the command state system? Do you use it? Should it be removed? The state system does not allow you to manually assign states using the PAWN syntax. Anyone could manually set the state instead of this include providing such a system. This makes the command state system of SmartCMD redundant and harmful (because it does not let you use the PAWN syntax).

If you are using YSI, ensure that YSI is included before SmartCMD (Github Issue #5).
Reply
#67

Quote:
Originally Posted by Yashas
Посмотреть сообщение
How many of you are using it?
Is everything working?

What do you think about the command state system? Do you use it? Should it be removed? The state system does not allow you to manually assign states using the PAWN syntax. Anyone could manually set the state instead of this include providing such a system. This makes the command state system of SmartCMD redundant and harmful (because it does not let you use the PAWN syntax).

If you are using YSI, ensure that YSI is included before SmartCMD (Github Issue #5).
Started using it in all my projects the day you released it - it's a great include. I have yet to explore the territory of command states, so count that as not in use for me. The rest is working as intended.
Reply
#68

Quote:
Originally Posted by Yashas
Посмотреть сообщение
How many of you are using it?
Is everything working?

What do you think about the command state system? Do you use it? Should it be removed? The state system does not allow you to manually assign states using the PAWN syntax. Anyone could manually set the state instead of this include providing such a system. This makes the command state system of SmartCMD redundant and harmful (because it does not let you use the PAWN syntax).

If you are using YSI, ensure that YSI is included before SmartCMD (Github Issue #5).
I'm using it since the time of my last post in this topic (11/01/17) and didn't run into any problems so far. I don't know what are command states so i don't use it. If you meant flags yes i'm using those.
Reply
#69

I'm having issues that whenever a command has been disabled it can not be enabled.

This is the code I'm using, most of it has been directly copied from the tutorial and modified so it works properly in the gamemode.

PHP код:
forward CommandDisabled(cmdidplayeridparams[]);
public 
CommandDisabled(cmdidplayeridparams[])
{
    
SendErrorMessage(playerid, -1"The command has been disabled.");
    return 
1;
}
CMD<DISABLECMDS>:disablecmd(cmdidplayeridparams[])
{
    if(!
adminCheck(playerid5)) return 0;
    switch(
ReassignCommandFunction(GetCommandID(params), "CommandDisabled"))
    {
        case -
1: return SendClientMessage(playeridCOLOR_RED"The entered command does not exist.");
        case 
0: return SendClientMessage(playeridCOLOR_RED"The entered command is already disabled.");
        case 
1: return SendClientMessage(playeridCOLOR_WHITE"The entered command has been "COL_RED"disabled"COL_WHITE".");
    }
    return 
CMD_SUCCESS;
}
CMD<DISABLECMDS>:enablecmd(cmdidplayeridparams[])
{
    if(!
adminCheck(playerid5)) return 0;
    new 
cmd_func[MAX_FUNC_NAME], cid GetCommandID(params);
    
GetCommandFunctionName(cidcmd_func);
    
    switch(
ReassignCommandFunction(cidcmd_func))
    {
        case -
1: return SendClientMessage(playeridCOLOR_RED"The entered command does not exist.");
        case 
0: return SendClientMessage(playeridCOLOR_RED"The entered command is already enabled.");
        case 
1: return SendClientMessage(playeridCOLOR_WHITE"The entered command has been "COL_GREEN"enabled"COL_WHITE".");
    }
    return 
CMD_SUCCESS;

Reply
#70

Good Work.
Reply
#71

PHP код:
forward disabled(cmdidplayeridparams[])
public 
disabled(cmdidplayeridparams[])
{
      return 
SendClientMessage(playeridRED"The command has been disabled.");
}
CMD<ACMD>:disablecmd(cmdidplayeridparams[])
{
      switch(
ReassignCommandFunction(GetCommandID(params), "disabled"))
      {
             case -
1: return SendClientMessage(playeridRED"The entered command does not exist.");
             case 
0: return SendClientMessage(playeridRED"The entered command is already disabled.");
             case 
1: return SendClientMessage(playeridRED"The entered command has been disabled.");
      }
      return 
CMD_SUCCESS;
}
CMD<ACMD>:enablecmd(cmdidplayeridparams[])
{
      new 
cmd_func[MAX_FUNC_NAME], cid GetCommandID(params);
      
GetCommandFunctionName(cidcmd_func);

      switch(
ReassignCommandFunction(cidcmd_func))
      {
             case -
1: return SendClientMessage(playeridRED"The entered command does not exist.");
             case 
0: return SendClientMessage(playeridRED"The entered command is already enabled.");
             case 
1: return SendClientMessage(playeridRED"The entered command has been enabled.");
      }
      return 
CMD_SUCCESS;

This not working, i disable a command and i can't enable it back lol
Reply
#72

Quote:
Originally Posted by Banditul18
Посмотреть сообщение
PHP код:
forward disabled(cmdidplayeridparams[])
public 
disabled(cmdidplayeridparams[])
{
      return 
SendClientMessage(playeridRED"The command has been disabled.");
}
CMD<ACMD>:disablecmd(cmdidplayeridparams[])
{
      switch(
ReassignCommandFunction(GetCommandID(params), "disabled"))
      {
             case -
1: return SendClientMessage(playeridRED"The entered command does not exist.");
             case 
0: return SendClientMessage(playeridRED"The entered command is already disabled.");
             case 
1: return SendClientMessage(playeridRED"The entered command has been disabled.");
      }
      return 
CMD_SUCCESS;
}
CMD<ACMD>:enablecmd(cmdidplayeridparams[])
{
      new 
cmd_func[MAX_FUNC_NAME], cid GetCommandID(params);
      
GetCommandFunctionName(cidcmd_func);
      switch(
ReassignCommandFunction(cidcmd_func))
      {
             case -
1: return SendClientMessage(playeridRED"The entered command does not exist.");
             case 
0: return SendClientMessage(playeridRED"The entered command is already enabled.");
             case 
1: return SendClientMessage(playeridRED"The entered command has been enabled.");
      }
      return 
CMD_SUCCESS;

This not working, i disable a command and i can't enable it back lol
I'm having the same issues, as was described a while ago in my post.
Reply
#73

I don't check the forums often.

I'll get to know about the issues through the github repo much faster than here.

I'm sorry for the late response though. I'll look into the matter and find a suitable fix.
Reply
#74

is there any way to make special letter support for the commands or the alternate? (i mean й,б,ű etc)
the script dont have to distinguish the a and 'б' just let it work
Reply
#75

Fix for Issue #6 (ReassignCommandFunction)

Working Branch = i6-fix

Include with proposed fix can be found in the above branch (direct link)

If nobody faces any issue, I'll merge it into the master branch.

TL;DR (or I don't know what you are talking about):
There was a bug. The bug has been fixed in this version of the include (which is not the main include). You can use it. Report if you find issues. If no issues are found, I'll move the fix to the main include.
Reply
#76

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Fix for Issue #6 (ReassignCommandFunction)

Working Branch = i6-fix

Include with proposed fix can be found in the above branch (direct link)

If nobody faces any issue, I'll merge it into the master branch.

TLR (or I don't know what you are talking about):
There was a bug. The bug has been fixed in this version of the include (which is not the main include). You can use it. Report if you find issues. If no issues are found, I'll move the fix to the main include.
Код:
../pawno/include\SmartCMD\smartcmd.inc(1308) : warning 217: loose indentation
Other than that, going to merge it and test it right now.
Reply
#77

Has anyone tried the fix?
Reply
#78

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Has anyone tried the fix?
I have tried the fix, it works.

But I haven't tested the fix extensively.
Reply
#79

Quote:
Originally Posted by dani16
Посмотреть сообщение
Gooooooooooood woooork. Is there a counter that can specify how long it takes to perform a command?
You can use the profiler plugin to find out how long your commands take to execute.

If you want to find out the number of times a command is used, you can use the `cmdid` parameter of `OnPlayerCommandReceived` as the index for an array which keeps counting.
Reply
#80

Currently the default flags (CMD_DEFAULT_FLAG) apply only to the commands for which the flags haven't been given explicitly.

Should it apply to all commands irrespective of whether flags have been given or not? This can be done by ORing with the flags which have been given explicitly with the default flags but this creates an issue if the flags aren't being used as bitfields. In that case, the flags will be ORed with 0 which won't mess with the flags.

What do you prefer?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)