Raised This Month: $ Target: $400
 0% 

get_user_button spams


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wonsae
Senior Member
Join Date: Jan 2006
Location: Behind you >:D
Old 05-24-2006 , 16:46   get_user_button spams
Reply With Quote #1

hi i put this in client_prethink
Code:
if(get_user_button(id) & IN_USE){             blah(id)         }         else             {             blah2(id)         }

Code:
public blah(id){     client_print(id,print_chat,"test1") } public blah2(id){     client_print(id,print_chat,"test2") }

but when i use it in game it spams the client_print
and it auto goes to blah2 and the only way i can make it go to blah i have to hold my use button[/small]
wonsae is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-24-2006 , 16:48  
Reply With Quote #2

If the user is holding the button, which is what u coded, it will do what is in blah...

If you do not have the button pushed in at all, it will do what is in blah2


I think you can use returns to stop the spamming.

Code:
return PLUGIN_HANDLED
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-24-2006 , 16:48  
Reply With Quote #3

What do you want it to do? If I understand correctly, something like this?

Code:
if(get_user_button(id) & IN_USE) {     blad(id)     entity_set_int(id,EV_INT_button, get_user_button(id) & ~IN_USE) } else     blah2(id)

Also, it's better to cache get_user_button and then use it, but I didn't do it in this.

EDIT: SweatyBanana is wrong. returning PLUGIN_HANDLED will not solve it.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
BetaX
Member
Join Date: Nov 2005
Old 05-24-2006 , 16:48  
Reply With Quote #4

Edit: ): I read that wrong. Nevermind. I thought he was simply telling us what it was going to do in the second part, heh.
BetaX is offline
wonsae
Senior Member
Join Date: Jan 2006
Location: Behind you >:D
Old 05-24-2006 , 16:57  
Reply With Quote #5

Quote:
Originally Posted by Hawk552

Code:
if(get_user_button(id) & IN_USE) {     blad(id)     entity_set_int(id,EV_INT_button, get_user_button(id) & ~IN_USE) } else     blah2(id)
So this would make it so when the person presses it once it it goes to blah and stays in blah than press again it goes to blah2 and stays there right?
wonsae is offline
KoST
Senior Member
Join Date: Jul 2005
Old 05-24-2006 , 16:58  
Reply With Quote #6

Code:
if ((get_user_button(id) & IN_USE) && !(get_user_oldbutton(id) & IN_USE)){     // this will be called only once the button is pressed }

[edit] fixed
__________________
KoST is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-24-2006 , 17:00  
Reply With Quote #7

Quote:
Originally Posted by KoST
Code:
if ((get_user_button(id) & IN_USE) && !(get_user_button(id) & IN_USE)){     // this will be called only once the button is pressed }
Wow, I never expected that would work. I'll have to remember that.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
wonsae
Senior Member
Join Date: Jan 2006
Location: Behind you >:D
Old 05-24-2006 , 17:00  
Reply With Quote #8

what about my else part? How would I do that?
wonsae is offline
KoST
Senior Member
Join Date: Jul 2005
Old 05-24-2006 , 17:01  
Reply With Quote #9

else part:
Code:
if (!(get_user_button(id) & IN_USE) && (get_user_oldbutton(id) & IN_USE)){     // this will be called only once the button is released }

[edit] fixed
__________________
KoST is offline
wonsae
Senior Member
Join Date: Jan 2006
Location: Behind you >:D
Old 05-24-2006 , 17:03  
Reply With Quote #10

but I want it so when you press the use button once it stays in blah but when you press it again it goes to blah2 not when you release it it goes to blah2
wonsae 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 16:29.


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