Raised This Month: $ Target: $400
 0% 

PLugin server CPU Optimization


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
raa
Senior Member
Join Date: Oct 2005
Old 12-06-2006 , 21:49   PLugin server CPU Optimization
Reply With Quote #1

How could the below code be optimized/made to use less server cpu resources?

Code:
#include <engine>
#include <amxmodx>
#include <cstrike>


public plugin_init() {
	register_plugin("Bender model replacement", "0.1", "Front Line & nightscream - modified by raa")
	register_event("ResetHUD", "resetModel", "b")
	register_logevent("Event_RoundStart",2,"0=World triggered","1=Round_Start");
	return PLUGIN_CONTINUE
}

new g_szMdl[] = "models/b_hostage.mdl";

public plugin_precache() {
	
	precache_model("models/player/b_terror/b_terror.mdl")
	precache_model("models/player/b_arctic/b_arctic.mdl")
	precache_model("models/player/b_leet/b_leet.mdl")
	precache_model("models/player/b_guerilla/b_guerilla.mdl")
	
	precache_model("models/player/b_gsg9/b_gsg9.mdl")
	precache_model("models/player/b_urban/b_urban.mdl")
	precache_model("models/player/b_sas/b_sas.mdl")
	precache_model("models/player/b_gign/b_gign.mdl")
	
	precache_model("models/player/b_vip/b_vip.mdl")
	if(file_exists(g_szMdl))
		precache_model(g_szMdl);
	
	
	
	return PLUGIN_CONTINUE
}

public Event_RoundStart()
	{
	new iEnt;
	while((iEnt = find_ent_by_class(iEnt,"hostage_entity")) != 0)
		{
		if(file_exists(g_szMdl))
			entity_set_model(iEnt,g_szMdl);
	}
}

public resetModel(id) {
	new usermodel[33]
	cs_get_user_model(id, usermodel, 32)
	if(cs_get_user_team(id) == CS_TEAM_CT) {
		if(equali(usermodel, "GSG9")) {
			cs_set_user_model(id, "b_gsg9")
			}else{
			
			if(equali(usermodel, "GIGN")) {
				cs_set_user_model(id, "b_gign")
				}else{
				
				if(equali(usermodel, "URBAN")) {
					cs_set_user_model(id, "b_urban")
					}else{
					if(equali(usermodel, "SAS")) {
						cs_set_user_model(id, "b_sas")
						}else{
						
						if(equali(usermodel, "VIP")) {
							cs_set_user_model(id, "b_vip")
						}
					}
				}
			}
		}
	}
	if(equali(usermodel, "TERROR")) {
		
		cs_set_user_model(id, "b_terror")
		
		}else{
		
		if(equali(usermodel, "ARCTIC")) {
			
			cs_set_user_model(id, "b_arctic")
			
			}else{
			
			if(equali(usermodel, "GUERILLA")) {
				
				cs_set_user_model(id, "b_guerilla")
				}else{
				
				if(equali(usermodel, "LEET")) {
					
					cs_set_user_model(id, "b_leet")
					
				}
			}
		}
	}
	return PLUGIN_HANDLED
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0\\ deflang1033{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/
raa is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:50.


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