SA-MP Forums Archive
Hook 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)
+--- Thread: Hook ZCMD commands (/showthread.php?tid=608979)



Hook ZCMD commands - Jonesy96 - 07.06.2016

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


Re: Hook ZCMD commands - saffierr - 07.06.2016

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.


Re: Hook ZCMD commands - Jonesy96 - 07.06.2016

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.


Re: Hook ZCMD commands - Vince - 07.06.2016

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.


Re: Hook ZCMD commands - PrO.GameR - 07.06.2016

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.


Re: Hook ZCMD commands - Misiur - 07.06.2016

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
}