Raised This Month: $ Target: $400
 0% 

[ZP] Delete 2 things


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
strangeguy
Senior Member
Join Date: Mar 2019
Old 12-27-2019 , 08:01   [ZP] Delete 2 things
Reply With Quote #1

Can anyone help me to delete supplybox and chicken for this plugin. I would like only egg as bonus box.

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <zombieplague>

#define PLUGIN "[ZP] Drop itens"
#define VERSION "1.0"
#define AUTHOR "Biel-oGrande"

new g_model_supplybox[] = "models/zombie_plague/w_supplybox.mdl"
new g_model_egg[] = "models/zombie_plague/w_egg.mdl"
new g_model_chicken[] = "models/zombie_plague/w_chicken.mdl"

new g_sound_supplybox[] = "zombie_plague/supplybox_pickup.wav"
new g_sound_egg[] = "zombie_plague/egg_pickup.wav"
new g_sound_chicken[] = "zombie_plague/chicken_pickup.wav"

new cvar_min_ap, cvar_max_ap

public plugin_init() {
	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	cvar_min_ap = register_cvar("zp_min_ap","1")
	cvar_max_ap = register_cvar("zp_max_ap","5")
	
	register_logevent("round_start", 2, "1=Round_Start")
	
	register_event("DeathMsg", "player_death", "a")
	
	register_forward(FM_Touch, "fwdTouch")
}

public plugin_precache()  {
	
	precache_model(g_model_supplybox)
	precache_sound(g_sound_supplybox)
	
	precache_model(g_model_egg)
	precache_sound(g_sound_egg)
	
	precache_model(g_model_chicken)
	precache_sound(g_sound_chicken)
}

public round_start() {
	
	new ent = -1
	while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "supplybox")) != 0) {
		
		engfunc(EngFunc_RemoveEntity, ent)
	}
	while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "egg")) != 0) {
		
		engfunc(EngFunc_RemoveEntity, ent)
	}
	while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "chicken")) != 0) {
		
		engfunc(EngFunc_RemoveEntity, ent)
	}
}

public player_death() {
	
	new victim = read_data(2)
	
	switch(random_num(1,3)) {
		
		case 1: drop_supplybox(victim)
			case 2: drop_egg(victim)
			case 3: drop_chicken(victim)
		}
	
	return PLUGIN_CONTINUE
}

public drop_supplybox(id) {
	
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	new Float:origin[3]
	pev(id, pev_origin, origin)
	
	set_pev(ent, pev_origin, origin)
	set_pev(ent, pev_classname, "supplybox")
	engfunc(EngFunc_SetModel, ent, g_model_supplybox)
	set_pev(ent, pev_solid, SOLID_TRIGGER)
	set_pev(ent, pev_movetype, MOVETYPE_NOCLIP)
	engfunc(EngFunc_DropToFloor, ent)
	
	set_pev(ent, pev_renderfx, kRenderFxGlowShell)
	set_pev(ent, pev_rendercolor, Float:{0.0, 0.0, 150.0})
}

public drop_egg(id) {
	
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	new Float:origin[3]
	pev(id, pev_origin, origin)

	set_pev(ent, pev_origin, origin)
	set_pev(ent, pev_classname, "egg")
	engfunc(EngFunc_SetModel, ent, g_model_egg)
	set_pev(ent, pev_solid, SOLID_TRIGGER)
	set_pev(ent, pev_movetype, MOVETYPE_BOUNCE)
	engfunc(EngFunc_DropToFloor, ent)
	
	set_pev(ent, pev_renderfx, kRenderFxGlowShell)
	set_pev(ent, pev_rendercolor, Float:{0.0, 150.0, 000.0})
}

public drop_chicken(id) {
	
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	new Float:origin[3]
	pev(id, pev_origin, origin)
	
	set_pev(ent, pev_origin, origin)
	set_pev(ent, pev_classname, "chicken")
	engfunc(EngFunc_SetModel, ent, g_model_chicken)
	set_pev(ent, pev_solid, SOLID_TRIGGER)
	set_pev(ent, pev_movetype, MOVETYPE_NOCLIP)
	engfunc(EngFunc_DropToFloor, ent)
	
	set_pev(ent, pev_renderfx, kRenderFxGlowShell)
	set_pev(ent, pev_rendercolor, Float:{150.0, 150.0, 150.0})
}

public fwdTouch(ent, id) { 
	
	if(!pev_valid(ent) || !is_user_alive(id)) return FMRES_IGNORED
	
	new classname[32]
	pev(ent, pev_classname, classname, charsmax(classname))
	
	if(equali(classname, "supplybox")) {
		
		emit_sound(id, CHAN_AUTO, g_sound_supplybox, 1.0, ATTN_NORM, 0, PITCH_NORM)
		engfunc(EngFunc_RemoveEntity, ent)
		give(id)
	}
	if(equali(classname, "egg")) {
		
		emit_sound(id, CHAN_AUTO, g_sound_egg, 1.0, ATTN_NORM, 0, PITCH_NORM)
		engfunc(EngFunc_RemoveEntity, ent)
		give(id)
	}
	if(equali(classname, "chicken")) {
		
		emit_sound(id, CHAN_AUTO, g_sound_chicken, 1.0, ATTN_NORM, 0, PITCH_NORM)
		engfunc(EngFunc_RemoveEntity, ent)
		give(id)
	}
	return FMRES_IGNORED
}

public give(id) {
	
	new iRandom = random_num(get_pcvar_num(cvar_min_ap), get_pcvar_num(cvar_max_ap))	
	
	zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iRandom)
	
	client_print(id, print_center, "[ %d ] Ammopacks", iRandom)
}
strangeguy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-27-2019 , 08:40   Re: [ZP] Delete 2 things
Reply With Quote #2

Did you at least try? It's pretty straight forward.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
strangeguy
Senior Member
Join Date: Mar 2019
Old 12-27-2019 , 08:55   Re: [ZP] Delete 2 things
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
Did you at least try? It's pretty straight forward.
I trying to delete this 2 boxes but I have much errors and incompatibilities
strangeguy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-27-2019 , 08:59   Re: [ZP] Delete 2 things
Reply With Quote #4

Try it and post the results. This is not the plugin requests section.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
strangeguy
Senior Member
Join Date: Mar 2019
Old 12-27-2019 , 09:34   Re: [ZP] Delete 2 things
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
Try it and post the results. This is not the plugin requests section.
Ok, I delete supply box and chicken but when compiling I have these errors.

amx_bonus.sma<55> : error 014: invalid statement; not in switch
amx_bonus.sma<55> : warning 215: expression has no effect
amx_bonus.sma<55> : error 001: expected token ; but found :
amx_bonus.sma<55> : error 029: invalid expression, assumed zero
amx_bonus.sma<55> : fatal error 107: too many error messages on one line

and edit code
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <zombieplague>

#define PLUGIN "[ZP] Drop itens"
#define VERSION "1.0"
#define AUTHOR "Biel-oGrande"

new g_model_egg[] = "models/zombie_plague/w_egg.mdl"

new g_sound_egg[] = "zombie_plague/egg_pickup.wav"

new cvar_min_ap, cvar_max_ap

public plugin_init() {
	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	cvar_min_ap = register_cvar("zp_min_ap","1")
	cvar_max_ap = register_cvar("zp_max_ap","5")
	
	register_logevent("round_start", 2, "1=Round_Start")
	
	register_event("DeathMsg", "player_death", "a")
	
	register_forward(FM_Touch, "fwdTouch")
}

public plugin_precache()  {
	
	precache_model(g_model_egg)
	precache_sound(g_sound_egg)
	
}

public round_start() {
	
	new ent = -1
	while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "egg")) != 0) {
		
		engfunc(EngFunc_RemoveEntity, ent)
	}
}

public player_death() {
	
	new victim = read_data(2)
	
        {
		
			case 1: drop_egg(victim)
			
		}
	
	return PLUGIN_CONTINUE
}

public drop_egg(id) {
	
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	new Float:origin[3]
	pev(id, pev_origin, origin)

	set_pev(ent, pev_origin, origin)
	set_pev(ent, pev_classname, "egg")
	engfunc(EngFunc_SetModel, ent, g_model_egg)
	set_pev(ent, pev_solid, SOLID_TRIGGER)
	set_pev(ent, pev_movetype, MOVETYPE_BOUNCE)
	engfunc(EngFunc_DropToFloor, ent)
	
	set_pev(ent, pev_renderfx, kRenderFxGlowShell)
	set_pev(ent, pev_rendercolor, Float:{0.0, 150.0, 000.0})
}

public fwdTouch(ent, id) { 
	
	if(!pev_valid(ent) || !is_user_alive(id)) return FMRES_IGNORED
	
	new classname[32]
	pev(ent, pev_classname, classname, charsmax(classname))
	
	if(equali(classname, "egg")) {
		
		emit_sound(id, CHAN_AUTO, g_sound_egg, 1.0, ATTN_NORM, 0, PITCH_NORM)
		engfunc(EngFunc_RemoveEntity, ent)
		give(id)
	}
	return FMRES_IGNORED
}

public give(id) {
	
	new iRandom = random_num(get_pcvar_num(cvar_min_ap), get_pcvar_num(cvar_max_ap))	
	
	zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iRandom)
}
strangeguy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-27-2019 , 13:16   Re: [ZP] Delete 2 things
Reply With Quote #6

Why did you remove the "switch" and leave the "case"? This is like having an "else" without an "if".

If you have no clue what you're doing, you should use the requests section.
__________________

Last edited by OciXCrom; 12-27-2019 at 20:33.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
strangeguy
Senior Member
Join Date: Mar 2019
Old 12-27-2019 , 16:25   Re: [ZP] Delete 2 things
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
Why did you remove the "switch" and left the "case"? This is like having an "else" without an "if".

If you have no clue what you're doing, you should use the requests section.
Okay
strangeguy 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 02:52.


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