AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   PreThink and client buttons (https://forums.alliedmods.net/showthread.php?t=19963)

MrDev 10-29-2005 14:03

PreThink and client buttons
 
I'm trying to reverse the users direction. move left = move right etc.

Currently I have:

Code:
public client_PreThink ( id ) {         if(get_user_button(id) & IN_MOVELEFT)     {         client_cmd(id, "+moveright")     }                     else if (get_user_oldbutton(id) & IN_MOVELEFT)     {         client_cmd(id, "-moveright")     }         return FMRES_HANDLED }

but it won't work :( Maybe it's because i need to stop moving left first? I've tryed different approches but none worked. Prethink is called correctly.

Freecode 10-29-2005 14:29

to stop the other movement use the - sign.
so
Code:
client_cmd(id, "-moveleft") client_cmd(id, "+moveright")

MrDev 10-29-2005 16:49

Without trying I think you're wrong.

You see the idea here is to move as long as you hold down the button, when you release the button you stop move.

If you only write +moveright you will move right until the command "-moveright" is entered.

Charr 10-29-2005 17:05

Hes right.

First in your plugin you have to stop them moving by using the:
Code:

-movedirection
Then you have to tell them to move the direction you want them to move. So use this:
Code:
 public client_PreThink ( id ) {         if(get_user_button(id) & IN_MOVELEFT)     {         client_cmd(id,"-moveleft")         client_cmd(id, "+moveright")     }                     else if (get_user_oldbutton(id) & IN_MOVELEFT)     {         client_cmd(id, "-moveright")     }         return FMRES_HANDLED }

MrDev 10-29-2005 17:22

The problem is.. It's not working. I've already tried that and you just stand still when "trying" to move left instead of going right.. What's really annoys me is, that SHOULD work, and i really can't see why it wont.

1) User hold down a KEY -- It stop and begin to move right
2) User releases KEY. Now get_user_button & LEFT returns 0 and else if is called. old button is LEFT one time and it should then stop moving RIGHT.. but noooo :(

Charr 10-29-2005 17:46

Instead of using prethink, try registering the +moveleft and +moveright.

[ --<-@ ] Black Rose 10-29-2005 17:52

whats FMRES_HANDELED ?

MrDev 10-29-2005 17:57

Charr: Yeah, but i would really like it to work in prethink, I've used prethink before to make it so the user could not attack so this should be do-able. Thanks for the advice though :)

Charr 10-29-2005 18:46

Try using a test script were you could use something like client_print instead moving the player.

[ --<-@ ] Black Rose 10-29-2005 19:29

its flimmering... or w/e... does IN_MOVELEFT means, player is pressing "go left btn" or player is going left or maby something else...?


All times are GMT -4. The time now is 23:50.

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