Best approach to trigger callback between gamemode and filterscript -
sheenidgs - 26.12.2017
I have a gamemode and a filterscript for account system. In my account system, it has a callback named OnPlayerLoggedIn. This callback will called if a player has been logged in successfully. Then, I want create this filterscript that can be integrated with callbacks and functions. This is what I want:
- Player connected to the server
- Player ask for password
- If matched, player logged in and callback OnPlayerLoggedIn called from account system.
- The loaded filterscripts and gamemode also called after the player logged in.
What is the best approach for my case? I've think about ALS, y_hooks, and y_als. But I've seen it on YSI Wikia and it has examples just for include. Maybe I didn't understand at all how those works.
Re: Best approach to trigger callback between gamemode and filterscript -
Dayrion - 26.12.2017
I think you can simply use CallRemoteFunction.
(Example) I wanted to warn admins (with an AdmWarn obivously) when something specific happens in my FS, so I decied to do this:
PHP код:
Local_AdmWarn(message[], {Float,_}:...)
{
new buffer[244];
format(buffer, sizeof(buffer), message, ___1); // using y_va
print(message);
return CallRemoteFunction("SendInternalMessage", "is", 0, buffer);
}
And in the gamemode:
PHP код:
SendInternalMessage(message_type, const message[])
{
if(!message_type)
return AdmWarn(message);
else
return AdmCmd(message);
}
Re: Best approach to trigger callback between gamemode and filterscript -
sheenidgs - 26.12.2017
Quote:
Originally Posted by Dayrion
I think you can simply use CallRemoteFunction.
(Example) I wanted to warn admins (with an AdmWarn obivously) when something specific happens in my FS, so I decied to do this:
PHP код:
Local_AdmWarn(message[], {Float,_}:...)
{
new buffer[244];
format(buffer, sizeof(buffer), message, ___1); // using y_va
print(message);
return CallRemoteFunction("SendInternalMessage", "is", 0, buffer);
}
And in the gamemode:
PHP код:
SendInternalMessage(message_type, const message[])
{
if(!message_type)
return AdmWarn(message);
else
return AdmCmd(message);
}
|
I see.... I've thinked about CallRemoteFunction too, but I didn't try it yet. I'll try now
Re: Best approach to trigger callback between gamemode and filterscript -
Dayrion - 26.12.2017
Quote:
Originally Posted by sheenidgs
I see.... I've thinked about CallRemoteFunction too, but I didn't try it yet. I'll try now 
|
Alright, let me know how it's going on.
Merry christmas (a bit late)
Re: Best approach to trigger callback between gamemode and filterscript -
sheenidgs - 26.12.2017
Quote:
Originally Posted by Dayrion
Alright, let me know how it's going on.
Merry christmas (a bit late) 
|
I've tested it and it works. But I'll keep find the best approach because I want create a filterscript that can be integrated with other scripts. Thanks anyway for your help
Re: Best approach to trigger callback between gamemode and filterscript -
Amagida - 26.12.2017
Quote:
Originally Posted by Dayrion
PHP код:
Local_AdmWarn(message[], {Float,_}:...)
{
new buffer[244];
format(buffer, sizeof(buffer), message, ___1); // using y_va
print(message);
return CallRemoteFunction("SendInternalMessage", "is", 0, buffer);
}
|
If you are using y_va, theres no need for
{Float,_}:... .
You can use
va_args<>.
PHP код:
Local_AdmWarn(message[], va_args<>)
{
print(message);
return CallRemoteFunction("SendInternalMessage", "is", 0, va_return(message, va_start<1>);
}
Re: Best approach to trigger callback between gamemode and filterscript -
Dayrion - 26.12.2017
Quote:
Originally Posted by Amagida
If you are using y_va, theres no need for {Float,_}:... .
You can use va_args<>.
PHP код:
Local_AdmWarn(message[], va_args<>)
{
print(message);
return CallRemoteFunction("SendInternalMessage", "is", 0, va_return(message, va_start<1>);
}
|
Ye'p, completly forget about va_return !