AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   combination of looking at someone and pressing e (https://forums.alliedmods.net/showthread.php?t=313838)

tolpecek 01-24-2019 13:47

combination of looking at someone and pressing e
 
Hello, i need help, this just doesnt work, thanks :D
any idea how to make it work ?
Code:

public ev_ShowStatus( id , uc_handle , seed )  //called when id looks at someone
{
        static Buttons , OldButtons;
   
    Buttons = get_uc( uc_handle , UC_Buttons );
    OldButtons = pev( id , pev_oldbuttons )

        new name[32], pid = read_data(2);
       
        get_user_name(pid, name, 31);
        new color1 = 0, color2 = 0;
///this dont work
        if ( !( OldButtons & IN_USE ) && ( Buttons & IN_USE ) && !g_CanBuild && !g_boolPrepTime)
            {
                if(cs_get_user_team(id) & CS_TEAM_CT)
                    {
                                new name2[32];
                                get_user_name(id, name2, 31);
                                if(cs_get_user_team(pid) & CS_TEAM_CT)
                                {
                                        print_color(id, "%s Vybral si si hraca %s na healovanie", formatmodname, name)
                                        print_color(pid, "%s Hrac %s si ta vybral na healovanie", formatmodname, name2)
                                        ischoosed[pid] = 1
                                        set_task(1.0,"paramedictask",id+paratask,_,_,"b")
                                        set_task(1.0,"paramedictask",pid+paratask,_,_,"b")
                                }
                                else
                                {
                                print_color(id, "%s Hrac %s nie je CT", formatmodname, name)
                                }
                    }
        }
        else if ( ( OldButtons & IN_USE ) && !( Buttons & IN_USE ) )
    {

    }

// until here
        if (get_user_team(pid) == 1)
                color1 = 255;
        else
                color2 = 255;

        new Float:height=0.30
        //height=0.60

        if (g_friend[id] == 1)        // friend
        {
                new clip, ammo, wpnid = get_user_weapon(pid, clip, ammo);
                new wpnname[32];

                if (wpnid)
                        xmod_get_wpnname(wpnid, wpnname, 31);

                set_hudmessage(color1, 50, color2, -1.0, height, 1, 0.01, 3.0, 0.01, 0.01);
                new nLen, szStatus[512]
                nLen += format( szStatus[nLen], 511-nLen, "Hrac: %s | Body: %d | XP: %d", name, credits[pid], xpcredits[pid]);       
                if (g_iszombie[pid])
                {
                        nLen += format( szStatus[nLen], 511-nLen, "^nSpecialne itemy:");
                        if (g_zariche[pid])
                                nLen += format( szStatus[nLen], 511-nLen, "^nZariche");
                        if (g_apokalypsa[pid])
                                nLen += format( szStatus[nLen], 511-nLen, "^nApokalypsa");
                        if(g_aura[pid])
                                nLen += format( szStatus[nLen], 511-nLen, "^nAuraLevel: %d", g_auralevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^n--------------------");
                        nLen += format( szStatus[nLen], 511-nLen, "^nVylepsenia:");
                        nLen += format( szStatus[nLen], 511-nLen, "^nZivoty %d/50", g_unHPLevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nArmor %d/50", g_unAPLevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nGravitacia %d/50", g_unGRLevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nNeviditelnost %d/50", g_unINLevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nRychlost %d/50", g_unSPLevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nPoskodenie %d/50", g_unDMGLevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nRecoil %d/33", g_unRECLevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nPrebijanie %d/50", g_unPREBLevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nSanca na kriticky zasah %d/25", g_criticlevel[pid]);
                        nLen += format( szStatus[nLen], 511-nLen, "^nKriticky zasah %d/25", g_criticlvl[pid]);
                }
                else
                {
                        nLen += format( szStatus[nLen], 511-nLen, "^nSpecialne itemy:");
                        if (g_zariche[pid])
                                nLen += format( szStatus[nLen], 511-nLen, "^nZariche");
                        if (g_apokalypsa[pid])
                                nLen += format( szStatus[nLen], 511-nLen, "^nApokalypsa");
                        if(g_aura[pid])
                                nLen += format( szStatus[nLen], 511-nLen, "^nAura");
                        nLen += format( szStatus[nLen], 511-nLen, "^n--------------------");
                        if(g_item_dmg[pid]) nLen += format( szStatus[nLen], 511-nLen, "^nMaly DAMAGE");
                        if(g_item_gdmg[pid]) nLen += format( szStatus[nLen], 511-nLen, "^nVelky DAMAGE");
                        if(g_item_rec[pid]) nLen += format( szStatus[nLen], 511-nLen, "^nRECOIL");
                        if(g_item_rel[pid]) nLen += format( szStatus[nLen], 511-nLen, "^nRELOAD");
                        if(g_item_reg[pid])nLen += format( szStatus[nLen], 511-nLen, "^nREGENERACE");

                }
                ShowSyncHudMsg(id, gHudSyncInfo, szStatus);
        }
        if (g_friend[id] != 1) //enemy
        {
                set_hudmessage(color1, 50, color2, -1.0, height, 1, 0.01, 3.0, 0.01, 0.01);
                new nLen, szStatus[512]
                nLen += format( szStatus[nLen], 511-nLen, "Hrac: %s | Body: %d | XP: %d", name, credits[pid], xpcredits[pid]);       
                ShowSyncHudMsg(id, gHudSyncInfo, szStatus);
        }
}


Bugsy 01-26-2019 11:36

Re: combination of looking at someone and pressing e
 
I added comments only for the part of your code that does not work:
Code:
///this dont work //The buttons checking is correct if you want to only detect when the player FIRST presses USE. This will not hook them holding USE //If you want only the first press and it is not working as you expect, then your CanBuild and/or PrepTime variables are not set to False     if ( !( OldButtons & IN_USE ) && ( Buttons & IN_USE ) && !g_CanBuild && !g_boolPrepTime)     { //cs_get_user_team(id) returns the team index as an integer, this is not a bit-wise value. Use '==' instead of '&"         if(cs_get_user_team(id) & CS_TEAM_CT)             {                 new name2[32]; //Technically not a code issue but try to get in the habit of using charsmax( variable ) instead of size - 1.                 get_user_name(id, name2, 31); //cs_get_user_team(id) returns the team index as an integer, this is not a bit-wise value. Use '==' instead of '&"                 if(cs_get_user_team(pid) & CS_TEAM_CT)                 {                     print_color(id, "%s Vybral si si hraca %s na healovanie", formatmodname, name)                     print_color(pid, "%s Hrac %s si ta vybral na healovanie", formatmodname, name2)                     ischoosed[pid] = 1 //This is not part of your problem, but I would setup paramedictask to handle both players within the same call, you can pass the //player id's in the data parameter. This would allow you to call set_task() only once which is more efficient.                     set_task(1.0,"paramedictask",id+paratask,_,_,"b")                     set_task(1.0,"paramedictask",pid+paratask,_,_,"b")                 }                 else                 {                     print_color(id, "%s Hrac %s nie je CT", formatmodname, name)                 }             }     } //This code will fire if g_CanBuild or PrepTime is true when a player first presses USE     else if ( ( OldButtons & IN_USE ) && !( Buttons & IN_USE ) )     {     } // until here


All times are GMT -4. The time now is 07:33.

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