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

Too many checks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
0x00
SourceMod Donor
Join Date: Oct 2010
Location: #!/usr/bin/0x00
Old 04-13-2011 , 17:16   Too many checks
Reply With Quote #1

Let's say that I want to do a check just like the code above, how I am supposed to do so?

It simple doesnt compile and give me a shit load of errors, even if they're all in the same line.

PHP Code:
if(!StrEqual(temp"tf_weapon_bat"false) || !StrEqual(temp"tf_weapon_bat_wood"false) || 
!
StrEqual(temp"tf_weapon_bat_fish"false) || !StrEqual(temp"tf_weapon_shovel"false) || 
!
StrEqual(temp"tf_weapon_fireaxe"false) || !StrEqual(temp"tf_weapon_bottle"false) || 
!
StrEqual(temp"tf_weapon_sword"false) || !StrEqual(temp"tf_weapon_fists"false) || 
!
StrEqual(temp"tf_weapon_lunchbox"false) || !StrEqual(temp"tf_weapon_wrench"false) || 
!
StrEqual(temp"tf_weapon_bonesaw"false) || !StrEqual(temp"tf_weapon_club"false) || 
!
StrEqual(temp"tf_weapon_knife"false) || !StrEqual(temp"tf_weapon_invis"false) || 
!
StrEqual(temp"tf_weapon_robot_arm"false) || !StrEqual(temp"tf_weapon_stickbomb" false))
{
        
// something here

0x00 is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 04-13-2011 , 17:30   Re: Too many checks
Reply With Quote #2

StrContains(temp, "tf_weapon") ?
__________________
databomb is offline
0x00
SourceMod Donor
Join Date: Oct 2010
Location: #!/usr/bin/0x00
Old 04-13-2011 , 17:34   Re: Too many checks
Reply With Quote #3

Nope, if you havent noticed there's just melee weapons on my list.. any kind of weapon uses tf_weapon~ meaning it won't filter anything.
0x00 is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 04-13-2011 , 18:31   Re: Too many checks
Reply With Quote #4

Long live TFC!

In that case 0x00, have you tried checking if the active weapon slot position is the melee position?

Also, that last StrEqual is missing a comma!! And if you do go with StrEqual approach then I should suggest truncating the first part "tf_weapon_" before you do all the checks to save CPU cycles.
__________________
databomb is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 04-13-2011 , 18:41   Re: Too many checks
Reply With Quote #5

As suggested, use the weaponslot.
If that isn't equal for all of them, go with a StrEqual from position temp[9]. (If there are only a few exceptions, like all melee + 2 secondary, you can just check slot || the two names, ofcourse)
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 04-14-2011 , 13:21   Re: Too many checks
Reply With Quote #6

Besides, there has to be a smarter way to determine if a weapon is a melee weapon. I'd say check the ammo, or something else in the netprops.
AtomicStryker is offline
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 04-14-2011 , 16:55   Re: Too many checks
Reply With Quote #7

Quote:
Originally Posted by AtomicStryker View Post
Besides, there has to be a smarter way to determine if a weapon is a melee weapon. I'd say check the ammo, or something else in the netprops.
I thought of this but then The Sandman came into mind

I think checking to see if the active weapon is in the 0 slot would suffice.

PHP Code:
new iWeapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
if(
GetPlayerWeaponSlot(client0) == iWeapon)
{
   
//looks like player is most likely holding a melee weapon

__________________
FoxMulder is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 04-14-2011 , 17:08   Re: Too many checks
Reply With Quote #8

I decided to look through your list, and isn't lunchbox NOT a melee item?
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-14-2011 , 20:13   Re: Too many checks
Reply With Quote #9

Quote:
Originally Posted by 0x00 View Post
It simple doesnt compile and give me a shit load of errors, even if they're all in the same line.
I suggest fixing the error that's on the line given to you by the compiler.
Fyren is offline
Cookies.net
Senior Member
Join Date: Jan 2011
Old 04-15-2011 , 02:27   Re: Too many checks
Reply With Quote #10

the last strequal is missing a ,
PHP Code:
!StrEqual(temp"tf_weapon_stickbomb" false
should be
PHP Code:
!StrEqual(temp"tf_weapon_stickbomb"false
no compiler errors then here
Cookies.net 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 12:01.


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