Hook ZCMD commands
#1

Hi All,

I'm currently using y_hooks.inc. Is there a way i can hook a ZCMD command? For example, I have /enter. If I wanted to have /enter in say my bank include, and then also in my hospital include. Is there a way that I can hook the command, because obviously it's going to be the same /enter, just searching to see if the player is at different coordinates.

Any ideas?

Thanks
Reply
#2

As you stated, just get the player's XYZ and check if it matches a bank or hospital with a radius of 5.
No need to hook it.
But to get back to your question, I don't know.
Reply
#3

Quote:
Originally Posted by saffierr
Посмотреть сообщение
As you stated, just get the player's XYZ and check if it matches a bank or hospital with a radius of 5.
No need to hook it.
But to get back to your question, I don't know.
I could do it that way, but Id rather hook it if there is a way to do so. That way I can have the respective /enter command in its' respective include. Rather than just having 1 /enter command with loads of checks for different coords. I'd rather have the /enter for the hospital within the hospital include, and the /enter for the bank seperate, in the bank include.
Reply
#4

Normally, returning 0 in OnPlayerCommandText transfers control of the callback to the next script (unless there's none, in which case the generic "unknown command" message is sent). But I don't know how ZCMD handles this. It might be worth a try to simply return 0 if the player isn't in the right location.
Reply
#5

I'm pretty sure there is no way to hook it, but technically you can chain it yourself, in the end of each enter command you call the next command by cmd_bankenter(playerid,params) or sth like that.

Now that I think about it you could give hooking method 7 a shot, but instead of forwarding and returning the CMD name directly, you should use cmd_ before calling it.
it might work.
Reply
#6

I usually do it something like
pawn Код:
YCMD:enter(playerid, params[], help) {
    call OnPlayerEnter(playerid);

    return 1;
}
Then in includes
pawn Код:
hook OnPlayerEnter(playerid) {
    if(!IWantThisToBeCalled) return Y_HOOKS_CONTINUE_RETURN_1;

    //We open a door or shit
    return Y_HOOKS_BREAK_RETURN_1; //We break the chain so other callbacks are not called
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)