AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Use button (https://forums.alliedmods.net/showthread.php?t=134129)

Vechta 08-01-2010 09:04

Use button
 
Can someone correct please all bugs?
And if im pressing E nothing happen on all classes :/

Code:
Code:

public FwdCmdStart(id, uc_handle, seed)
{
        if(!is_user_alive(id))
                return FMRES_IGNORED
               
        new button = get_user_button(id)
        new oldbutton = get_user_oldbutton(id)
               
        if (zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_smoker)
        {
                if ((button & IN_USE) && (oldbutton && IN_USE))
                        drag_start(id)
               
                if ((!button & IN_USE) && (oldbutton & IN_USE))
                        drag_end(id)
        }
       
        if (zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_charger)
        {
                if ((button & IN_USE) && (oldbutton && IN_USE))
                {
                        set_task(0.1, "charger_push", id)
                }
        }
       
        new distance
        get_user_aiming(id, aimed, body, distance);
       
        if (zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_jockey)
        {
                if ((button & IN_USE) && (oldbutton && IN_USE))
                {
                        if(distance < 25.0)
                        {
                                if (is_user_alive(aimed) && zp_get_user_zombie(aimed))
                                {
                                        set_user_health(aimed, get_user_health(aimed) + 500)
                                }
                        }
                }
        }
}


Bugsy 08-01-2010 09:09

Re: Use button
 
When doing a bit-operation, make sure to use the correct operator: && should be &. I highlighted the lines where this correction is needed.
Code:
public FwdCmdStart(id, uc_handle, seed) {     if(!is_user_alive(id))         return FMRES_IGNORED             new button = get_user_button(id)     new oldbutton = get_user_oldbutton(id)             if (zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_smoker)     {         if ((button & IN_USE) && (oldbutton && IN_USE))             drag_start(id)                 if ((!button & IN_USE) && (oldbutton & IN_USE))             drag_end(id)     }         if (zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_charger)     {         if ((button & IN_USE) && (oldbutton && IN_USE))         {             set_task(0.1, "charger_push", id)         }     }         new distance     get_user_aiming(id, aimed, body, distance);         if (zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_jockey)     {         if ((button & IN_USE) && (oldbutton && IN_USE))         {             if(distance < 25.0)             {                 if (is_user_alive(aimed) && zp_get_user_zombie(aimed))                 {                     set_user_health(aimed, get_user_health(aimed) + 500)                 }             }         }     } }

Vechta 08-01-2010 09:15

Re: Use button
 
Thanks, can you also fix the bug with get_user_aiming i dont know anything about it and i can find anything that can help me :S

Bugsy 08-01-2010 09:16

Re: Use button
 
What is it supposed to do?

Vechta 08-01-2010 09:18

Re: Use button
 
If aiming at zombie and pressing E that the zombie get 500hp

Vechta 08-01-2010 09:50

Re: Use button
 
Still dont work

Vechta 08-01-2010 12:05

Re: Use button
 
So anyone can try to fix ?

meTaLiCroSS 08-01-2010 12:33

Re: Use button
 
PHP Code:

if (zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_jockey)
{
    if ((
button IN_USE) && (oldbutton && IN_USE))
    {
        static 
aimed body
        
if( get_user_aiming(idaimedbody25) > 0.0 )
        {
            if ( 
is_user_alive(aimed) && zp_get_user_zombie(aimed) )
            {
                
set_user_health(aimedget_user_health(aimed) + 500)
            }
        }
    }


Quote:

Originally Posted by FuncWiki
If the player's aim doesn't hit anything, 0.0 is returned.


Bugsy 08-01-2010 12:40

Re: Use button
 
Oops, my mistake I read the wiki wrong. :-B

Vechta 08-01-2010 13:43

Re: Use button
 
Thanks, but the problem is on all classes if im pressing E nothing happens


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

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