Counting ZCMD Commands.
#1

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 ?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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)"
Reply
#5

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....
Reply
#6

Still didn't manage to solve this. Anyone?
Reply
#7

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.
Reply
#8

Thank you! I also tought of something like this but didn't actually knew how to.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)