Raised This Month: $ Target: $400
 0% 

set model + prevent crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ownage
BANNED
Join Date: Jul 2007
Location: I don't know
Old 07-13-2007 , 15:01   Re: set model + prevent crash
Reply With Quote #1

Code:
#include <amxmodx> #include <umitem> #include <cstrike> #include <engine> #include <fakemeta> #include <fun> new gMsgScreenFade; new ldt[33] new gHasCovenantPower[33] new cvar_arena     new cvar_hp new cvar_model new cvar_shieldap new hp[33] new lasthp[33] new invis[33] new invischarge = 30 new modloop public plugin_init() {         register_plugin("ITEM Halo Energy Shield","1.1","OWNAGR")       register_item("Halo 2 R Shield & [press F for 6 sec Camouflage]", "ARMOR (shield) goes down first, then hp, does not protect from 1 shot / instant kills, Press F for invisiblity", 16000)         register_event("HLTV",         "Event_NewRound",     "a",     "1=0", "2=0")         cvar_arena = register_cvar("sv_halo","0")     cvar_model=register_cvar("sv_mcfreeman","0")         cvar_shieldap = register_cvar("sv_haloap","200")     cvar_hp = register_cvar("sv_halohp","200")         register_clcmd("h","h")     register_clcmd("sh" ,"Enable_Item")     register_clcmd("nosh" ,"Disable_Item")         server_cmd("sv_halo 0")     server_cmd("sv_haloap 200")     server_cmd("sv_halohp 200")         register_clcmd("+rope", "hook_on")     gMsgScreenFade = get_user_msgid("ScreenFade"); } public zplugin_precache(){     precache_model("models/player/freeman/freeman.mdl")     precache_model("models/player/mc/mc.mdl") } //need invis[id] >=invischarge for invis public hook_on(id){     if (!gHasCovenantPower[id]){                 if(is_user_alive(id)){             client_cmd(id,"impulse 100")         }                 return PLUGIN_CONTINUE     }     else if(invis[id]<invischarge){         client_print(id,print_center,"Invisibility not recharged yet! ( %i/%i )",invis[id],invischarge)         return PLUGIN_CONTINUE     }     client_print(id,print_center,"You are hard to see! Charging.....")     client_print(id,print_chat,"[OWNAGE HALO 2 INVISIBLITY] Camouflage activated! You are hard to see! Charging.....")         new tid[2]     tid[0] = id     set_task(0.1, "invisibility", 0, tid,2 , "a", 60)         set_task(6.3,"noinvis", 0, tid,2 )     invis[id]=0     return PLUGIN_CONTINUE     } public invisibility(tid[]){     if(is_user_connected(tid[0])){         set_user_rendering(tid[0],kRenderFxGlowShell, 0,0,0, kRenderTransTexture,45)     } } public noinvis(tid[]){     if(is_user_alive(tid[0])){         set_user_rendering(tid[0], kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 255)         client_print(tid[0],print_center,"Invisibility is over!")         client_print(tid[0],print_chat,"[OWNAGE HALO 2 INVISIBLITY] Invisibility is over!")     } } public Event_NewRound() {     if (get_pcvar_num(cvar_arena)){         set_task(3.0,"arena")             }         set_task(4.5,"ref")             modelall2() //there is 2 methods, modeall and modeall2, one is do it all, one is delayed                 return PLUGIN_CONTINUE } public arena(){     client_print(0,print_center,"Its Halo 2 style! HP & AP recharge! Aim for the head!")         //set_pcvar_num(cvar_shieldap,255)         new Players[32], iNum, target     get_players(Players, iNum, "a")         for(new i = 0; i < iNum; ++i)     {         target = Players[i]         if(is_user_alive(target)&& !gHasCovenantPower[target]){                     client_cmd(target,"sh")                     }     }     modelall2() //there is 2 methods, modeall and modeall2, one is do it all, one is delayed } public modelall(){         new mod = get_pcvar_num(cvar_model)     if(mod==0||mod==1){         new Players[32], iNum,id         get_players(Players, iNum, "a")         for(new i = 0; i < iNum; ++i)         {             id=Players[i]             new szModel[33]             cs_get_user_model(id, szModel, 32)             if (containi(szModel, "mc") ==-1||containi(szModel, "freeman") ==-1){                 set_model(id)             }                                                 }         }     } public modelall2(){         new mod = get_pcvar_num(cvar_model)     if(mod==0||mod==1){         modloop=0         set_task(0.3,"looppm",0,"",0,"a",32)         }     } public looppm(){     modloop++     if(is_user_connected(modloop)&&is_user_alive(modloop)){             set_model(modloop)                     }     } public set_model(id){     if(!is_user_alive(id)||!is_user_connected(id)){         return     }     server_cmd("amx_chat %d",id)     if(cs_get_user_team(id) == CS_TEAM_T){         new szModel[33]         cs_get_user_model(id, szModel, 32)         if (containi(szModel, "mc") ==-1){             cs_set_user_model(id, "mc")                     }     else if(cs_get_user_team(id) == CS_TEAM_CT){         new szModel[33]         cs_get_user_model(id, szModel, 32)         if (containi(szModel, "freeman") ==-1){             cs_set_user_model(id, "freeman")                     }                         } } public ref(){     new Players[32], iNum, target     get_players(Players, iNum, "a")         for(new i = 0; i < iNum; ++i)     {         target = Players[i]         if(is_user_alive(target)&& gHasCovenantPower[target]){             ldt[target]=0             invis[target]=invischarge-1         }     } } public h(id){     client_print(id,print_chat,"HP %i,AP %i",get_user_health(id),get_user_armor(id)) } public client_disconnect(id){     Disable_Item(id) } public Enable_Item(id) {     gHasCovenantPower[id]=1     if(!task_exists(id)){         set_task(1.03, "shieldloop", id, "", 0, "b")     }     ldt[id]=0     invis[id]=invischarge         cs_set_user_armor(id, get_pcvar_num(cvar_shieldap),CS_ARMOR_VESTHELM)     set_user_health(id,get_pcvar_num(cvar_hp))         return PLUGIN_HANDLED }     public Disable_Item(id) {     gHasCovenantPower[id]=0     remove_task(id)         return PLUGIN_HANDLED } public shieldloop(id){     ldt[id]--         if(invis[id]==invischarge){         client_print(id,print_chat,"[OWNAGE HALO 2 INVISIBLITY] Invisiblity charged! Press F to use!")         client_print(id,print_center,"[OWNAGE HALO 2 INVISIBLITY] Invisiblity charged! Press F to use!")         client_cmd(id,"spk sound/buttons/button7")         client_cmd(id,"spk sound/buttons/button7")                     }     invis[id]++ } public client_PreThink(id){     //client_print(id,print_console,"halo shield task")     //ldt[id]--     if( is_user_alive(id) && gHasCovenantPower[id]){                 hp[id] = get_user_health(id)             new playerarmor = get_user_armor(id)                         if(hp[id]!=lasthp[id]){             ldt[id]=8             if(hp[id]<99){                 message_begin( MSG_ONE_UNRELIABLE , gMsgScreenFade , {0,0,0} ,id );                 write_short( (1<<9) ); // duration                 write_short( (1<<9) ); // hold time                 write_short( (1<<12) ); // fade type                 write_byte( 120 ); //red                 write_byte( 0 ); //blue                 write_byte( 0 ); //green                 write_byte( 120 ); //alpha                 message_end();                 }             else{ //yellow                 if(playerarmor < get_pcvar_num(cvar_shieldap)){                     set_user_rendering( id, kRenderFxGlowShell, 20, 20, 0, kRenderNormal,  45);                     if(!task_exists(id+100)&&is_user_alive(id)){                         set_task(1.1,"noglow",id+100)                         }                 }             }         }         lasthp[id]=hp[id]         if(playerarmor < get_pcvar_num(cvar_shieldap)/5  && ldt[id] < 1){             cs_set_user_armor(id, get_pcvar_num(cvar_shieldap),CS_ARMOR_VESTHELM)             set_user_health(id,get_pcvar_num(cvar_hp))             client_cmd(id,"stopsound")             client_cmd(id,"spk sound/items/suitchargeok1")                         if( playerarmor < 1){                 client_cmd(id,"spk sound/items/suitchargeok1")                 client_cmd(id,"spk sound/items/suitchargeok1")             }                         client_print(id,print_center,"Your energy shields have recharged")                         set_user_rendering( id, kRenderFxGlowShell, 0, 155, 0, kRenderNormal, 20 );             if(!task_exists(id+100)&&is_user_alive(id)){                 set_task(1.8,"noglow",id+100)             }                         message_begin( MSG_ONE_UNRELIABLE , gMsgScreenFade , {0,0,0} ,id );             write_short( (1<<10) ); // duration             write_short( (1<<10) ); // hold time             write_short( (1<<12) ); // fade type             write_byte( 0 ); //red             write_byte( 255 ); //green             write_byte( 0); //blue             write_byte( 120 ); //alpha             message_end();         }         else if( playerarmor < get_pcvar_num(cvar_shieldap) && ldt[id] < 1){             cs_set_user_armor(id, get_pcvar_num(cvar_shieldap),CS_ARMOR_VESTHELM)             set_user_health(id,get_pcvar_num(cvar_hp))                         client_cmd(id,"spk sound/items/suitchargeok1")                         set_user_rendering( id, kRenderFxGlowShell, 0, 150, 0, kRenderNormal, 20 );             if(!task_exists(id+100)&&is_user_alive(id)){                 set_task(1.8,"noglow",id+100)             }                                     message_begin( MSG_ONE_UNRELIABLE , gMsgScreenFade , {0,0,0} ,id );             write_short( (1<<9) ); // duration             write_short( (1<<9) ); // hold time             write_short( (1<<12) ); // fade type             write_byte( 0 ); //red             write_byte( 255 ); //g             write_byte( 0); //b             write_byte( 60 ); //alpha             message_end();         }                     //new playerhp = get_user_health(id)                 if(hp[id] < 99&&playerarmor <1){             client_print(id,print_center,"Your shields are low, take cover!")             set_user_rendering( id, kRenderFxGlowShell, 15, 0,17, kRenderNormal, 40);                 }                 new sethp = get_pcvar_num(cvar_hp)                 if(hp[id]!=sethp){                         new missinghp = (sethp-hp[id])                         if( playerarmor>=missinghp){                 new damageap = playerarmor - missinghp                 cs_set_user_armor(id, damageap ,CS_ARMOR_VESTHELM)                 set_user_health(id,sethp)             }             else if( playerarmor > 0){                 set_user_health(id,hp[id]+playerarmor)                 set_user_armor(id,0)             }         }     }     return PLUGIN_CONTINUE } public noglow(zomg){     new idtemp=zomg-100     if(is_user_alive(idtemp)&&is_user_connected(idtemp)){         set_user_rendering( idtemp, kRenderFxGlowShell, 0, 0,0, kRenderNormal, 16 );     } }
Ownage is offline
Reply



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 21:31.


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