Page 1 of 1

apsauga nuo hs

Posted: 2012 Sep 02 15:09
by GhostMan
Kaip padaryti, kad pataikius į galvą būtų 50% tikimybė tą padarytą žalą blokuoti?

Code: Select all

public player_Attack ( id, iAttacker, Float:flDamage, Float:fVecDir[3], tr ){    if ( get_user_flags( id ) & VIP_ACCESS )    {        if ( IsPlayer( iAttacker ) && heavy_active[ id ] && cs_get_user_team( id ) != cs_get_user_team( iAttacker ) && get_tr2( tr, TR_iHitgroup ) == HIT_HEAD && get_tr2( tr, TR_iHitgroup ) == HIT_HEAD )        {            set_tr2( tr, TR_iHitgroup, HIT_CHEST );            set_tr2( tr, TR_iHitgroup, HIT_STOMACH );                                    message_begin( MSG_ONE_UNRELIABLE, g_msgFade, .player=id );            {                write_short( 1<<12 );                write_short( 1<<5 );                write_short( FFADE_IN );                write_byte( 139 );                write_byte( 34 );                write_byte( 34 );                write_byte( 75 );            }            message_end( );                        message_begin( MSG_ONE_UNRELIABLE, g_msgShake, .player=id );            {                write_short( 255<<5 );                write_short( 50<<5 );                write_short( 255<<5 );            }            message_end( );        }    }}
Suprantu, kad galima taip kažką padaryt, bet į kurią man vietą kišti šitą kodą? Nes to kur viršui aš nelabai suprantu.

Code: Select all

new iRandom = random_num( 1 , 100 );if(iRandom <= 50){}

Re: apsauga nuo hs

Posted: 2012 Sep 03 17:48
by InvIs
50% tikimybė yra

Code: Select all

new num = random_num(1,2)if (num != 1){ SetHamParamFloat(4, 0) // Jei num nelygus 1 (50% tikimybė nepasitvirtino) žala lygi nuliui}
o ne

Code: Select all

random_num(1,100)
Pats pagalvok logiškai

Re: apsauga nuo hs

Posted: 2012 Sep 03 19:05
by TETYYS
a nors ir galima int rand = random_num(0, 1000);
if (rand <= 500)
{
<...>
}

Re: apsauga nuo hs

Posted: 2012 Sep 04 01:31
by newb

Code: Select all

if(random(2)) { ... } 
^_^

Re: apsauga nuo hs

Posted: 2012 Sep 04 06:29
by GhostMan
Tai šitą "random" dalyką geraiu dėti prieš ar po šitos vietos?

Code: Select all

        if ( IsPlayer( iAttacker ) && heavy_active[ id ] && cs_get_user_team( id ) != cs_get_user_team( iAttacker ) && get_tr2( tr, TR_iHitgroup ) == HIT_HEAD && get_tr2( tr, TR_iHitgroup ) == HIT_HEAD )