little question
#1

hey guys,

eehm i am making a small filterscript atm but i have heard of the things that in a gamemode i have to do return 1; and in filterscript return 0;??

is this true or can i just use return 1; in my filterscript for ANY callback?

greets niels
Reply
#2

In some callbacks, you need to return 0 to let other scripts handle it. (callbacks like: OnRconCommand, OnDialogResponse, and OnPlayerCommandText).
The OnPlayerKeyStateChange callback seems to act just opposite, so you'll need to return 1 to let filterscripts read from this callback.
Some callbacks' return value do something else; like OnPlayerText where you can return 0 to not allow the player to chat.
And then there are a callbacks that don't handle returns.

I think you should check the wiki before just returning 0 in all your callbacks in your filterscript.
To see a list of callbacks and what they return, check the wiki https://sampwiki.blast.hk/wiki/Category:Scripting_Callbacks.

EDIT: As callbacks like OnPlayerText first are called in the gamemode, I guess it doesn't matter if you return 0 in the filterscript, as the gamemode already made sure you send the message.
Reply
#3

from experimenting a lot with callbacks (Zcommands aswell, they act same somehow), i learned this:
the gamemode script gets loaded as first, it gets assigned the "trunk" callbacks, which should return something (1 for success, 0 for fail like UnKnownCommand).
assuming you load a filterscript now, it gets assigned a child instance on the main trunk:
Код:
1 - filterscript NOW gets procesed first, so a callback/zCMD can return nothing (not 0 nor 1), to let the gamemode..
0 - gamemode ..finally process the callback
i got one CMD:cmds(playerid,params[]) in my gamemode, returning 1; at its end.
now, ALL my filterscripts contain a CMD:cmds aswell, but they dont return anything. but they DO process things (SendClientMessage), until the gamemode prints out its stuff, then returns.
you can se and prove the order of the scripts printing out the /cmds by simply reading their order
ima make a screenshot now, where i loaded some filterscripts /cmds callbacks, pay attention to the order.

i guess that needs no more comments?
if iam doing it th wrong way, let me know, but as far as i can see, the server runs for days, and there are some players using the /cmds all time..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)