AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved read data from events and hook 2 things (https://forums.alliedmods.net/showthread.php?t=316776)

nacknic 06-09-2019 14:29

read data from events and hook 2 things
 
for example 1:
Code:

register_event( "SendAudio", "t_win", "a", "2=%!MRAD_terwin" );
register_event( "SendAudio","ct_win", "a", "2=%!MRAD_ctwin" );

example 2 hook them both:
Code:

register_event( "SendAudio", "win", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin" );
so, how i read 2=%!MRAD_terwin or 2=%!MRAD_ctwin ?
read_data( 2 ) ?

Bugsy 06-09-2019 15:54

Re: read data from events and hook 2 things
 
Why don't you try it and find out for yourself?

thEsp 06-09-2019 16:55

Re: read data from events and hook 2 things
 
Determine whether read_data(2) is 1 or 2.. via switch statement. That's it all.

nacknic 06-09-2019 18:47

Re: read data from events and hook 2 things
 
Quote:

Originally Posted by thEsp (Post 2655045)
Determine whether read_data(2) is 1 or 2.. via switch statement. That's it all.

i did simple thing to check:
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>

public plugin_init( )
        register_event( "SendAudio", "win", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin" );
       
public win( )
{
        new sz[ 51 ];
        client_print( 0, print_chat, "%S", read_data( 2, sz, charsmax( sz ) );
}

its works, show me !MRAD_ctwin when ct win and !MRAD_terwin when t win.

now when i try to check like that, not works, i know its because '%' in %!MRAD_terwin" and %!MRAD_cterwin", but i not know what to do to check , can you help me please ?
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>

public plugin_init( )
        register_event( "SendAudio", "win", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin" );
       
public win( )
{
        new sz[ 51 ];
        read_data( 2, sz, charsmax( sz ) );
       
        if ( equal( sz, "%!MRAD_terwin" ) )
                client_print( 0, print_chat, "T" );
        else if ( equal( sz, "%!MRAD_cterwin" ) )
                client_print( 0, print_chat, "CT" );
}


Bugsy 06-09-2019 19:08

Re: read data from events and hook 2 things
 
Not sure if the % is or isn't causing an issue here. Try checking only the part of the string with the team name:
PHP Code:

#include <amxmodx>

public plugin_init( ) 
    
register_event"SendAudio""win""a""2=%!MRAD_terwin""2=%!MRAD_ctwin" );
    
public 
win( )
{
    new 
sz16 ];
    
read_data2szcharsmaxsz ) );
    
    if ( 
equalsz], "ter" ) , )
        
client_print0print_chat"T" );
    else
        
client_print0print_chat"CT" );



nacknic 06-09-2019 23:35

Re: read data from events and hook 2 things
 
Quote:

Originally Posted by Bugsy (Post 2655058)
Not sure if the % is or isn't causing an issue here. Try checking only the part of the string with the team name:
PHP Code:

#include <amxmodx>

public plugin_init( ) 
    
register_event"SendAudio""win""a""2=%!MRAD_terwin""2=%!MRAD_ctwin" );
    
public 
win( )
{
    new 
sz16 ];
    
read_data2szcharsmaxsz ) );
    
    if ( 
equalsz], "ter" ) , )
        
client_print0print_chat"T" );
    else
        
client_print0print_chat"CT" );



hi, i learn from you that i can sub-string in equal operator, i did this, and work 100% [thank you] i write my code:
Code:

#include <amxmodx>

public plugin_init( )
    register_event( "SendAudio", "win", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin" );
   
public win( )
{
    new sz[ 16 ];
    read_data( 2, sz, charsmax( sz ) );
   
    if ( equal( sz[ 1 ], "!MRAD_terwin" ) )
        client_print( 0, print_chat, "T" );
    else if ( equal( sz[ 1 ], "!MRAD_ctwin" ) )
        client_print( 0, print_chat, "CT" );
}

when i start sz[ 1 ], its skipping the all '%' problem


All times are GMT -4. The time now is 17:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.