AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_button spams (https://forums.alliedmods.net/showthread.php?t=28861)

wonsae 05-24-2006 16:46

get_user_button spams
 
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]

SweatyBanana 05-24-2006 16:48

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

Hawk552 05-24-2006 16:48

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.

BetaX 05-24-2006 16:48

Edit: ): I read that wrong. Nevermind. I thought he was simply telling us what it was going to do in the second part, heh.

wonsae 05-24-2006 16:57

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?

KoST 05-24-2006 16:58

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

Hawk552 05-24-2006 17:00

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.

wonsae 05-24-2006 17:00

what about my else part? How would I do that?

KoST 05-24-2006 17:01

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

wonsae 05-24-2006 17:03

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


All times are GMT -4. The time now is 16:29.

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