| Doc-Holiday |
10-30-2011 16:18 |
To many if statments?
I have a question for you awesome scripters
With the below code im noticing lag when i kill some one on my team or thother...
Is that caused by to many if statements?
PHP Code:
public fwdPlayerDeath(iVictim, iAttacker, iShouldGib) { if(!get_pcvar_num(g_Cvar2[CVAR_ENABLED]) || is_user_bot(iAttacker)) return HAM_IGNORED; if(get_pcvar_num(g_Cvar2[CVAR_DEATHMATCH]) && !bBombPlanted) { set_task(get_pcvar_float(g_Cvar2[CVAR_RESPAWNTIME]), "RespawnPlayer", iVictim); set_task(0.01, "RespawnHud", iVictim); } set_pev(iVictim, pev_iuser1, 0); if(get_pcvar_num(g_Cvar2[CVAR_SOUNDTOGGLE])) { emit_sound(iVictim, CHAN_VOICE, g_Death_Sounds[random(sizeof(g_Death_Sounds))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); } StopBleeding(iVictim); g_kills[iVictim] = 0; g_HS[iVictim] = 0; if(!IsPlayer(iAttacker)) return HAM_IGNORED; new weapon = get_user_weapon(iAttacker); new HitGroup = get_pdata_int(iVictim, m_LastHitGroup, 5); new iClass = g_XP[iAttacker][Class]; new iTotalKillerXP; if(get_pcvar_num(g_Cvar2[ CVAR_TK ]) && cs_get_user_team(iVictim) == cs_get_user_team(iAttacker)) { g_XP[iAttacker][XP][iClass] -= get_pcvar_num(g_Cvar2[CVAR_TKXP]); set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0); ShowSyncHudMsg(iAttacker, gHudSyncXp, "- %d", get_pcvar_num(g_Cvar2[CVAR_TKXP])); } else if(cs_get_user_team(iAttacker) != cs_get_user_team(iVictim)) { //Adds Kill XP iTotalKillerXP += get_pcvar_num(g_Cvar2[CVAR_KILLXP]); ++g_kills[iAttacker]; //Adds Knife Bonus if(weapon == CSW_KNIFE) { iTotalKillerXP += get_pcvar_num(g_Cvar2[CVAR_KNIFEBONUS]); } if(HitGroup == HIT_HEAD) { iTotalKillerXP += get_pcvar_num(g_Cvar2[CVAR_HSBONUS]); ++g_HS[iAttacker]; } //Adds Kill Streak Bonus if(g_kills[iAttacker] == get_pcvar_num(g_Cvar2[CVAR_KILLSTREAK])) { iTotalKillerXP += get_pcvar_num(g_Cvar2[CVAR_KILLSTREAKBONUS]); g_kills[iAttacker] = 0; } //Adds Headshot Streak if(g_HS[iAttacker] == get_pcvar_num(g_Cvar2[CVAR_HSSTREAK])) { iTotalKillerXP += get_pcvar_num(g_Cvar2[CVAR_HSSTREAKBONUS]); g_HS[iAttacker] = 0; } g_XP[iAttacker][XP][iClass] += iTotalKillerXP; set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.0); ShowSyncHudMsg(iAttacker, gHudSyncXp, "+ %d", iTotalKillerXP); iTotalKillerXP = 0; } CheckLevel(iAttacker); return HAM_IGNORED; }
EDIT... now its not lagging on player death but crashing on map change due to nvault... GOD I HATE THIS CRAP....
|