View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-11-2017 , 18:21   Re: One-Shot Multikill Detection
Reply With Quote #49

What I think would be best is to put prefix in with the message format and eliminate the format() call in SendMessage(). Perhaps also put prefix in a cvar so the user can change/remove it without re-compiling.

PHP Code:
SendMessage("%s ^4%s^1's grenade killed^4 %d^1 players!",Prefix,szName,iKills)
SendMessage("%s Oh my gawd!^4 %s^1 killed %d with one shot!",Prefix,KillerName,UserKills[iKiller][iNumKills]) 
Another thing.

PHP Code:
enum MessageTypes
{
    
HUD,
    
LOG,
    
CHAT
}

cVars[pCvarMessageType] = register_cvar("osmd_messagetype","0"
Just so you understand how this works. If a user installs your plugin and does not create a config file, it will default to HUD automatically and use that forever unless it's changed. If a user sets the cvar to something outside of the enum value range (like 6 or something) it will use CHAT. When I originally suggested choosing a fail-safe method I assumed CHAT was the default/preferred notification. Since you are using HUD as your default, you may want to do this:

PHP Code:
//Use chat only if cvar=1
case LOG:
{
    for(new 
i;sizeof replaceIcons;i++)
    {
        
replace_all(szMsg,charsmax(szMsg),replaceIcons[i],"")
    }
    
    
log_amx(szMsg)
}
//Use chat only if cvar=2
case CHAT:
{
    new 
Players[32],iPlayersNum,PlayerID
    
    get_players
(Players,iPlayersNum,"ch")

    for(new 
0;iPlayersNum;i++)
    {
        
PlayerID Players[i]
        if(
is_user_connected(PlayerID))
        {
            
message_begin(MSG_ONE_UNRELIABLE,MsgSayText,_,PlayerID)  
            
write_byte(PlayerID)
            
write_string(szMsg)
            
message_end()
        }
    }
}
//Use HUD if cvar = -99999 to 0 and 3 to 99999 (for example, it's anything out of the defined message types).
default:
{
    for(new 
i;sizeof replaceIcons;i++)
    {
        
replace_all(szMsg,charsmax(szMsg),replaceIcons[i],"")
    }
    
set_hudmessage(0,255,0,-1.0,0.0,1,1.0,5.0)
    
ShowSyncHudMsg(0,gSync,szMsg)

__________________

Last edited by Bugsy; 01-11-2017 at 18:28.
Bugsy is offline