Monthly Target: $400 Donations: $126
 31% 

One-Shot Multikill Detection


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-09-2017 , 23:22   Re: One-Shot Multikill Detection
Reply With Quote #41

  1. It appears you did away with the ability for SendMessage() to send to individual players but you left in the ability to do so only for HUD? If this was unintentional, change 'index' to '0' in ShowSyncHUDMsg() and remove 'index' from your function heading. You then need to remove the '0,' from each place you call SendMessage().

  2. You are still using format().. always use formatex().
__________________
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: Brazil, SP
Old 01-10-2017 , 22:30   Re: One-Shot Multikill Detection
Reply With Quote #42

I've removed the index.
I didn't seen formatex() there.
__________________
Furien Mod GameSites version (98% done)
EFFx is offline
Send a message via Skype™ to EFFx
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-10-2017 , 23:01   Re: One-Shot Multikill Detection
Reply With Quote #43

Quote:
Originally Posted by EFFx View Post
I've removed the index.
I didn't seen formatex() there.
Is it that hard to search your code? Replace every instance of it.
Code:
        case LOG:         {             for(new i;i < sizeof replaceIcons;i++)             {                 replace_all(szMsg,charsmax(szMsg),replaceIcons[i],"")             }                         log_amx(szMsg)         }         default:         {             new Players[32],iPlayersNum = 1,PlayerID             get_players(Players,iPlayersNum,"ch")            
            format(szMsg,charsmax(szMsg),"%s %s",Prefix,szMsg)
            get_players(Players,iPlayersNum,"ch")
__________________

Last edited by Bugsy; 01-10-2017 at 23:02.
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: Brazil, SP
Old 01-10-2017 , 23:03   Re: One-Shot Multikill Detection
Reply With Quote #44

Omg, I'm dumb, I've readed you saying for me use format() instead of formatex(), LOL

Quote:
I didn't seen formatex() there.
Sorry, code updated.
__________________
Furien Mod GameSites version (98% done)

Last edited by EFFx; 01-10-2017 at 23:04.
EFFx is offline
Send a message via Skype™ to EFFx
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-11-2017 , 00:23   Re: One-Shot Multikill Detection
Reply With Quote #45

I still recommend adding the "1>0" condition so the code does not reach DeathMsg on suicide which will prevent 5 native calls from happening.
  • get_pcvar_num(cVars[pCvarPluginEnabled])
  • read_data(1)
  • read_data(2)
  • get_user_team(iKiller)
  • get_user_team(iVictim)

PHP Code:
register_event("DeathMsg","functionDeath","a","4!grenade","1>0"
SendMessage():
Code:
SendMessage(const message[],any:...) {     static szMsg[191]
    You need to change the 3 to a 2 in vformat() since you removed the id parameter.
    Again, test your plugin after any code changes until you are more experienced.
    vformat(szMsg,charsmax(szMsg),message,3)     replace_all(szMsg, charsmax(szMsg),"!g","^4")     replace_all(szMsg, charsmax(szMsg),"!y","^1")     replace_all(szMsg, charsmax(szMsg),"!t","^3")         new MessageTypes:iMessageType = MessageTypes:get_pcvar_num(cVars[pCvarMessageType])     new const replaceIcons[] = {"^4","^3","^1"}         switch(iMessageType)     {         case HUD:         {             for(new i;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)         }         case LOG:         {             for(new i;i < sizeof replaceIcons;i++)             {                 replace_all(szMsg,charsmax(szMsg),replaceIcons[i],"")             }                         log_amx(szMsg)         }         default:         {             //You do not need to assign iPlayersNum a default value of 1
            new Players[32],iPlayersNum = 1,PlayerID
            //You call get_players() twice.
            get_players(Players,iPlayersNum,"ch")
                        formatex(szMsg,charsmax(szMsg),"%s %s",Prefix,szMsg)
            get_players(Players,iPlayersNum,"ch")
            for(new i = 0;i < iPlayersNum;i++)             {                 PlayerID = Players[i]                 //You do not need to check if connected when players retrieved with get_players().
                if(is_user_connected(PlayerID))
                {                     message_begin(MSG_ONE_UNRELIABLE,MsgSayText,_,PlayerID)                      write_byte(PlayerID)                     write_string(szMsg)                     message_end()                 }             }         }     } }
__________________
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: Brazil, SP
Old 01-11-2017 , 01:11   Re: One-Shot Multikill Detection
Reply With Quote #46

Code updated.

Sorry, I'm with so much problems on my head. I got little time to udpate those of my plugins.
__________________
Furien Mod GameSites version (98% done)

Last edited by EFFx; 01-11-2017 at 01:11.
EFFx is offline
Send a message via Skype™ to EFFx
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-11-2017 , 06:34   Re: One-Shot Multikill Detection
Reply With Quote #47

Quote:
Originally Posted by Bugsy View Post
Is it that hard to search your code? Replace every instance of it.
Code:
        case LOG:         {             for(new i;i < sizeof replaceIcons;i++)             {                 replace_all(szMsg,charsmax(szMsg),replaceIcons[i],"")             }                         log_amx(szMsg)         }         default:         {             new Players[32],iPlayersNum = 1,PlayerID             get_players(Players,iPlayersNum,"ch")            
            format(szMsg,charsmax(szMsg),"%s %s",Prefix,szMsg)
            get_players(Players,iPlayersNum,"ch")
Here format should be used, not formatex because he is formatting in the same buffer from where he get values.

EFFX, really, test your plugin before releasing.
__________________

Last edited by HamletEagle; 01-11-2017 at 06:38.
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: Brazil, SP
Old 01-11-2017 , 13:26   Re: One-Shot Multikill Detection
Reply With Quote #48

Yes, Bugsy. The message will show the Prefix so much times and do not show the message.

It should be format()

Code updated.
__________________
Furien Mod GameSites version (98% done)

Last edited by EFFx; 01-11-2017 at 13:48.
EFFx is offline
Send a message via Skype™ to EFFx
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-11-2017 , 19: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 19:28.
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: Brazil, SP
Old 01-11-2017 , 19:26   Re: One-Shot Multikill Detection
Reply With Quote #50

1. Whats the problem using the format() ?

2. No, I want not return CHAT when the cvar is 6 or something else anymore. I want show hud message. And the reason is because some peoples use hud_saytext. And a hud is better.

And is not possible add case default, FYI.
__________________
Furien Mod GameSites version (98% done)

Last edited by EFFx; 01-11-2017 at 19:28.
EFFx is offline
Send a message via Skype™ to EFFx
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 06:53.


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