Counting ZCMD Commands. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Counting ZCMD Commands. (
/showthread.php?tid=217373)
Counting ZCMD Commands. -
Zh3r0 - 27.01.2011
Is there a really simple way to count ZCMD commands? Since ZCMD uses some defines to transform them into public.
I tried many ways, but giving me errors.
This is what a zcmd commands starts
pawn Код:
#define COMMAND:%1(%2) forward cmd_%1(%2); \
public cmd_%1(%2)
Any idea how can i insert a Var++ into that? So it counts the commands ?
Re: Counting ZCMD Commands. -
Gabe - 27.01.2011
pawn Код:
#define COMMAND:%1(%2) forward cmd_%1(%2); \
zcount++; \
public cmd_%1(%2)
Might work ( I am not sure how the code outside of the functions are run), but you should really use ******'s scripting fuctions to get the count.
Re: Counting ZCMD Commands. -
Zh3r0 - 27.01.2011
Quote:
Originally Posted by Gabe
pawn Код:
#define COMMAND:%1(%2) forward cmd_%1(%2); \ zcount++; \ public cmd_%1(%2)
Might work ( I am not sure how the code outside of the functions are run), but you should really use ******'s scripting fuctions to get the count.
|
Yeah tried even that, even putting it into { } ( ) < >, gave me couple of errors. Even using return Cmds++;
Same.
I can't reallay use ycmds's count system since it is really god damn complicated.
Re: Counting ZCMD Commands. -
Gabe - 27.01.2011
You know that all
pawn Код:
#define COMMAND:%1(%2) forward cmd_%1(%2); \
zcount++; \
public cmd_%1(%2)
Does is search the entire script for every instance of "COMMAND:%1(%2)"
And replace it with "forward cmd_%1(%2);
zcount++;
public cmd_%1(%2)"
Re: Counting ZCMD Commands. -
Zh3r0 - 27.01.2011
Quote:
Originally Posted by Gabe
You know that all
pawn Код:
#define COMMAND:%1(%2) forward cmd_%1(%2); \ zcount++; \ public cmd_%1(%2)
Does is search the entire script for every instance of "COMMAND:%1(%2)"
And replace it with "forward cmd_%1(%2);
zcount++;
public cmd_%1(%2)"
|
Yes i really know that, but it's not like i'm going to add Cmds++ on every CMD: public....
Re: Counting ZCMD Commands. -
Zh3r0 - 28.01.2011
Still didn't manage to solve this. Anyone?
Re: Counting ZCMD Commands. -
__ - 28.01.2011
Tested and works.
pawn Код:
#include <a_samp>
#include <zcmd>
#include <YSI/y_scripting>
main() {
}
public OnGameModeInit() {
printf("Commands: %d", countCommands());
return 1;
}
CMD:test(playerid, params[]) {
print("lol");
}
stock countCommands() {
new
cmdBuffer[32],
commandCount;
for(new it = 0; it < Scripting_GetPublicsCount(); it++) {
Scripting_GetPublic(it, cmdBuffer);
if(!strcmp(cmdBuffer, "cmd_", false, 4)) {
commandCount++;
}
}
return commandCount;
}
You need YSI/y_scripting for this to work, you can remove the OnGameModeInit callback as it was a test to verify it compiled.
Re: Counting ZCMD Commands. -
Zh3r0 - 28.01.2011
Thank you! I also tought of something like this but didn't actually knew how to.