Raised This Month: $ Target: $400
 0% 

Check || && problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 12-17-2007 , 09:54   Check || && problem
Reply With Quote #1

Hello to everyone who is willing to help me solve this thingy.

Code:
public event_weap_pick_up(id) {     if( !is_user_connected(id) || !is_user_alive(id) || !get_cvar_num("amx_vipscript") )         return PLUGIN_CONTINUE;         if( read_data(1) != CSW_AWP ||  Awp_User[id] )         return PLUGIN_CONTINUE;         set_task(0.1, "drop_awp", id);     client_print(id, print_chat, "Bla bla la la");         return PLUGIN_CONTINUE; }

The problem is I cannot figure out how to add extra check for other weapons into this code. I want it to check not only for CSW_AWP but also for CSW_G3SG1 and CSW_SG550.
For some reason it does not work like that
Code:
if( read_data(1) != CSW_AWP || CSW_G3SG1 || CSW_SG5500 || Awp_User[id] )

Cheers.
Pamaliska is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-17-2007 , 10:07   Re: Check || && problem
Reply With Quote #2

weapon is data 2.

This will check if player pick up one of the 3 awps

PHP Code:
#define WEAPONS_TO_CHECK_BITSUM    (1<<CSW_AWP)|(1<<CSW_G3SG1)|(1<<CSW_SG550)


public event_weap_pick_up(id) {
    if( !
is_user_connected(id) || !is_user_alive(id) || !get_cvar_num("amx_vipscript") )
        return
    
    if(  !( 
WEAPONS_TO_CHECK_BITSUM & (1<<read_data(2)) ) || Awp_User[id]  )
        return
        
    
set_task(0.1"drop_awp"id)
    
client_print(idprint_chat"Bla bla la la")

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-17-2007 at 11:50.
ConnorMcLeod is offline
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 12-17-2007 , 10:38   Re: Check || && problem
Reply With Quote #3

Code:
if( WEAPONS_TO_CHECK_BITSUM & read_data(2) || Awp_User[id] )         return

"drop_awp" did not get a chance to be executed; just removed "return".
Thank you very much.
Pamaliska is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-17-2007 , 10:41   Re: Check || && problem
Reply With Quote #4

updated
drop_awp is skipped when awp_user is true or when picked weapon is not an awp.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 12-17-2007 , 11:08   Re: Check || && problem
Reply With Quote #5

I am not sure it is skipped, as I moved client_print to "drop_awp" and it is being printed, every time I pick up any weapon; although I force to drop only awps. Just deleted client_print for now, as it spams my chat.

Cheers.
Pamaliska is offline
Old 12-17-2007, 11:35
ConnorMcLeod
This message has been deleted by ConnorMcLeod. Reason: wrong code
Old 12-17-2007, 11:36
ConnorMcLeod
This message has been deleted by ConnorMcLeod. Reason: noob
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 12-17-2007 , 11:47   Re: Check || && problem
Reply With Quote #6

Thanks. Bad I am not allowed to give you +karma.
Pamaliska is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-17-2007 , 11:51   Re: Check || && problem
Reply With Quote #7

My bad, instead of read_data(2), must be (1<<read_data(2))
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 12-17-2007 , 12:02   Re: Check || && problem
Reply With Quote #8

I hate to say that, but it did not change, if leave client_print, it would print every time I pick any weapon. Though I can leave without that message
I ques it is just a matter of principles, to get it to work 100%.

Just a quick question. I don't want that nonVIP players would spend money on awps as they would drop those guns anyway. Is there a chance to block buy of just awps through buymenu. I would like to have that code in the same vipmenu plugin; however, it already handles one menu, would it interfere with hooking what menu player selected. Hope you understand what I am talking about.

Last edited by Pamaliska; 12-17-2007 at 12:09.
Pamaliska is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-17-2007 , 12:26   Re: Check || && problem
Reply With Quote #9

1. Show the whole code

2. Sure : http://forums.alliedmods.net/showthread.php?t=63942
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 12-17-2007 , 13:05   Re: Check || && problem
Reply With Quote #10

Code:
/// register_event("WeapPickup", "event_weap_pick_up", "b"); /// public event_weap_pick_up(id) {     if( !is_user_connected(id) || !is_user_alive(id) || !get_cvar_num("amx_vipscript") )         return         if(  !( WEAPONS_TO_CHECK_BITSUM & (1<<read_data(2)) ) || Awp_User[id]  )         return             set_task(0.1, "drop_awp", id) } public drop_awp(id) {     if( !Awp_User[id] && is_user_alive(id) && user_has_weapon(id, CSW_AWP) )         engclient_cmd(id, "drop", "weapon_awp");         //client_cmd(id,"weapon_awp;wait;wait;wait;drop");             if( !Awp_User[id] && is_user_alive(id) && user_has_weapon(id, CSW_G3SG1) )         engclient_cmd(id, "drop", "weapon_g3sg1");         //client_cmd(id,"weapon_g3sg1;wait;wait;wait;drop");             if( !Awp_User[id] && is_user_alive(id) && user_has_weapon(id, CSW_SG550) )         engclient_cmd(id, "drop", "weapon_sg550");         //client_cmd(id,"weapon_sg550;wait;wait;wait;drop");                 return PLUGIN_CONTINUE } /// This is what I do on proper player spawn drop_awp(id) // just to check and strip of awps if user is no loger Awp_user

This is the part of the code that handles awps. Awp_user[id] is properly reset and checked.
Pamaliska 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 11:04.


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