SA-MP Forums Archive
How to call a public callback? - 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: How to call a public callback? (/showthread.php?tid=338160)



How to call a public callback? - JaKe Elite - 29.04.2012

Hey i want to know how scripters call their made callback

Ex.

OnPlayerEnterWater - If player is in water this function is called

How can i call my public callback? I'm planning to create a include.


Re: How to call a public callback? - warcodes_ - 29.04.2012

Timer.


Re: How to call a public callback? - JaKe Elite - 29.04.2012

No, i mean without timer, they don't use timer they just call it

Ex.

When i'm in water OnPlayerEnterWater is called but maybe, maybe they use one?


Re: How to call a public callback? - Niko_boy - 29.04.2012

SetTimer ; SetTimerEx
CallLocalFunction and CallRemoteFunction for mor einfo please visit some tutorials on samp wiki or forums

Edit:
for water part i guess they use IsPlayerInRangeOfPoint or something liek that and use in OnPlayerUpdate or a repeating timer callback ; and check the player if he is there it will call function either by a timer or calllocal / remote fucntion


Re: How to call a public callback? - warcodes_ - 29.04.2012

Without a timer

=

Make your callback a stock, and call it w/e you like.


Re: How to call a public callback? - JaKe Elite - 29.04.2012

Thanks both of you but i cannot rep you for now i will say 'Thank you'


Re: How to call a public callback? - PrawkC - 29.04.2012

It is not possible to have a callback be called without doing it yourself, IE setting a check in a timer or using Onplayerupdate


Re: How to call a public callback? - Jonny5 - 29.04.2012

theirs also
OnPlayerStateChange


and i think they check for water by checking the animations the player currently has,


Re: How to call a public callback? - JaKe Elite - 29.04.2012

Hey one more question i'm creating a call back that checks something Ex.

pawn Код:
forward OnPlayerDancingAnim(playerid, animlib[], animname[])
public OnPlayerDancingAnim(playerid, animlib[], animname[])
{
     if(animlib == "DANCING")
     {
        if(animname == "dnce_M_a")
        {
             //codes
        }
     }
     return 1;
}
it give me error like

Код:
error 033: array must be indexed (variable "animlib")
error 033: array must be indexed (variable "animname")
and is it ok to call the public call back with CallRemoteFunction in OnPlayerUpdate by checking if player is playing an animation?


Re: How to call a public callback? - Ash. - 29.04.2012

Quote:
Originally Posted by Romel
Посмотреть сообщение
Hey one more question i'm creating a call back that checks something Ex.

pawn Код:
forward OnPlayerDancingAnim(playerid, animlib[], animname[])
public OnPlayerDancingAnim(playerid, animlib[], animname[])
{
     if(animlib == "DANCING")
     {
        if(animname == "dnce_M_a")
        {
             //codes
        }
     }
     return 1;
}
it give me error like

Код:
error 033: array must be indexed (variable "animlib")
error 033: array must be indexed (variable "animname")
and is it ok to call the public call back with CallRemoteFunction in OnPlayerUpdate by checking if player is playing an animation?
You can't compare strings using the == operator. You have to use strcmp (string compare) in order to compare strings.

Your final question: Yes, it is okay, however you should ensure that it is only called once.