Best approach to trigger callback between gamemode and filterscript
#1

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.
Reply
#2

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(buffersizeof(buffer), message___1); // using y_va
    
print(message);
    return 
CallRemoteFunction("SendInternalMessage""is"0buffer);

And in the gamemode:
PHP код:
SendInternalMessage(message_type, const message[])
{
    if(!
message_type)
        return 
AdmWarn(message);
    else
        return 
AdmCmd(message);

Reply
#3

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(buffersizeof(buffer), message___1); // using y_va
    
print(message);
    return 
CallRemoteFunction("SendInternalMessage""is"0buffer);

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
Reply
#4

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)
Reply
#5

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
Reply
#6

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
PHP код:
Local_AdmWarn(message[], {Float,_}:...)
{
    new 
buffer[244];
    
format(buffersizeof(buffer), message___1); // using y_va
    
print(message);
    return 
CallRemoteFunction("SendInternalMessage""is"0buffer);

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"0va_return(messageva_start<1>);

Reply
#7

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"0va_return(messageva_start<1>);

Ye'p, completly forget about va_return !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)