Raised This Month: $51 Target: $400
 12% 

One-Shot Multikill Detection


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-04-2017 , 20:31   Re: One-Shot Multikill Detection
Reply With Quote #21

Quote:
Originally Posted by EFFx View Post
Sorry about the error, it doesn't give an error for me.
Then you probably didn't test it well enough to execute that particular piece of code.


Quote:
Originally Posted by EFFx View Post
Hm, I was searching how can I use that function like this:

PHP Code:
new szMessageTypeName[32]
GetMessageType(szMessageTypeName,charsmax(szMessageTypeName)) 
But I don't know how do that.
That makes absolutely no sense.

Quote:
Originally Posted by EFFx View Post
This,

PHP Code:
SendMessage(0GetMessageType(), /*...*/
That give an error.
What error? Did you remove the pseudocode (the comment) part of that expression and replace it with your actual code?

Quote:
Originally Posted by EFFx View Post
Look what I made:

PHP Code:
MessageTypes:GetMessageType(MessageTypes:returnValue

    new 
MessageTypes:iMessageType MessageTypes:get_pcvar_num(cVars[pCvarMessageType]) 
     
    switch(
iMessageType
    { 
        case 
CHATHUDLOG
        { 
            
returnValue iMessageType 
        

        default: 
        { 
            
returnValue CHAT 
        

    } 
    return 
returnValue 

That makes no sense and doesn't change the result, it just makes the function require a pointless argument. It should be how I wrote it originally. Use my original function making the necessary edits and attach your plugin and I can help you make it work properly.

Quote:
Originally Posted by EFFx View Post
PHP Code:
SendMessage(0,GetMessageType(MessageType),"^4%s^1's grenade killed^4 %d^1 players!",szName,iKills
The MessageTypes:MessageType is a global.
If you used my code, you don't need a global variable at all. That was the whole point of rewriting the function, to get rid of the global variable.

Quote:
Originally Posted by Craxor View Post
Here, as fysiks said
PHP Code:
    register_plugin
    
(
    .
plugin_name PLUGIN,
    .
version VERSION,
    .
author AUTHOR
    

Should be:
PHP Code:
    register_plugin
    
(
        .
plugin_name PLUGIN,
        .
version VERSION,
        .
author AUTHOR
    

I didn't not say anything about indentation here. I was simply giving my opinion regarding register_plugin() since I find it less readable.

@HamletEagle, I'm not able to post my opinion? That's interesting. I posted significant objective feedback as well if you didn't notice.
__________________

Last edited by fysiks; 01-04-2017 at 20:34.
fysiks is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-04-2017 , 20:38   Re: One-Shot Multikill Detection
Reply With Quote #22

I've tried your code again, and yes, this doesn't give the old error anymore. -.-
You can say what you want fysiks, all replies here ABOUT MY CODE are welcome.

About it
PHP Code:
new szMessageTypeName[32]
GetMessageType(szMessageTypeName,charsmax(szMessageTypeName)) 
Just for knowledge xD, but if its make no sense, lets continue with the default format.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-05-2017 , 04:15   Re: One-Shot Multikill Detection
Reply With Quote #23

It's the way you say it, like it's a very big issue. You should clearly state that it is only your opinion.
Sorry if my reply looked rude or something.
__________________

Last edited by HamletEagle; 01-05-2017 at 04:16.
HamletEagle is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-07-2017 , 14:50   Re: One-Shot Multikill Detection
Reply With Quote #24

Disregard what has already been stated. I went through and listed things I saw:
  1. You need to define MAX_PLAYERS using #define because people who are running 1.8.3 will get a duplicate definition error (Invalid symbol name "") when trying to compile since 1.8.3 defines MAX_PLAYERS out of the box. I recommend that you download a dev 1.8.3 version of AMX-X and compile on both versions to make sure there are no conflicts. I've experienced in the past end-users getting warnings on compile in 1.8.2 while in 1.8.3 compiles with 0 warnings. To do this, name the amxmodx parent directory with the version number: Currently I have 2 folders 'amxmodx' (1.8.3) and 'amxmodx182', after my compile is clear on 1.8.3, I rename 'amxmodx' to 'amxmodx183' and change 'amxmodx182' to 'amxmodx' and then attempt a compile.
    • Code:
      AMX Mod X Compiler 1.8.3-dev+4748
      Copyright (c) 1997-2006 ITB CompuPhase
      Copyright (c) 2004-2013 AMX Mod X Team
      
      Error: Invalid symbol name "" on line 12
      
      1 Error.
      Could not locate output file D:\HLServer\cstrike\addons\amxmodx\plugins\Tomfod.amx (compile failed).
  2. Weird spacing. After the =, press your spacebar once and then enter your variable value.
    • PHP Code:
      const TASK_CHECKKILLS =             23013013
      new const szCfgFile[] =             "Tomfod/tomfod_cvars.cfg" 
    • Space/format your code consistently before releasing it. Here you have a function directly under a closing bracket from the function above it. Make your code pretty before releasing.
      PHP Code:
      ...
      }
      GetMessageType()

  3. register_plugin() info: In my opinion, 2 of the 3 values will remain constant forever so what I do is hard-code the plugin title and author in the function itself and put only the version number in a variable towards the top since you will update this with each build.
    • PHP Code:
      new const Version[] = "0.1";
      register_plugin"plugin name" Version "your name" ); 
  4. fw_HamTakeDamage() is registered in post, name the forward function accordingly.

  5. Instead of failing the plugin if the config is not found, you should make the plugin create a config with the default values or allow it to run with the default register_cvar() values. Make it as easy as possible for the end-user to use. I'm also not sure that it's necessary to log it to the regular log in addition to using set_fail_state() since the latter will add a log automatically to the error_01072016.log file which is where the server admin should be checking for errors. In this case, you can remove formatex(), log_amx(), and do your error formatting directly in set_fail_state().

  6. GetMessageType() - Since you only determine the message type for SendMessage(), you should remove the GetMessageType() function all together and place the code directly in SendMessage(). If you were sending multiple messages after determining the message type then I would be ok with your implementation since it would reduce get_pcvar_num() calls. But each instance, you send only a single message.
__________________

Last edited by Bugsy; 01-07-2017 at 14:54.
Bugsy is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 01-07-2017 , 16:58   Re: One-Shot Multikill Detection
Reply With Quote #25

fw_HamTakeDamage -> PlayerTakenDamage
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-07-2017 , 19:55   Re: One-Shot Multikill Detection
Reply With Quote #26

Quote:
Originally Posted by PRoSToTeM@ View Post
fw_HamTakeDamage -> PlayerTakenDamage
I believe Bugsy was simply saying change it to something like fw_HamTakeDamagePost(). It is not completely out of the question to use multiple forwards/functions that would be described by "PlayerTakenDamage".
__________________
fysiks is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-07-2017 , 20:07   Re: One-Shot Multikill Detection
Reply With Quote #27

All things are now done. Waiting your replies...
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-07-2017 , 22:31   Re: One-Shot Multikill Detection
Reply With Quote #28

1. You completely did the opposite of what I suggested for your register_plugin() values. I even provided an example yet you only moved PluginVersion[] into plugin_init(). What is the point of doing that? Re-read #3 of my previous post.

2. In LoadCvars() you hard-code the file path when attempting to open the file (which you never close) and then use get_localinfo() to retrieve the configs directory to exec the config. This should be done in both instances for consistency and because it is what you should be doing. You are also building the file name twice. You do not technically need to check if the file exists before calling exec on it, the server console would just output 'couldn't exec abc123.cfg' if it doesn't exist. If you want, you could do a file_exists() check before calling server_cmd() on it.
PHP Code:
LoadCvars()
{
    new 
FormatDir[128], fileOpen 
    formatex
(FormatDir,charsmax(FormatDir),"addons/amxmodx/configs/%s",szCfgFile)
    
fileOpen fopen(FormatDir,"rt")
    
    if(
fileOpen
    {
        new 
szDir[32]
        
get_localinfo("amxx_configsdir",szDir,charsmax(szDir))
        
server_cmd("exec %s/%s",szDir,szCfgFile)
    }
}
//to
LoadCvars()
{
    new 
szConfigFile128 ];
    
    
formatexszConfigFileget_configsdirszConfigFile charsmaxszConfigFile ) ) ] , charsmaxszConfigFile ) , "/%s" szCfgFile );
    
server_cmd"exec %s" szConfigFile );

3. In SendMessage()
  • You need to account for the end-user putting an invalid message type value in the cvar. If you leave your code as is and user puts '8' in the cvar, you will get no message output. If you want CHAT to be the failsafe, then put the CHAT code under the default: switch value. This way it will use HUD or LOG if the value is that and it will use CHAT if the value is CHAT or any other random value.
  • Line 230 you have index ? index : 0. You can use just 'index' and it will work the same.
  • Line 203 you use format(), use formatex() instead.
  • Throughout your plugin the function is always sending the message to all players yet you coded it to handle a single player or all players. Since this function is not being used in any other plugins, you can reduce some code by hard-coding it to always send to all.

4. Line spacing! Again... Why do you do this:
PHP Code:
            if(index
                
Players[0] = index

            
else 
                
get_players(Players,iPlayersNum,"ch"
This should be:
PHP Code:
if(index
    
Players[0] = index
else 
    
get_players(Players,iPlayersNum,"ch")
//or
if(index
{
    
Players[0] = index
}
else 
{
    
get_players(Players,iPlayersNum,"ch")

5. My suggestion was to add '_Post' or something to fw_HamTakeDamage but instead you changed it to PlayerTakenDamage as PRoSToTeM@ suggested, which I think did nothing.

6. Add a "1>0" condition in register_event() for DeathMsg so it is not called on suicide.
__________________
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-08-2017 , 15:06   Re: One-Shot Multikill Detection
Reply With Quote #29

1. Done
2. Done
3. Those are the things I don't understand:

Quote:
Throughout your plugin the function is always sending the message to all players yet you coded it to handle a single player or all players. Since this function is not being used in any other plugins, you can reduce some code by hard-coding it to always send to all.
The plugin can send the message only for the player with multikill as well.

Quote:
You need to account for the end-user putting an invalid message type value in the cvar. If you leave your code as is and user puts '8' in the cvar, you will get no message output. If you want CHAT to be the failsafe, then put the CHAT code under the default: switch value. This way it will use HUD or LOG if the value is that and it will use CHAT if the value is CHAT or any other random value.
Can you explain more better? idu

4. Done
5. I've added fw_HamTakeDamagePost
6. Is this really needed? That function check if someone has killed 2 or more with one shot, how can someone can kill 2+ and suicide at the same time? Should I add this?

Edit number 6:

PHP Code:
if(iKiller != iVictim
-_-

6. Check removed.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 01-08-2017 at 17:26.
EFFx is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-08-2017 , 18:09   Re: One-Shot Multikill Detection
Reply With Quote #30

Quote:
Originally Posted by EFFx View Post
3. Those are the things I don't understand:

The plugin can send the message only for the player with multikill as well.

Can you explain more better? idu
I know it 'can', but you do not so what is the point of coding it to do so. You use SendMessage twice, both times to all players.
PHP Code:
SendMessage(0,"Oh my gawd!^4 %s^1 killed %d with one shot!",KillerName,UserKills[iKiller][iNumKills])
SendMessage(0,"^4%s^1's grenade killed^4 %d^1 players!",szName,iKills
Quote:
Originally Posted by EFFx View Post
6. Is this really needed? That function check if someone has killed 2 or more with one shot, how can someone can kill 2+ and suicide at the same time? Should I add this?

Edit number 6:

PHP Code:
if(iKiller != iVictim
-_-
It prevents the code from ever reaching your event hook on a suicide. I understand you are handling it in the event, but IMO it's better to stop the flow as soon as possible.


You updated the RegisterHam line but not the forward function. You still have:
"PlayerTakenDamage(iVictim,iInflictor,iAttack er,Float:fDamage,iDamageBits)
RegisterHam(Ham_TakeDamage,"player","fw_HamTa keDamagePost",1)

You did not fix the LoadCvars() function.

When you make changes, compile and test, until you get better.
__________________

Last edited by Bugsy; 01-08-2017 at 18:12.
Bugsy is offline
Reply



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 07:01.


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