AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Operators (https://forums.alliedmods.net/showthread.php?t=222088)

vamppa 07-29-2013 16:26

Operators
 
Hello,
Can I check an value against two different operators?

YamiKaitou 07-29-2013 16:27

Re: Operators
 
Explain better, not sure what you are talking about

vamppa 07-29-2013 16:49

Re: Operators
 
PHP Code:

public plugin_init() 

    
register_clcmd("drop","anticrashserver"
}
public 
anticrashserver(id

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


something like this.
I am trying to force the client to have at least 1 weapon in his/her hand.
which should work with just
PHP Code:

num == 

however we have snarks,satchels and tripmines which are not recognized by amxmodx as part of the weapon index.
so Im first trying to isolate if it is 1 weapon.
then if it is one weapon I will disable the ability to drop by checking if its > 0.
so people wouldn't be able to drop further if they got an snarks,satchels,tripmines with 1 weapon in hand.
but I dont know how to check the same value against two different operators, if possible.

red_bull2oo6 07-29-2013 19:54

Re: Operators
 
well, the num > 0 will always get called because user has at least 1 weapon in the check above..
so you could put only num > 0 and return handled.. it will do the same.

i`m still confuse of what you're trying to do.

if user has at least one weapon you block drop command? ( that's what your code from above does ).

fysiks 07-29-2013 23:42

Re: Operators
 
This doesn't make sense. num will contain the ammo for that particular weapon. Also, if num is 1 then it will ALWAYS be greater than zero.

ConnorMcLeod 07-30-2013 01:10

Re: Operators
 
fysiks you are confusing get_user_weapon and get_user_weapons.

About problem, may be you are focused on the wrong thing.
What does trigger those crashes ? I thinkk there could be something to fix in custom weapons plugins.

vamppa 07-30-2013 08:41

Re: Operators
 
well it is an pretty confusing one. what red_bull mentioned I was aware off.
lets say I do this
PHP Code:

public anticrashserver(id

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


I go into an hldm game, I spawn with glock & crowbar.
as I move I pick up weapons from the ground i.e. gauss,rpg,mp5.
then I execute the drop command as many times as I can.
I will be left with one weapon in my hand, works perfectly.

now the same thing I go into hldm game, spawn etc
but along the way I pick up gauss,rpg,mp5,tripmine.
then I execute the drop command as many times as I can.
I will be left with zero weapons in hand.
why? I dont know.
think because weapon_tripmine (weapon_satchel and snarks) are not recognized as weapons I assume by amxmodx core but as ammo.
the best fix I can think of temporarily for this is
PHP Code:

public anticrashserver(id

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


making the odds less probable, since now you will be needing weapon_tripmine along with weapon_satchel in order for you to be able to drop all weapons.
but that is no fix ofcourse :P

vamppa 08-01-2013 10:26

Re: Operators
 
alright alternatively with fakemeta
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define EXTRAOFFSET      5
#define EXTRAOFFSET_WEAPONS   4
#define OFFSET_WEAPONID      30
#define OFFSET_ACTIVEITEM   306


stock hl_get_user_weapon_ent(client)
{
   return 
get_pdata_int(clientOFFSET_ACTIVEITEMEXTRAOFFSET)
}
stock hl_get_weapon_id(entity)
{
   return 
get_pdata_int(entityOFFSET_WEAPONIDEXTRAOFFSET_WEAPONS)
}

   new 
wepid hl_get_weapon_id(hl_get_user_weapon_ent(plrid)); 

Must have one weapon in hand.
or cant drop weapon_crowbar would work as well.
can use some help here.


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

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