AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   reverse keys (https://forums.alliedmods.net/showthread.php?t=60648)

Exolent[jNr] 09-09-2007 03:00

reverse keys
 
ok i have this code in the forwarded prethink:
Code:
public fm_PreThink(id) {     if(gbReverseKeys[id])     {         static button, oldbuttons;         button = pev(id, pev_button);         oldbuttons = pev(id, pev_oldbuttons);         if(button & IN_MOVELEFT && !(oldbuttons & IN_MOVELEFT))         {             set_pev(id, pev_button, (button & ~IN_MOVELEFT) | IN_MOVERIGHT);         }         else if(button & IN_MOVERIGHT && !(oldbuttons & IN_MOVERIGHT))         {             set_pev(id, pev_button, (button & ~IN_MOVERIGHT) | IN_MOVELEFT);         }         if(button & IN_FORWARD && !(oldbuttons & IN_FORWARD))         {             set_pev(id, pev_button, (button & ~IN_FORWARD) | IN_BACK);         }         else if(button & IN_BACK && !(oldbuttons & IN_BACK))         {             set_pev(id, pev_button, (button & ~IN_BACK) | IN_FORWARD);         }     } }


except it just doesnt work.

any ideas?

EDIT: i also have same code, but with IN_JUMP, just to block it and not do anything else, but u can still jump.

ConnorMcLeod 09-09-2007 05:17

Re: reverse keys
 
Try this (and the same for the others) :

Code:
set_pev( id, pev_button, ( button & ( ~IN_MOVELEFT | IN_MOVERIGHT ) ) )

Exolent[jNr] 09-09-2007 12:43

Re: reverse keys
 
any other ideas?

also this doesnt work:
Code:
new button = pev(id, pev_button); if(button & IN_JUMP) {    set_pev(id, pev_button, (button & ~IN_JUMP)); }

Alka 09-09-2007 13:42

Re: reverse keys
 
Code:

new button = pev(id, pev_button);
if(button & IN_JUMP)
{
 button = button & ~IN_JUMP;
 set_pev(id, pev_button, button);
}

This should work!

ConnorMcLeod 09-09-2007 13:43

Re: reverse keys
 
-edit- : alka was too fast for me :P

Try this :

Code:
new button = pev(id, pev_button); if(button & IN_JUMP) {     button &= ~IN_JUMP     set_pev(id, pev_button, button); }

Exolent[jNr] 09-09-2007 15:02

Re: reverse keys
 
doing it that way doesnt work either...

is there something im doing wrong? =\


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

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