|
Junior Member
|

08-20-2012
, 15:41
Power Ups
|
#1
|
Hell0.
I use GHW power ups mod on my deathmach server, however, they should respawn every 25.0 seconds. Sometimes it respawns , sometimes not, sometimes there is one power up in other.
PHP Code:
/* * _______ _ _ __ __ * | _____/ | | | | \ \ __ / / * | | | | | | | | / \ | | * | | | |____| | | |/ __ \| | * | | ___ | ______ | | / \ | * | | |_ | | | | | | / \ | * | | | | | | | | | | | | * | |____| | | | | | | | | | * |_______/ |_| |_| \_/ \_/ * * * * Last Edited: 02-13-08 * * ============ * Changelog: * ============ * * v2.0 * -Plugin Rewrite * * v1.2 * -Models' Spin Sequences Now Work * * v1.0 * -Initial Release * */
#define VERSION "2.0"
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <fakemeta>
#define NUM_PUPS 11 #define MAX_PUPS 200
static const models[NUM_PUPS][32] = { "models/ghw_armor.mdl", "models/ghw_autoheal.mdl", "models/ghw_bhop.mdl", "models/ghw_damage.mdl", "models/ghw_footsteps.mdl", "models/ghw_gravity.mdl", "models/ghw_health.mdl", "models/ghw_invisibility.mdl", "models/ghw_money.mdl", "models/ghw_recoil.mdl", "models/ghw_speed.mdl" }
static const classnames[NUM_PUPS][32] = { "GHW_PUP_Armor", "GHW_PUP_Autoheal", "GHW_PUP_Bhop", "GHW_PUP_Damage", "GHW_PUP_Footsteps", "GHW_PUP_Gravity", "GHW_PUP_Health", "GHW_PUP_Invisibility", "GHW_PUP_Money", "GHW_PUP_Recoil", "GHW_PUP_Speed" }
new configfile[200]
new Float:origins[MAX_PUPS][3] new type[MAX_PUPS] new ents[MAX_PUPS] new line[MAX_PUPS] new count_pups
new Float:player_abilities[NUM_PUPS][33]
new pup_enabled, pup_last,pup_respawn
new bool:freezetime
public plugin_init() { register_plugin("Power Up Mod",VERSION,"GHW_Chronic")
register_concmd("amx_pup_create","cmd_create",ADMIN_LEVEL_D,"<type>") register_concmd("amx_pup_remove","cmd_remove",ADMIN_LEVEL_D," Removes nearest Power Up spawn to you.") //menu?
pup_last = register_cvar("pup_last","21.0") pup_respawn = register_cvar("pup_respawn","0") pup_enabled = register_cvar("pup_enabled","1")
register_event("SendAudio","end_round","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw") register_event("CurWeapon","CurWeapon","be","1=1","3>0") register_event("Damage","Damage","b") register_forward(FM_PlayerPreThink,"FM_think") register_forward(FM_Touch,"FM_touch") register_forward(FM_TraceLine, "FM_traceline")
new map[32] get_mapname(map,31)
new configsdir[200] get_configsdir(configsdir,199)
format(configsdir,199,"%s/PowerUps",configsdir) format(configfile,199,"%s/%s.ini",configsdir,map) if(!dir_exists(configsdir)) mkdir(configsdir)
load_powerups()
set_task(1.0,"ability_think",0,"",0,"b") }
public cmd_remove(id,level,cid) { if(!cmd_access(id,level,cid,1)) { return PLUGIN_HANDLED }
new bool:removed = false new Float:origin[3], classname[32] pev(id,pev_origin,origin) new ent = engfunc(EngFunc_FindEntityInSphere,get_maxplayers(),origin,100.0) while(ent) { pev(ent,pev_classname,classname,31) for(new i=0;i<NUM_PUPS;i++) { if(equali(classname,classnames[i])) { for(new j=0;j<count_pups;j++) { if(ent==ents[j]) { if(type[j]>=0) { console_print(id,"[AMXX] Power Up %s Removed.",classname) } else { console_print(id,"[AMXX] Power Up GHW_PUP_Random Removed.") } type[j] = -2 write_file(configfile,"",line[j]) break; } } engfunc(EngFunc_RemoveEntity,ent) removed=true; break; } } ent = engfunc(EngFunc_FindEntityInSphere,ent,origin,100.0) }
if(!removed) { console_print(id,"[AMXX] No Power Up found near you.") }
return PLUGIN_HANDLED }
public Damage(id) { if(is_user_alive(id)) { new attacker = get_user_attacker(id) if(is_user_alive(attacker) && player_abilities[3][attacker]) { new health = get_user_health(id) new damage = read_data(2) health -= damage
if(health<0) health = 1 set_user_health(id,health) } } }
public FM_think(id) { if(is_user_alive(id) && player_abilities[2][id]) { if((pev(id,pev_button) & IN_JUMP) && (pev(id,pev_flags) & FL_ONGROUND)) { static Float:velocity[3] pev(id,pev_velocity,velocity) velocity[2] = 250.0 set_pev(id,pev_velocity,velocity) set_pev(id,pev_gaitsequence,6) } } }
public FM_traceline_hook(Float:blah1[3],Float:blah2[3],blah3,id) { if(is_user_alive(id) && player_abilities[9][id]) { static vec1[3], Float:vec2[3] get_user_origin(id,vec1,3)
vec2[0] = float(vec1[0]) vec2[1] = float(vec1[1]) vec2[2] = float(vec1[2])
set_tr(TR_vecEndPos,vec2) } }
public FM_touch(id,ent) { if(is_user_alive(id)) { static classname[32] pev(ent,pev_classname,classname,31) for(new i=0;i<NUM_PUPS;i++) { if(equali(classname,classnames[i])) { engfunc(EngFunc_RemoveEntity,ent) handle_ability(id,i)
new Float:respawn = get_pcvar_float(pup_respawn) if(respawn) { set_task(respawn,"spawn_pup",i+50) }
break; } } } }
public CurWeapon(id) { if(player_abilities[10][id] && !freezetime) { set_user_maxspeed(id,100000.0) } if(player_abilities[5][id]) { set_user_gravity(id,0.5) } }
public remove_ability(id,type) { switch(type) { case 1: { set_user_footsteps(id,1) client_print(id,print_chat,"[AMXX] Your Auto-Heal Power Up wore off.") } case 2: { client_print(id,print_chat,"[AMXX] Your Bunny Hop Power Up wore off.") } case 3: { client_print(id,print_chat,"[AMXX] Your Double Damage Power Up wore off.") } case 4: { client_print(id,print_chat,"[AMXX] Your Silent-Stepping Power Up wore off.") } case 5: { set_user_gravity(id) client_print(id,print_chat,"[AMXX] Your Lower Gravity Power Up wore off.") } case 7: { set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255) client_print(id,print_chat,"[AMXX] Your Invisibility Power Up wore off.") } case 9: { client_print(id,print_chat,"[AMXX] Your No Recoil Power Up wore off.") } } }
public handle_ability(id,type) { switch(type) { case 0: { new CsArmorType:trash new armor = cs_get_user_armor(id,trash)
if(armor>=205) armor = 255 else armor += 50
cs_set_user_armor(id,armor,CS_ARMOR_VESTHELM)
client_print(id,print_chat,"[AMXX] You gained Armor!") } case 1: { player_abilities[type][id] += get_pcvar_float(pup_last) client_print(id,print_chat,"[AMXX] You gained Auto-Heal! (%0.0f seconds)",player_abilities[type][id]) } case 2: { player_abilities[type][id] += get_pcvar_float(pup_last) client_print(id,print_chat,"[AMXX] You gained Bunny Hopping! (%0.0f seconds)",player_abilities[type][id]) } case 3: { player_abilities[type][id] += get_pcvar_float(pup_last) client_print(id,print_chat,"[AMXX] You gained Double Damage! (%0.0f seconds)",player_abilities[type][id]) } case 4: { player_abilities[type][id] += get_pcvar_float(pup_last) client_print(id,print_chat,"[AMXX] You gained Silent-Stepping! (%0.0f seconds)",player_abilities[type][id]) set_user_footsteps(id,0) } case 5: { player_abilities[type][id] += get_pcvar_float(pup_last) client_print(id,print_chat,"[AMXX] You gained Lower Gravity! (%0.0f seconds)",player_abilities[type][id]) set_user_gravity(id,0.5) } case 6: { new health = get_user_health(id)
if(health>=205) health = 255 else health += 50
set_user_health(id,health)
client_print(id,print_chat,"[AMXX] You gained health!") } case 7: { set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,70)
client_print(id,print_chat,"[AMXX] You gained invisibility!") } case 8: { new money = cs_get_user_money(id)
if(money>=14000) money = 16000 else money += 2000
cs_set_user_money(id,money)
client_print(id,print_chat,"[AMXX] You gained $2000!") } case 9: { player_abilities[type][id] += get_pcvar_float(pup_last) client_print(id,print_chat,"[AMXX] You gained No Recoil! (%0.0f seconds)",player_abilities[type][id]) } } }
public cmd_create(id,level,cid) { if(!cmd_access(id,level,cid,2)) { return PLUGIN_HANDLED }
if(count_pups>=MAX_PUPS) { console_print(id,"[AMXX] %d Power Ups exist. Only %d allowed. Could not create new one.",count_pups,MAX_PUPS) return PLUGIN_HANDLED }
new arg1[32] read_argv(1,arg1,31)
if(equali(arg1,"armor")) type[count_pups] = 0 else if(equali(arg1,"autoheal")) type[count_pups] = 1 else if(equali(arg1,"bhop")) type[count_pups] = 2 else if(equali(arg1,"damage")) type[count_pups] = 3 else if(equali(arg1,"footsteps")) type[count_pups] = 4 else if(equali(arg1,"gravity")) type[count_pups] = 5 else if(equali(arg1,"health")) type[count_pups] = 6 else if(containi(arg1,"invisibility")==0) type[count_pups] = 7 else if(equali(arg1,"money")) type[count_pups] = 8 else if(equali(arg1,"recoil")) type[count_pups] = 9 else if(equali(arg1,"speed")) type[count_pups] = 10 else if(equali(arg1,"random")) type[count_pups] = -1 else { console_print(id,"[AMXX] Invalid Power Up type") return PLUGIN_HANDLED }
pev(id,pev_origin,origins[count_pups])
new string[200] format(string,199,"%f %f %f %d",origins[count_pups][0],origins[count_pups][1],origins[count_pups][2],type[count_pups]) write_file(configfile,string) line[count_pups] = file_size(configfile,1) - 2
count_pups++
console_print(id,"[AMXX] Power Up created at your location.")
return PLUGIN_HANDLED }
public end_round() { set_task(6.0,"new_round") freezetime = true }
public new_round() { set_task(get_cvar_float("mp_freezetime"),"not_freezetime") for(new i=0;i<count_pups;i++) { if((!ents[i] || !pev_valid(ents[i])) && !task_exists(i+50)) { spawn_pup(i+50) } } }
public not_freezetime() { freezetime = false }
public client_disconnect(id) { while(task_exists(id)) remove_task(id) for(new i=0;i<NUM_PUPS;i++) player_abilities[i][id] = 0.0 }
public plugin_precache() { for(new i=0;i<NUM_PUPS;i++) { precache_model(models[i]) } }
public spawn_pup(num) { num -= 50 if(get_pcvar_num(pup_enabled) && type[num]!=-2) { ents[num] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
if(type[num]!=-1) { set_pev(ents[num],pev_classname,classnames[type[num]]) engfunc(EngFunc_SetModel,ents[num],models[type[num]]) } else { new num2 = random_num(0,NUM_PUPS-1) set_pev(ents[num],pev_classname,classnames[num2]) engfunc(EngFunc_SetModel,ents[num],models[num2]) }
set_pev(ents[num],pev_mins,Float:{-16.0,-16.0,0.0}) set_pev(ents[num],pev_maxs,Float:{16.0,16.0,36.0}) set_pev(ents[num],pev_size,Float:{-16.0,-16.0,0.0,16.0,16.0,36.0}) engfunc(EngFunc_SetSize,ents[num],Float:{-16.0,-16.0,0.0},Float:{16.0,16.0,36.0})
set_pev(ents[num],pev_solid,SOLID_BBOX) set_pev(ents[num],pev_movetype,MOVETYPE_FLY)
set_pev(ents[num],pev_sequence,0) set_pev(ents[num],pev_gaitsequence,0) set_pev(ents[num],pev_framerate,1.0)
set_pev(ents[num],pev_origin,origins[num]) } }
public load_powerups() { if(file_exists(configfile)) { new Fsize = file_size(configfile,1) new read[64], trash new left[64] for(new i=0;i<Fsize;i++) { read_file(configfile,i,read,63,trash) if(read[0]!=';' && count_pups<MAX_PUPS && strlen(read)>10) { strbreak(read,left,63,read,63) origins[count_pups][0] = str_to_float(left) strbreak(read,left,63,read,63) origins[count_pups][1] = str_to_float(left) strbreak(read,left,63,read,63) origins[count_pups][2] = str_to_float(left) type[count_pups] = str_to_num(read) line[count_pups] = i count_pups++ } } } }
public ability_think() { new players[32], num get_players(players,num,"ah") for(new i=0;i<num;i++) { for(new j=0;j<NUM_PUPS;j++) { if(player_abilities[j][players[i]]) { player_abilities[j][players[i]] -= 1.0 if(player_abilities[j][players[i]]<=0.0) { remove_ability(players[i],j) player_abilities[j][players[i]] = 0.0 } } } if(player_abilities[1][players[i]]) { new health = get_user_health(players[i])
if(health>223) health = 255 else health += 1 set_user_health(players[i],health) } } }
Is the problem in this set_task(respawn,"spawn_pup",i+50) or public spawn_pup(num) , please help me to solve that problem.
|
|