AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Does anyone have an idea why this lags/causes load? (https://forums.alliedmods.net/showthread.php?t=188867)

vamppa 07-01-2012 07:55

Does anyone have an idea why this lags/causes load?
 
PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin("anti one crash ","1.2","Lev")
    
}
public 
client_command(plrid)
{
   
// Get client command.
   
new cmd[5];
   
read_argv(0cmdsizeof(cmd) - 1);
   
// Check if command is drop.
   
if (equali(cmd"drop"))
   {
      
// Get player's weapons count.
      
new num;
      new 
weapons[32];
      
get_user_weapons(plridweaponsnum);
      
// Deny command if user has only 2 weapon
      
if (num == 2)
      {
         return 
PLUGIN_HANDLED;
      }
   }
   return 
PLUGIN_CONTINUE;


wouldn't be better to hook the client drop command?

PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin("anti one crash ","1.2","Lev")
    
register_clcmd("drop","anticrash")
}
public 
anticrash(plrid)
{
      
// Get player's weapons count.
      
new num;
      new 
weapons[32];
      
get_user_weapons(plridweaponsnum);
      
// Deny command if user has only 2 weapon
      
if (num == 2)
      {
         return 
PLUGIN_HANDLED;
      }
   }
   return 
PLUGIN_CONTINUE;



ConnorMcLeod 07-01-2012 08:06

Re: Does anyone have an idea why this lags/causes load?
 
Sure it is better, but what you be even better, is to fix the badly coded plugin that make server crash when you drop a weapon.

vamppa 07-18-2012 20:28

Re: Does anyone have an idea why this lags/causes load?
 
how about this?

PHP Code:

#include <amxmodx> 

public plugin_init() 

    
register_plugin("anti one crash ","1.2","Lev+vamp"
    
register_clcmd("drop","anticrashserver"

public 
anticrashserver(id

      new 
num
      new 
weapons[32]; 
      
get_user_weapons(idweaponsnum); 
      if (
num == 2
      { 
         return 
PLUGIN_HANDLED
      } 
      return 
PLUGIN_CONTINUE;



hornet 07-19-2012 07:48

Re: Does anyone have an idea why this lags/causes load?
 
Quote:

Originally Posted by vamppa (Post 1753387)
how about this?

Read what Connor said? Fix the bad plugin.

vamppa 07-24-2012 23:53

Re: Does anyone have an idea why this lags/causes load?
 
im trying, one } has been removed as well as plrid to id
i dont know what further is bad about it, since it works for us HLDM.


"fix the badly coded plugin that make server crash when you drop a weapon"
would that crash be cs related?

OvidiuS 07-31-2012 17:47

Re: Does anyone have an idea why this lags/causes load?
 
What are you trying to do??

vamppa 07-31-2012 17:53

Re: Does anyone have an idea why this lags/causes load?
 
making it impossible for players to drop a weapon when they have two (making sure players got at least 2 weapons)
this is to prevent an exploit from happing that can crash the server.

this already does that and works, however I am trying to find the most lag free method.

Exolent[jNr] 07-31-2012 17:56

Re: Does anyone have an idea why this lags/causes load?
 
Quote:

Originally Posted by vamppa (Post 1762172)
this is to prevent an exploit from happing that can crash the server.

That "exploit" is relative to whatever you are running on your server.
It is better to fix the exploit instead of trying to prevent it.

vamppa 08-01-2012 08:00

Re: Does anyone have an idea why this lags/causes load?
 
I believe this is a known exploit in halflife deathmatch, unfortuantly in our mod "Adrenaline gamer" it didn't get fixed.
for halflife deathmatch valve fixed it by making it so the player has always got to have at least one weapon in his hand.
previously one could drop all his/her weapons.

how the bug prevention is done should be irrelevant, since the question is how to improve this plugin, optimize it?
apparently it is badly coded, ofcourse for the community that is going to use this plugin i want to know.
I tried to figure it out myself but obviously im not good enough and experienced at this.
could you show me how this is properly done?

Exolent[jNr] 08-01-2012 15:33

Re: Does anyone have an idea why this lags/causes load?
 
So Adrenaline gamer is a HL mod or a plugin?


All times are GMT -4. The time now is 15:01.

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