AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   block +moveright &left. (https://forums.alliedmods.net/showthread.php?t=93162)

One 05-25-2009 04:54

block +moveright &left.
 
i tried this one here :

PHP Code:

public client_prethink(id)
{
    new 
button pev(id,pev_button);
    if (
button IN_MOVERIGHT)
    {
        
client_cmd(id"+right;wait;-right")
    }
    if (
button IN_MOVELEFT)
    {
        
client_cmd(id"+left;wait;-left")
    }


i just wanna to block +moveright or left & have only IN_RIGHT or IN_LEFT.

shine771 05-25-2009 04:59

Re: block +moveright &left.
 
PHP Code:

if((Buttons IN_MOVERIGHT) && (Buttons IN_RIGHT)) {
    
    
set_pev(id,pev_buttons,Buttons & ~IN_RIGHT)



One 05-25-2009 05:12

Re: block +moveright &left.
 
Quote:

Originally Posted by shine771 (Post 834263)
PHP Code:

if((Buttons IN_MOVERIGHT) && (Buttons IN_RIGHT)) {
    
    
set_pev(id,pev_buttons,Buttons & ~IN_RIGHT)



yay, ty. ill test. i hope this work :P

+k later. :mrgreen:

hleV 05-25-2009 08:17

Re: block +moveright &left.
 
Not tested.
Code:
public plugin_init()         register_forward(FM_CmdStart, "CmdStart");   public CmdStart(Client, Handle) {         static Buttons, InLeftOrRight;         Buttons = get_uc(Handle, UC_Buttons);           if ((Buttons & IN_LEFT) && (Buttons & IN_MOVELEFT))         {                 InLeftOrRight = true;                   Buttons &= ~IN_LEFT;                 Buttons |= ~IN_MOVELEFT;         }           if ((Buttons & IN_RIGHT) && (Buttons & IN_MOVERIGHT))         {                 if (InLeftOrRight)                 {                         Buttons |= ~IN_RIGHT;                         Buttons |= ~IN_MOVERIGHT;                 }                 else                 {                         InLeftOrRight = true;                           Buttons &= ~IN_RIGHT;                         Buttons |= ~IN_MOVERIGHT;                 }         }           if (InLeftOrRight)         {                 set_uc(Handle, UC_Buttons, Buttons);                   return FMRES_SUPERCEDE;         }           return FMRES_IGNORED; }

ot_207 05-25-2009 08:19

Re: block +moveright &left.
 
Better use CMDSTART, it is better than PRETHINK for what you want to do ;).

PHP Code:

// PLUGIN_INIT()
register_forward(FM_CmdStart"fw_cmdstart")

public 
fw_cmdstart(iducseed)
{
    if (!
is_user_alive(id))
        return 
FMRES_IGNORED

    
static buttons
    buttons 
get_uc(uc_handleUC_Buttons)

    
// Here do what shine did! but instead of SET_PEV use SET_UC



shine771 05-25-2009 10:17

Re: block +moveright &left.
 
Quote:

+k later. :mrgreen:
No need, i've already got excellent karma and it seems like you can't give me more. :(

One 05-26-2009 04:33

Re: block +moveright &left.
 
Ty again.

no code works.

IN_MOVELEFT/RIGHT still works when i press A or D( +moveright & +moveleft )

imagin u are playing NFS or so, when u press +right or +left, you cant have a side move. you just move the screen. better said, you dont have +moveleft. you have +left.




&& i dont open a new TH for this :

how can i show ° in hud?

100°

i dont want to write GRAD :(

Arkshine 05-26-2009 05:05

Re: block +moveright &left.
 
You can't block something client-side. There is probably an alternative way.

One 05-26-2009 06:03

Re: block +moveright &left.
 
Quote:

Originally Posted by arkshine (Post 834957)
You can't block something client-side. There is probably an alternative way.

lol? first u say i cant & after this u say there is a alternative way to do this?

or maybe i didnt understood u.

i want just change movexx to xx. this must be poss.

shine771 05-26-2009 11:05

Re: block +moveright &left.
 
I suppose you're making an racing mod or something? I've already have done a racing mod. I suggest you use an extra entity for players car, cause it's too messy with players. That's only a lame suggestion. I would finish my own mod, but there was a problem with entity stepsize, that's why i didn't publish it :).

About your problem, try
PHP Code:

engclient_cmd(id,"-right"

or

PHP Code:

if((Buttons IN_MOVERIGHT) || (Buttons IN_MOVELEFT)) {
        
      
set_pev(id,pev_button,Buttons & ~IN_RIGHT & ~IN_LEFT)




All times are GMT -4. The time now is 01:30.

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