AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Handling +use (https://forums.alliedmods.net/showthread.php?t=17460)

alien 09-01-2005 17:31

Handling +use
 
Hi,

does some1 know, how 2 handle USE key for each player? Is there an event for this??

Thnx

Batman/Gorlag 09-01-2005 18:07

There's a function in the engine include and its called force_use(pPlayer, pEntity) where pEntity could be a hostage, or another player.

Zenith77 09-01-2005 18:09

alien what exactly do you mean handle it? like stop it?

Batman/Gorlag 09-01-2005 18:14

Oh, is he talking about blocking an event, I don't know I just thought he asked how to make a use command and all.

alien 09-01-2005 21:10

I mean, hook a function to that event. If there is any. Sorry for mismatch explanation :)

atambo 09-01-2005 21:19

public client_PreThink(id)
{
new buttons = get_user_button(id)
if(buttons & IN_USE)...
}

v3x 09-01-2005 21:49

To disable it:
Code:
public client_PreThink(id) {     if(get_user_button(id)&IN_USE)     {         entity_set_int(id,EV_INT_button,entity_get_int(id,EV_INT_button)&~IN_USE)     } }
Or something..

Hooking it normally:
Code:
public client_PreThink(id) {     if(get_user_button(id)&IN_USE)     {         // ...     } }

alien 09-02-2005 07:00

:(

I tried. It executes client_PreThink hundred times a second. Thats what I don't want.

Watch this:

Code:
set_task(CHECK_USE_PERIOD, "repeat_check_use", 8138459, "", 0, "b")

It makes repeat_check_use( ) function called every CHECK_USE_PERIOD second. repeat_check_use( ) checks if player's pressing a button. That's what I'm trying to avoid ... because it's useless to check each player repeately whether he is trying to press E on his keyboard, if so, whether he is standing near the button. client_PreThink( ) does the same.

I still believe, there is possibility to invoke an event when player presses USE key, but I have found none in meta game list. :(

Can you help me?

v3x 09-02-2005 07:27

Oh, okay.. Then do this:
Code:
public client_PreThink(id) {     if((get_user_button(id) & IN_USE) && !(get_user_oldbutton(id) & IN_USE))     {         // blah ..     } }
:)

alien 09-02-2005 08:00

:(
Im sorry, my English sucks ...

I'll ask simple: how to write something into print_chat when some1 presses USE key?

:D


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

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