Raised This Month: $18 Target: $400
 4% 

MSG_ONE or MSG_ONE_UNRELIABLE with no target entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-20-2020 , 11:27   MSG_ONE or MSG_ONE_UNRELIABLE with no target entity
Reply With Quote #1

I have some problems with one plugin, does anyone know how to fix this?

PHP Code:
#include < amxmodx >
#include < hamsandwich >

#define IsValidPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

new g_bConnected33 ] = false;
new 
g_bAlive33 ] = false;
new 
g_iTeam33 ];
new 
g_szName33 ][ 32 ];
new 
boolg_bHasPrefix33 ] = false;

new 
g_iMessageChat;
new 
g_iMaxPlayers;

public 
plugin_init( ) {
    
register_plugin"VIP: Chat Prefix for user info""2.0""Milutinke (ByM)" );
    
    
RegisterHamHam_Spawn"player""fw_HamPlayerSpawnPost", .Post true );
    
    
register_event"TeamInfo""fw_EventTeamInfo""a" );
    
    
register_clcmd"say""fw_ChatPrefix" );
    
register_clcmd"say_team""fw_ChatPrefixTeam" );
    
    
g_iMessageChat get_user_msgid"SayText" );
    
g_iMaxPlayers get_maxplayers( );
}

public 
fw_HamPlayerSpawnPostiPlayer ) {
    
g_bConnectediPlayer ] = boolis_user_connectediPlayer );
    
g_bAliveiPlayer ] = boolis_user_aliveiPlayer );
}

public 
client_connectiPlayer ) {
    
g_bHasPrefixiPlayer ] = false;
    
g_bConnectediPlayer ] = false;
    
g_bAliveiPlayer ] = false;
    
g_iTeamiPlayer ] = 0;
}

public 
client_putinserveriPlayer 
    
g_bConnectediPlayer ] = true;

public 
client_authorizediPlayer ) {
    
get_user_nameiPlayerg_szNameiPlayer ], charsmaxg_szName[ ] ) );
    
    new 
szInfo32 ];
    if( 
get_user_infoiPlayer"vip"szInfocharsmaxszInfo ) ) ) {
        
trimszInfo );
        
        if( 
szInfo] == EOS )
            return;
            
        
g_bHasPrefixiPlayer ] = boolequalszInfo"1" );
    }
}

public 
client_disconnectiPlayer ) {
    
g_szNameiPlayer ][ ] = EOS;
    
g_bHasPrefixiPlayer ] = false;
    
g_bConnectediPlayer ] = false;
    
g_bAliveiPlayer ] = false;
    
g_iTeamiPlayer ] = 0;
}

public 
client_infochangediPlayer ) {
    new 
szName32 ];
    
get_user_nameiPlayerszNamecharsmaxszName ) );
    
    if( !
equalg_szNameiPlayer ], szName ) )
        
copyg_szNameiPlayer ], charsmaxg_szName[ ] ), szName );
}

public 
fw_EventTeamInfo( ) {
    new 
iPlayer read_data);
    
    if( !
g_bConnectediPlayer ] )
        return 
PLUGIN_CONTINUE;
    
    new 
szTeam12 ];
    
read_data2szTeamcharsmaxszTeam ) );
    
    switch( 
szTeam] ) {
        case 
'T' :  g_iTeamiPlayer ] = 1;
        case 
'C' :  g_iTeamiPlayer ] = 2;
        case 
'S' :  g_iTeamiPlayer ] = 3;
        default: 
g_iTeamiPlayer ] = 4;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
fw_ChatPrefixiPlayer ) {
    if( !
g_bConnectediPlayer ] || !IsValidPlayeriPlayer ) )
        return 
2;
        
    static 
szSaid191 ];
    
read_argsszSaidcharsmaxszSaid ) );
    
remove_quotesszSaid );
    
    return 
ChatPrefixiPlayerszSaidcharsmaxszSaid ), false );
}

public 
fw_ChatPrefixTeamiPlayer ) {
    if( !
g_bConnectediPlayer ] || !IsValidPlayeriPlayer ) )
        return 
2;
        
    static 
szSaid191 ];
    
read_argsszSaidcharsmaxszSaid ) );
    
remove_quotesszSaid );
    
    return 
ChatPrefixiPlayerszSaidcharsmaxszSaid ), true );
}

public 
ChatPrefix( const iPlayerszSaid[ ], const iSaidLength, const bTeamChat ) {
    static 
szMessage191 ], iPlayers;

    if( !
szSaid] )
        return 
2;
    
    
formatexszMessagecharsmaxszMessage ), "%s!t%s: !n%s"g_bHasPrefixiPlayer ] ? "!g[VIP] " ""g_szNameiPlayer ], szSaid );
    
replace_allszMessagecharsmaxszMessage ), "%""" );
    
replace_allszMessagecharsmaxszMessage ), "!n""^x01" );
    
replace_allszMessagecharsmaxszMessage ), "!r""^x02" );
    
replace_allszMessagecharsmaxszMessage ), "!g""^x04" );
    
replace_allszMessagecharsmaxszMessage ), "!t""^x03" );
    
trimszMessage );
    
    for( 
iPlayers 1iPlayers <= g_iMaxPlayersiPlayers ++ ) {
        if( !
g_bConnectediPlayer ] || ( !g_bAliveiPlayer ] && g_bAliveiPlayers ] ) )
            continue;
        
        if( 
bTeamChat ) {
            if( 
get_user_teamiPlayer ) != get_user_teamiPlayers ) )
                continue;
        }
        
        
message_beginMSG_ONEg_iMessageChat, { 00}, iPlayers );
        
write_byteiPlayer );
        
write_stringszMessage );
        
message_end( );
    }
    
    return 
2;

It's a plugin that gives you [VIP] prefix when someone hes setinfo set for "vip 1"
supertrio17 is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 05-20-2020 , 11:49   Re: MSG_ONE or MSG_ONE_UNRELIABLE with no target entity
Reply With Quote #2

Code:
#include < amxmodx > #include < hamsandwich > #define IsValidPlayer(%0)   ( 1 <= %0 <= g_iMaxPlayers ) new g_bConnected[ 33 ] = false; new g_bAlive[ 33 ] = false; new g_iTeam[ 33 ]; new g_szName[ 33 ][ 32 ]; new bool: g_bHasPrefix[ 33 ] = false; new g_iMessageChat; new g_iMaxPlayers; public plugin_init( ) {     register_plugin( "VIP: Chat Prefix for user info", "2.0", "Milutinke (ByM)" );         RegisterHam( Ham_Spawn, "player", "fw_HamPlayerSpawnPost", .Post = true );         register_event( "TeamInfo", "fw_EventTeamInfo", "a" );         register_clcmd( "say", "fw_ChatPrefix" );     register_clcmd( "say_team", "fw_ChatPrefixTeam" );         g_iMessageChat = get_user_msgid( "SayText" );     g_iMaxPlayers = get_maxplayers( ); } public fw_HamPlayerSpawnPost( iPlayer ) {     g_bConnected[ iPlayer ] = bool: is_user_connected( iPlayer );     g_bAlive[ iPlayer ] = bool: is_user_alive( iPlayer ); } public client_connect( iPlayer ) {     g_bHasPrefix[ iPlayer ] = false;     g_bConnected[ iPlayer ] = false;     g_bAlive[ iPlayer ] = false;     g_iTeam[ iPlayer ] = 0; } public client_putinserver( iPlayer )     g_bConnected[ iPlayer ] = true; public client_authorized( iPlayer ) {     get_user_name( iPlayer, g_szName[ iPlayer ], charsmax( g_szName[ ] ) );         new szInfo[ 32 ];     if( get_user_info( iPlayer, "vip", szInfo, charsmax( szInfo ) ) ) {         trim( szInfo );                 if( szInfo[ 0 ] == EOS )             return;                     g_bHasPrefix[ iPlayer ] = bool: equal( szInfo, "1" );     } }    #if AMXX_VERSION_NUM < 183; public client_disconnect(iPlayer)     #else public client_disconnected(iPlayer)     #endif {     g_szName[ iPlayer ][ 0 ] = EOS;     g_bHasPrefix[ iPlayer ] = false;     g_bConnected[ iPlayer ] = false;     g_bAlive[ iPlayer ] = false;     g_iTeam[ iPlayer ] = 0; } public client_infochanged( iPlayer ) {     new szName[ 32 ];     get_user_name( iPlayer, szName, charsmax( szName ) );         if( !equal( g_szName[ iPlayer ], szName ) )         copy( g_szName[ iPlayer ], charsmax( g_szName[ ] ), szName ); } public fw_EventTeamInfo( ) {     new iPlayer = read_data( 1 );         if( !g_bConnected[ iPlayer ] )         return PLUGIN_CONTINUE;         new szTeam[ 12 ];     read_data( 2, szTeam, charsmax( szTeam ) );         switch( szTeam[ 0 ] ) {         case 'T' :  g_iTeam[ iPlayer ] = 1;         case 'C' :  g_iTeam[ iPlayer ] = 2;         case 'S' :  g_iTeam[ iPlayer ] = 3;         default: g_iTeam[ iPlayer ] = 4;     }         return PLUGIN_CONTINUE; } public fw_ChatPrefix( iPlayer ) {     if( is_vip_by_info(iPlayer ))     if( !g_bConnected[ iPlayer ] || !IsValidPlayer( iPlayer ) )         return 2;             static szSaid[ 191 ];     read_args( szSaid, charsmax( szSaid ) );     remove_quotes( szSaid );         return ChatPrefix( iPlayer, szSaid, charsmax( szSaid ), false ); } public fw_ChatPrefixTeam( iPlayer ) {     if( !g_bConnected[ iPlayer ] || !IsValidPlayer( iPlayer ) )         return 2;             static szSaid[ 191 ];     read_args( szSaid, charsmax( szSaid ) );     remove_quotes( szSaid );         return ChatPrefix( iPlayer, szSaid, charsmax( szSaid ), true ); } public ChatPrefix( const iPlayer, szSaid[ ], const iSaidLength, const bTeamChat ) {     static szMessage[ 191 ], iPlayers;     if( !szSaid[ 0 ] )         return 2;     formatex( szMessage, charsmax( szMessage ), "%s!t%s: !n%s", g_bHasPrefix[ iPlayer ] ? "!g[VIP] " : "", g_szName[ iPlayer ], szSaid );     replace_all( szMessage, charsmax( szMessage ), "%", "" );     replace_all( szMessage, charsmax( szMessage ), "!n", "^x01" );     replace_all( szMessage, charsmax( szMessage ), "!r", "^x02" );     replace_all( szMessage, charsmax( szMessage ), "!g", "^x04" );     replace_all( szMessage, charsmax( szMessage ), "!t", "^x03" );     trim( szMessage );         for( iPlayers = 1; iPlayers <= g_iMaxPlayers; iPlayers ++ ) {         if( !g_bConnected[ iPlayer ] || ( !g_bAlive[ iPlayer ] && g_bAlive[ iPlayers ] ) )             continue;                 if( bTeamChat ) {             if( get_user_team( iPlayer ) != get_user_team( iPlayers ) )                 continue;         }         if(is_user_connected(iPlayers)){         message_begin( MSG_ONE_UNRELIABLE, g_iMessageChat, { 0, 0, 0 }, iPlayers );         write_byte( iPlayer );         write_string( szMessage );         message_end( );         }     }     return 2; } stock bool:is_vip_by_info(iPlayer) {     static szInfo[5]     get_user_info(iPlayer, "vip", szInfo, charsmax(szInfo))     if( szInfo[0] == '1' )         return g_bHasPrefix[ iPlayer ] = true;     else return g_bHasPrefix[ iPlayer ] = false; }
__________________
"It's not the actual programming that's interesting. But it's what you can accomplish with the end results that are important." -Dennis Ritchie
"Mathematics, rightly viewed, possesses not only truth, but supreme beauty a beauty cold and austere, like that of sculpture..." -Bertrand Russell

Last edited by DJEarthQuake; 05-20-2020 at 12:30.
DJEarthQuake is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-20-2020 , 12:41   Re: MSG_ONE or MSG_ONE_UNRELIABLE with no target entity
Reply With Quote #3

Quote:
Originally Posted by DJEarthQuake View Post
Code:
#include < amxmodx > #include < hamsandwich > #define IsValidPlayer(%0)   ( 1 <= %0 <= g_iMaxPlayers ) new g_bConnected[ 33 ] = false; new g_bAlive[ 33 ] = false; new g_iTeam[ 33 ]; new g_szName[ 33 ][ 32 ]; new bool: g_bHasPrefix[ 33 ] = false; new g_iMessageChat; new g_iMaxPlayers; public plugin_init( ) {     register_plugin( "VIP: Chat Prefix for user info", "2.0", "Milutinke (ByM)" );         RegisterHam( Ham_Spawn, "player", "fw_HamPlayerSpawnPost", .Post = true );         register_event( "TeamInfo", "fw_EventTeamInfo", "a" );         register_clcmd( "say", "fw_ChatPrefix" );     register_clcmd( "say_team", "fw_ChatPrefixTeam" );         g_iMessageChat = get_user_msgid( "SayText" );     g_iMaxPlayers = get_maxplayers( ); } public fw_HamPlayerSpawnPost( iPlayer ) {     g_bConnected[ iPlayer ] = bool: is_user_connected( iPlayer );     g_bAlive[ iPlayer ] = bool: is_user_alive( iPlayer ); } public client_connect( iPlayer ) {     g_bHasPrefix[ iPlayer ] = false;     g_bConnected[ iPlayer ] = false;     g_bAlive[ iPlayer ] = false;     g_iTeam[ iPlayer ] = 0; } public client_putinserver( iPlayer )     g_bConnected[ iPlayer ] = true; public client_authorized( iPlayer ) {     get_user_name( iPlayer, g_szName[ iPlayer ], charsmax( g_szName[ ] ) );         new szInfo[ 32 ];     if( get_user_info( iPlayer, "vip", szInfo, charsmax( szInfo ) ) ) {         trim( szInfo );                 if( szInfo[ 0 ] == EOS )             return;                     g_bHasPrefix[ iPlayer ] = bool: equal( szInfo, "1" );     } }    #if AMXX_VERSION_NUM < 183; public client_disconnect(iPlayer)     #else public client_disconnected(iPlayer)     #endif {     g_szName[ iPlayer ][ 0 ] = EOS;     g_bHasPrefix[ iPlayer ] = false;     g_bConnected[ iPlayer ] = false;     g_bAlive[ iPlayer ] = false;     g_iTeam[ iPlayer ] = 0; } public client_infochanged( iPlayer ) {     new szName[ 32 ];     get_user_name( iPlayer, szName, charsmax( szName ) );         if( !equal( g_szName[ iPlayer ], szName ) )         copy( g_szName[ iPlayer ], charsmax( g_szName[ ] ), szName ); } public fw_EventTeamInfo( ) {     new iPlayer = read_data( 1 );         if( !g_bConnected[ iPlayer ] )         return PLUGIN_CONTINUE;         new szTeam[ 12 ];     read_data( 2, szTeam, charsmax( szTeam ) );         switch( szTeam[ 0 ] ) {         case 'T' :  g_iTeam[ iPlayer ] = 1;         case 'C' :  g_iTeam[ iPlayer ] = 2;         case 'S' :  g_iTeam[ iPlayer ] = 3;         default: g_iTeam[ iPlayer ] = 4;     }         return PLUGIN_CONTINUE; } public fw_ChatPrefix( iPlayer ) {     if( is_vip_by_info(iPlayer ))     if( !g_bConnected[ iPlayer ] || !IsValidPlayer( iPlayer ) )         return 2;             static szSaid[ 191 ];     read_args( szSaid, charsmax( szSaid ) );     remove_quotes( szSaid );         return ChatPrefix( iPlayer, szSaid, charsmax( szSaid ), false ); } public fw_ChatPrefixTeam( iPlayer ) {     if( !g_bConnected[ iPlayer ] || !IsValidPlayer( iPlayer ) )         return 2;             static szSaid[ 191 ];     read_args( szSaid, charsmax( szSaid ) );     remove_quotes( szSaid );         return ChatPrefix( iPlayer, szSaid, charsmax( szSaid ), true ); } public ChatPrefix( const iPlayer, szSaid[ ], const iSaidLength, const bTeamChat ) {     static szMessage[ 191 ], iPlayers;     if( !szSaid[ 0 ] )         return 2;     formatex( szMessage, charsmax( szMessage ), "%s!t%s: !n%s", g_bHasPrefix[ iPlayer ] ? "!g[VIP] " : "", g_szName[ iPlayer ], szSaid );     replace_all( szMessage, charsmax( szMessage ), "%", "" );     replace_all( szMessage, charsmax( szMessage ), "!n", "^x01" );     replace_all( szMessage, charsmax( szMessage ), "!r", "^x02" );     replace_all( szMessage, charsmax( szMessage ), "!g", "^x04" );     replace_all( szMessage, charsmax( szMessage ), "!t", "^x03" );     trim( szMessage );         for( iPlayers = 1; iPlayers <= g_iMaxPlayers; iPlayers ++ ) {         if( !g_bConnected[ iPlayer ] || ( !g_bAlive[ iPlayer ] && g_bAlive[ iPlayers ] ) )             continue;                 if( bTeamChat ) {             if( get_user_team( iPlayer ) != get_user_team( iPlayers ) )                 continue;         }         if(is_user_connected(iPlayers)){         message_begin( MSG_ONE_UNRELIABLE, g_iMessageChat, { 0, 0, 0 }, iPlayers );         write_byte( iPlayer );         write_string( szMessage );         message_end( );         }     }     return 2; } stock bool:is_vip_by_info(iPlayer) {     static szInfo[5]     get_user_info(iPlayer, "vip", szInfo, charsmax(szInfo))     if( szInfo[0] == '1' )         return g_bHasPrefix[ iPlayer ] = true;     else return g_bHasPrefix[ iPlayer ] = false; }
Thanks it worked
supertrio17 is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 05-20-2020 , 14:08   Re: MSG_ONE or MSG_ONE_UNRELIABLE with no target entity
Reply With Quote #4

You're welcome.
__________________
"It's not the actual programming that's interesting. But it's what you can accomplish with the end results that are important." -Dennis Ritchie
"Mathematics, rightly viewed, possesses not only truth, but supreme beauty a beauty cold and austere, like that of sculpture..." -Bertrand Russell
DJEarthQuake is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:20.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode