09.10.2016, 20:12
[Include] Command Processor [Faster Than I-ZCMD!]
09.10.2016, 23:08
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;
}
09.10.2016, 23:42
You don't use OnPlayerCommandText with this include.
10.10.2016, 00:59
1-Star dude.
10.10.2016, 01:23
10.10.2016, 04:55
Dude, due PAWN.CMD and sscanf(2) that realised as plugin, there is no more need in script-analog.
10.10.2016, 13:10
(
Последний раз редактировалось Yashas; 10.10.2016 в 14:42.
)
The include is really cute.
Commands which use '_' (I guess even '@' too) won't work since '_' | 0x20 will change the character.
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!
Commands which use '_' (I guess even '@' too) won't work since '_' | 0x20 will change the character.
Quote:
Can you add a function to check if a command exists?
ex: PHP код:
btw Good job. |
Код:
CommandExists(cmd[]) { static _cmd[32] = "cmd_"; _cmd[4] = 0; strcat(_cmd, cmd); return (funcidx(_cmd) != -1) }
10.10.2016, 15:58
I updated the include once again, here are the new benchmarks:
I did benchmarks between this include and Pawn.CMD, and these are the results:
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!
Код:
This Include: 841 This Include: 848 This Include: 843 This Include: 846 This Include: 850
Код:
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
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!
10.10.2016, 18:25
Quote:
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 Код:
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 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! |
10.10.2016, 18:37
Quote:
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.
|
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?
19.10.2016, 14:27
I LIKE IT KEEP IT UP!
22.10.2016, 07:39
Код:
[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ч
22.10.2016, 12:54
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
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));
22.10.2016, 13:06
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";
23.10.2016, 08:45
I got crash when execute any command, why?
23.10.2016, 08:50
CallLocalFunction crashes when you pass null strings.
Edit the include and do the change which Konstantinos stated until SickAttack officially updates the include.
Edit the include and do the change which Konstantinos stated until SickAttack officially updates the include.
23.10.2016, 09:07
Quote:
CallLocalFunction crashes when you pass null strings.
Edit the include and do the change which Konstantinos stated until SickAttack officially updates the include. |
I don't know why SickAttack doesn't noticed it
23.10.2016, 11:01
Anyway is better then pwn cmd? or is on seconds place?
23.10.2016, 11:13
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.
25.10.2016, 14:48
Quote:
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.
|
« Next Oldest | Next Newest »
Users browsing this thread: 1 Guest(s)