AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   New message started when msg XX has not yet been sent yet (https://forums.alliedmods.net/showthread.php?t=219943)

OxidedMaze 07-05-2013 04:33

New message started when msg XX has not yet been sent yet
 
Hi everyone , I'm new to amxx scripting and I'm learning by modifying others' plugins. The following code is modified from 'all chat' by ian.cammarata

what I want to do is , when players say a team message , the message will only show to specific player in a team , and other teammate won't see the message.

but when I say a team message , the game crashes and shows the error mentioned , where is my error?

PHP Code:


new g_PlayerTeam[33]     // [ID] = TeammateID , text will only show to him

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_messageget_user_msgid("SayText"), "SayTextHandler" )
}
/*
...
// codes about g_PlayerTeam
...
*/
public SayTextHandlermsg_idmsg_destrcvr ){
    
console_print("Say Detected")
    new 
str2[26]        
    
get_msg_arg_string2str225 )    // ( String 1 ) 
    
if( equalstr2"#Cstrike_Chat"13 ) )
    {
        new 
str3[22]
        
get_msg_arg_string3str321 )    // ( String 2 )
        
        
if( !strlenstr3 ) )
        {
            new 
str4[101]            // (String 3 , MsgContent)
            
get_msg_arg_string4str4100 )
            new 
sender get_msg_arg_int)    // ( Byte 1 , SenderID)
            
if(g_PlayerTeam[sender] == -1)    // Player don't have a Target to show message
            
{
                
console_print("HANDLED")
                return 
PLUGIN_HANDLED
            
}
            new 
bool:is_team_msg = !bool:equalstr2"#Cstrike_Chat_All"17 )
            
            new 
sender_team get_user_teamsender )
            new 
bool:is_sender_spec = !bool:( sender_team )
            if(
is_team_msg && !is_sender_spec){
                if( 
is_team_msg )        //Now we know it's team_msg
                
{        
                    
console_print("TeamMSG")
                    
                    
PrintTeamMsg(g_PlayerTeam[sender] , str4)  // Show to Target ONLY
                
}
            }
        }
    }
    return 
PLUGIN_HANDLED
}

public 
PrintTeamMsg(id Msg[]){
    
message_beginMSG_ONEget_user_msgid"SayText" ), _id )
    
write_byteid )
    
write_stringMsg )
    
message_end()




All times are GMT -4. The time now is 06:22.

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