Raised This Month: $ Target: $400
 0% 

Operators


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 07-29-2013 , 16:26   Operators
Reply With Quote #1

Hello,
Can I check an value against two different operators?
vamppa is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-29-2013 , 16:27   Re: Operators
Reply With Quote #2

Explain better, not sure what you are talking about
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 07-29-2013 , 16:49   Re: Operators
Reply With Quote #3

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.

Last edited by vamppa; 07-29-2013 at 19:23.
vamppa is offline
red_bull2oo6
Senior Member
Join Date: Mar 2012
Location: Braila, Romania
Old 07-29-2013 , 19:54   Re: Operators
Reply With Quote #4

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 ).
red_bull2oo6 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-29-2013 , 23:42   Re: Operators
Reply With Quote #5

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.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-30-2013 , 01:10   Re: Operators
Reply With Quote #6

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.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-30-2013 at 01:10.
ConnorMcLeod is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 07-30-2013 , 08:41   Re: Operators
Reply With Quote #7

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
vamppa is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 08-01-2013 , 10:26   Re: Operators
Reply With Quote #8

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.

Last edited by vamppa; 08-01-2013 at 10:31.
vamppa is offline
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 15:52.


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