[Include] Command Processor [Faster Than I-ZCMD!]
#21

Quote:
Originally Posted by jlalt
Посмотреть сообщение
Nevermind.
didn't read your reply properly lol.
Seems like you got my old version of the reply, you might want to consider reading the new one.

Thanks, by the way!
Reply
#22

Quote:
Originally Posted by Dice_
Посмотреть сообщение
How do I change unknown command message to modified one?
Here's an example, but you obviously have to make it send the message to players:

pawn Код:
public OnPlayerCommandPerformed(playerid, cmd[], params[], success)
{
    if(!success)
    {
        printf("The command /%s doesn't exist. Use /commands for a list of valid commands.", cmd);
    }
    return 1;
}
Reply
#23

You don't use OnPlayerCommandText with this include.
Reply
#24

1-Star dude.
Reply
#25

Quote:
Originally Posted by Pottus
Посмотреть сообщение
1-Star dude.
Why?
Reply
#26

Dude, due PAWN.CMD and sscanf(2) that realised as plugin, there is no more need in script-analog.
Reply
#27

The include is really cute.

Commands which use '_' (I guess even '@' too) won't work since '_' | 0x20 will change the character.


Quote:
Originally Posted by jlalt
Посмотреть сообщение
Can you add a function to check if a command exists?
ex:
PHP код:
CommandExist(cmd[]); 
returns 1 if exist 0 if not, it would be useful to block the existing commands from being used by non registered / logged in users while they yet can use the unknow commands....

btw Good job.
Код:
CommandExists(cmd[])
{
    static _cmd[32] = "cmd_";
    _cmd[4] = 0;
    strcat(_cmd, cmd);
    return (funcidx(_cmd) != -1)
}
Why do you need to know if the command exists to block a player from using commands? If the player uses a valid command, block it! If he types an invalid command, block it too!
Reply
#28

I updated the include once again, here are the new benchmarks:

Код:
This Include: 841
This Include: 848
This Include: 843
This Include: 846
This Include: 850
I did benchmarks between this include and Pawn.CMD, and these are the results:

Код:
This Include: 853 | 10/10/2016
This Include: 848 | 10/10/2016
This Include: 852 | 10/10/2016
This Include: 850 | 10/10/2016
This Include: 851 | 10/10/2016

Pawn.CMD: 1,446 | 10/10/2016
Pawn.CMD: 1,451 | 10/10/2016
Pawn.CMD: 1,460 | 10/10/2016
Pawn.CMD: 1,455 | 10/10/2016
Pawn.CMD: 1,449 | 10/10/2016
Check out the main post for the code used to benchmark both. This include seems to be considerably faster! Could anyone confirm this?

P.S. I didn't benchmark this include with Pawn.CMD before as PC_EmulateCommand wasn't executing commands for me, but then I noticed it only executes if a player is connected to the server (thanks to Stinged's code).

Based on those results, I doubt Pawn.CMD is any faster than I-ZCMD.

Quote:
Originally Posted by Yashas
Посмотреть сообщение
The include is really cute.

Commands which use '_' (I guess even '@' too) won't work since '_' | 0x20 will change the character.
I don't know or have seen a single person define commands like that before, so I guess it's more than okay. Not to mention tolower is vastly slow, and 0x60 doesn't do anything. Thanks, by the way!
Reply
#29

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
I updated the include once again, here are the new benchmarks:

Код:
This Include: 841
This Include: 848
This Include: 843
This Include: 846
This Include: 850
I did benchmarks between this include and Pawn.CMD, and these are the results:

Код:
This Include: 853 | 10/10/2016
This Include: 848 | 10/10/2016
This Include: 852 | 10/10/2016
This Include: 850 | 10/10/2016
This Include: 851 | 10/10/2016

Pawn.CMD: 1,446 | 10/10/2016
Pawn.CMD: 1,451 | 10/10/2016
Pawn.CMD: 1,460 | 10/10/2016
Pawn.CMD: 1,455 | 10/10/2016
Pawn.CMD: 1,449 | 10/10/2016
Check out the main post for the code used to benchmark both. This include seems to be considerably faster! Could anyone confirm this?

P.S. I didn't benchmark this include with Pawn.CMD before as PC_EmulateCommand wasn't executing commands for me, but then I noticed it only executes if a player is connected to the server (thanks to Stinged's code).

Based on those results, I doubt Pawn.CMD is any faster than I-ZCMD.



I don't know or have seen a single person define commands like that before, so I guess it's more than okay. Not to mention tolower is vastly slow, and 0x60 doesn't do anything. Thanks, by the way!
I don't think an include is faster than a plugin dude that's impossible.
Reply
#30

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
If you ever consider using flags as Crayder had suggested, it will come in handy to get all the commands of specific admin levels. Using properties seems ideal for such case.
I will take that into consideration, I'd like to see if my benchmarks with Pawn.CMD are correct first (assuming PC_EmulateCommand does the same process as using /test in-game for example).

Quote:
Originally Posted by Crystallize
Посмотреть сообщение
I don't think an include is faster than a plugin dude that's impossible.
This uses SSCANF, which is a plugin. It's a good alternative for people that want/use an include instead of a plugin, because like who doesn't use SSCANF?
Reply
#31

I LIKE IT KEEP IT UP!
Reply
#32

Код:
[07:29:10] [debug] Server crashed while executing Test.amx
[07:29:10] [debug] AMX backtrace:
[07:29:10] [debug] #0 native CallLocalFunction () from samp03svr
[07:29:10] [debug] #1 0000ba00 in public OnPlayerCommandText (playerid=4, cmdtext[]=@0015bcc8 "/test") at D:\gta san andreas\pawno\include\kcmd.inc:524
[07:29:10] [debug] Native backtrace:
[07:29:10] [debug] #0 f74289f0 in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () from plugins/crashdetect.so
[07:29:10] [debug] #1 f7421a62 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[07:29:10] [debug] #2 f7422764 in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[07:29:10] [debug] #3 f74246b4 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[07:29:10] [debug] #4 f742831d in ?? () from plugins/crashdetect.so
[07:29:10] [debug] #5 f777bd50 in __kernel_rt_sigreturn () from linux-gate.so.1
[07:29:10] [debug] #6 080dfcfc in ?? () from ./samp03svr
[07:29:10] [debug] #7 080950e4 in ?? () from ./samp03svr
[07:29:10] [debug] #8 f74234d3 in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[07:29:10] [debug] #9 0015bcc8 in ?? () from *—tчH•tчlё	lё	mє	lё	»	lј	$uч
Am I the only one who face this issue?
Reply
#33

I see why. This include does not check if the params is null. CallLocalFunction crashes when a null string is passed.

Any command which does not have params will crash the callback. The fix is to add

Код:
if(params[0] == '\0')
      return OnPlayerCommandPerformed(playerid, cmd[4], params, CallLocalFunction(cmd, "is", playerid, '\1'));
else
      return OnPlayerCommandPerformed(playerid, cmd[4], params, CallLocalFunction(cmd, "is", playerid, params));
Reply
#34

params used to be "\1" by default so if no parameters were entered, it would be left as it is. After updating, he forgot it so open the include and replace with:
Код:
new cmd[32] = "cmd_", params[126] = "\1";
Reply
#35

I got crash when execute any command, why?
Reply
#36

Quote:
Originally Posted by EnzoMetlc
Посмотреть сообщение
I got crash when execute any command, why?
CallLocalFunction crashes when you pass null strings.

Edit the include and do the change which Konstantinos stated until SickAttack officially updates the include.

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
params used to be "\1" by default so if no parameters were entered, it would be left as it is. After updating, he forgot it so open the include and replace with:
Код:
new cmd[32] = "cmd_", params[126] = "\1";
Reply
#37

Quote:
Originally Posted by Yashas
Посмотреть сообщение
CallLocalFunction crashes when you pass null strings.

Edit the include and do the change which Konstantinos stated until SickAttack officially updates the include.
I noticed that after comment haha Fixed! Thanks you and Konstantinos

I don't know why SickAttack doesn't noticed it
Reply
#38

Anyway is better then pwn cmd? or is on seconds place?
Reply
#39

Quote:
Originally Posted by Mister0
Посмотреть сообщение
Anyway is better then pwn cmd? or is on seconds place?
I dont think this is better than PAWN.Cmd. I don't believe those speed test results. PAWN.Cmd just can't be slower than any PAWN include. In fact, if you do the same function calls in PAWN code, it will still take less time that PAWN.Cmd takes (the time it took in the speed test). So it is simply unbelievable.
Reply
#40

Quote:
Originally Posted by Yashas
Посмотреть сообщение
I dont think this is better than PAWN.Cmd. I don't believe those speed test results. PAWN.Cmd just can't be slower than any PAWN include. In fact, if you do the same function calls in PAWN code, it will still take less time that PAWN.Cmd takes (the time it took in the speed test). So it is simply unbelievable.
maybe you have right, but is still better than any other like zcmd izcmd right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)