Calling a callback by myself? - 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: Calling a callback by myself? (
/showthread.php?tid=516260)
Calling a callback by myself? -
dusk - 30.05.2014
So I found myself in a situation where calling a callback would be useful. The situation: when a player disconnects, if he's in a mini-game his partner should get a kill, so I could just call OnPlayerDeath.
My question is: is that good practice?
I believe I read somewhere that you should not do this... But it's just a function , so I'm not sure.
Re: Calling a callback by myself? -
Riwerry - 30.05.2014
I am not sure, if this will work but you can use function
CallLocalFunction
Example, which you can try:
pawn Код:
//public OnPlayerDeath(playerid, killerid, reason)
CallLocalFunction("OnPlayerDeath", "ii", InsertHereYourArguments) //first i = playerid, second i = killerid, third i = ID of the reason
Re: Calling a callback by myself? -
dusk - 30.05.2014
No, I'm sure it will work.
But I just want to know if it's a good/common thing to do.
Re: Calling a callback by myself? -
RajatPawar - 30.05.2014
It will work, yes. But AFAIK, it's not common practice - it
is used but IMO, you should try to stay as non-interfering as possible with SA-MP callbacks. If it's that important, you can just use your own callback. If the problem is copying code over two times to two different callbacks, then the code is the problem - it should have been a function. (Up for a discussion)