AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check || && problem (https://forums.alliedmods.net/showthread.php?t=64500)

Pamaliska 12-17-2007 09:54

Check || && problem
 
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.

ConnorMcLeod 12-17-2007 10:07

Re: Check || && problem
 
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")



Pamaliska 12-17-2007 10:38

Re: Check || && problem
 
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.

ConnorMcLeod 12-17-2007 10:41

Re: Check || && problem
 
updated
drop_awp is skipped when awp_user is true or when picked weapon is not an awp.

Pamaliska 12-17-2007 11:08

Re: Check || && problem
 
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 12-17-2007 11:47

Re: Check || && problem
 
Thanks. Bad I am not allowed to give you +karma.

ConnorMcLeod 12-17-2007 11:51

Re: Check || && problem
 
My bad, instead of read_data(2), must be (1<<read_data(2))

Pamaliska 12-17-2007 12:02

Re: Check || && problem
 
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.

ConnorMcLeod 12-17-2007 12:26

Re: Check || && problem
 
1. Show the whole code

2. Sure : http://forums.alliedmods.net/showthread.php?t=63942

Pamaliska 12-17-2007 13:05

Re: Check || && problem
 
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.


All times are GMT -4. The time now is 11:04.

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