21.11.2011, 16:43
This time I want to introduce you an include, where you can use normal text inputs as commands which will be performed faster than using strcmp checks in OnPlayerText.
I've created this include because my heart bleeds if some peoples starts to script text string checks in OnPlayerText by using strcmp checks.
Example: http://pastebin.com/3sMRVaMY
Anyways this include is very easy to use, is not case sensitive, is very fast and can detect strings for params array.
How to use this include?
It's quite easy to use. (Idea from ZCMD)
You can use
or
or (not recommend)
Callback start:
Text string:
Player ID
Params string:
Example:
Even you can use the sscanf include/plugin (from ******) to parse strings to variables from params array.
https://sampforum.blast.hk/showthread.php?tid=120356
About returning values in txt_
If the callback exists, so returning 0 will deny executing TXT_OnPlayerText (muting) otherwise TXT_OnPlayerText will be also called!
Benchmark Tests
Results (Looping 10000 times through):
As we can see that my include is still faster than using strcmp checks in OnPlayerText.
Benchmark scripts:
http://solidfiles.com/d/8fc89eca14/
IF you find any another text processors, so please reply on this topic!
Credits:
Download btxt.inc from Solidfiles
Download btxt.inc from Pastebin
Regards: BigETI
I've created this include because my heart bleeds if some peoples starts to script text string checks in OnPlayerText by using strcmp checks.
Example: http://pastebin.com/3sMRVaMY
Anyways this include is very easy to use, is not case sensitive, is very fast and can detect strings for params array.
How to use this include?
It's quite easy to use. (Idea from ZCMD)
You can use
pawn Код:
TXT:hello(playerid, params[])
pawn Код:
TEXT:hello(playerid, params[])
pawn Код:
forward txt_hello(playerid, params[]);
public txt_hello(playerid, params[])
//...
Код:
TXT:hello(playerid, params[])
Код:
TXT:
Код:
hello
Код:
playerid
Код:
params[]
pawn Код:
TXT:test(playerid, params[])
{
new str[128];
format(str, 128, "You have wrote 'test' with following params: '%s'", params);
SendClientMessage(playerid, 0xFF0000FF, str);
return 0;
}
https://sampforum.blast.hk/showthread.php?tid=120356
About returning values in txt_
If the callback exists, so returning 0 will deny executing TXT_OnPlayerText (muting) otherwise TXT_OnPlayerText will be also called!
Benchmark Tests
Results (Looping 10000 times through):
Код:
BTXT without params: 60-65 ms BTXT with params (large params string): 252-263 ms strcmp methode without params: 19037 ms strcmp methode with params (same large params string as in BTXT check): 108984 ms
Benchmark scripts:
http://solidfiles.com/d/8fc89eca14/
IF you find any another text processors, so please reply on this topic!
Credits:
- Idea from ZCMD include (ZeeX)
- Hooking methode by ******
- Myself for creating this include
Download btxt.inc from Solidfiles
Download btxt.inc from Pastebin
Regards: BigETI