Raised This Month: $51 Target: $400
 12% 

Solved doesn't reset on new round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Adomaz1
Senior Member
Join Date: Feb 2014
Old 04-01-2017 , 04:14   doesn't reset on new round
Reply With Quote #1

Why doesn't g_bolsas[id] sets to 2 on new round? it always stays 0 :s

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <cstrike>
#include <gunxpmod>

// The sizes of models
#define PALLET_MINS Float:{ -27.260000, -22.280001, -22.290001 }
#define PALLET_MAXS Float:{  27.340000,  26.629999,  29.020000 }


// from fakemeta util by VEN
#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
// this is mine
#define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor,%1)

// cvars
new maxpallets, phealth;

// num of pallets with bags
new palletscout = 0;

/* Models for pallets with bags .
  Are available 2 models, will be set a random of them  */
new g_models[][] =
{
	"models/wildGames/Umbrella-Swarm/pallet_with_bags2.mdl",
	"models/wildGames/Umbrella-Swarm/pallet_with_bags.mdl"
}

new stuck[33], g_bolsas[33], g_has_sandbags[33], cvar[3], ZPSTUCK;

new const Float:size[][3] = {
	{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
	{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
	{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
	{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
	{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

public plugin_init() 
{
	register_plugin("GXM: Sand Bags", "1.1", "LARP")
	register_gxm_item("Sand Bags", "Heat seeking grenade", 90, 0, 5, 3, CSW_SANDBAGS)
	register_dictionary("gunxpmod.txt")
	set_task(0.1,"checkstuck",0,"",0,"b")

	ZPSTUCK = register_cvar("gxm_sandbags_stuck","1")
	maxpallets = register_cvar("gxm_sandbags_limit","20"); // max number of pallets with bags
	phealth = register_cvar("gxm_sandbags_health","500"); // set the health to a pallet with bags
	
	register_event("HLTV","event_newround", "a","1=0", "2=0"); // it's called every on new round
	
	register_menucmd(register_menuid("\r[GunXP] \ySandbags\r:"), 1023, "menu_command" );
	register_menucmd(register_menuid("\r[GunXP] \yBulvių maišai\r:"), 1023, "menu_command" );
	register_clcmd("say /sandbags","show_the_menu");
	register_clcmd("/sandbags","show_the_menu");
	register_clcmd("say /sb","show_the_menu");
	register_clcmd("/sb","show_the_menu");
	cvar[1] = register_cvar("gxm_sandbags_stuckeffects","1")
	cvar[2] = register_cvar("gxm_sandbags_stuckwait","7")

}

public plugin_precache()
{
	for(new i;i < sizeof g_models;i++)
		engfunc(EngFunc_PrecacheModel,g_models[i]);
}

public gxm_item_enabled(id)
{
	g_has_sandbags[id] = true;
	g_bolsas[id] = 2;
}

public client_connect(id)
{
	g_has_sandbags[id] = false;
	g_bolsas[id] = 0;
}

public show_the_menu(id,level,cid)
{	
	if(is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && g_has_sandbags[id])
	{		
		new szMenuBody[256];
		new keys;
		
		new nLen = format( szMenuBody, 255, "%L", id, "SANDBAGS" );
		nLen += format( szMenuBody[nLen], 255-nLen, "%L", id, "PUT_SANDBAG", g_bolsas[id] );
		nLen += format( szMenuBody[nLen], 255-nLen, "%L", id, "REMOVE_SANDBAG" );
		nLen += format( szMenuBody[nLen], 255-nLen, "%L", id, "EXIT_SANDBAG" );

		keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<9)

		show_menu( id, keys, szMenuBody, -1 );
		
		return PLUGIN_CONTINUE;
	}
	return PLUGIN_CONTINUE;
}

public menu_command(id,key,level,cid)
{
	switch( key )
	{
		case 0: 
		{
			if(is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && g_has_sandbags[id])
			{
				new money = g_bolsas[id]
				if ( money < 1 )
				{
					client_print_color(id, id, "%L", id, "SANDBAG1");
					show_the_menu(id,level,cid);
					return PLUGIN_CONTINUE
				}
				place_palletwbags(id);
				show_the_menu(id,level,cid);
				return PLUGIN_CONTINUE	
			}
			return PLUGIN_CONTINUE	
		}
		case 1:
		{
			if(is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT && g_has_sandbags[id])
			{
				new ent, body, class[32];
				get_user_aiming(id, ent, body);
				if (pev_valid(ent)) 
				{
					pev(ent, pev_classname, class, 31);
					
					if (equal(class, "amxx_pallets")) 
					{
						g_bolsas[id]+= 1
						fm_remove_entity(ent);
					}
					else { client_print_color(id, id, "%L", id, "SANDBAG2"); }
				}
				else { client_print_color(id, id, "%L", id, "SANDBAG2"); }
				
				show_the_menu(id,level,cid);
			}
		}
	}
	
	return PLUGIN_HANDLED;
}

public place_palletwbags(id)
{
	if( palletscout == get_pcvar_num(maxpallets) )
	{
		client_print_color(id, id, "%L", id, "SANDBAG3");
		return PLUGIN_HANDLED;
	}
	
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_wall"));
	
	set_pev(ent,pev_classname,"amxx_pallets");		
	engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]);
	
	static Float:xorigin[3];
	get_user_hitpoint(id,xorigin);
	
	if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY)
	{
		client_print_color(id, id, "%L", id, "SANDBAG4");
		return PLUGIN_HANDLED;
	}
	
	static Float:p_mins[3], Float:p_maxs[3];
	p_mins = PALLET_MINS;
	p_maxs = PALLET_MAXS;
	engfunc(EngFunc_SetSize, ent, p_mins, p_maxs);
	set_pev(ent, pev_mins, p_mins);
	set_pev(ent, pev_maxs, p_maxs );
	set_pev(ent, pev_absmin, p_mins);
	set_pev(ent, pev_absmax, p_maxs );
	engfunc(EngFunc_SetOrigin, ent, xorigin);
	set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block
	set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff
	
	new Float:p_cvar_health = get_pcvar_float(phealth);
	switch(p_cvar_health)
	{
		case 0.0 :
		{
			set_pev(ent,pev_takedamage,DAMAGE_NO);
		}
		
		default :
		{
			set_pev(ent,pev_health,p_cvar_health);
			set_pev(ent,pev_takedamage,DAMAGE_YES);
		}
	}
	
	static Float:rvec[3];
	pev(id,pev_v_angle,rvec);
	
	rvec[0] = 0.0;
	
	set_pev(ent,pev_angles,rvec);
	
	// drop entity to floor
	fm_drop_to_floor(ent);
	
	// num ..
	g_bolsas[id]-= 1
	palletscout++;

	return PLUGIN_HANDLED;
}

stock get_user_hitpoint(id, Float:hOrigin[3]) 
{
	if ( ! is_user_alive( id ))
		return 0;
    
	new Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
	new Float:fTemp[3];
    
	pev(id, pev_origin, fOrigin);
	pev(id, pev_v_angle, fvAngle);
	pev(id, pev_view_ofs, fvOffset);
    
	xs_vec_add(fOrigin, fvOffset, fvOrigin);
    
	engfunc(EngFunc_AngleVectors, fvAngle, feOrigin, fTemp, fTemp);
    
	xs_vec_mul_scalar(feOrigin, 9999.9, feOrigin);
	xs_vec_add(fvOrigin, feOrigin, feOrigin);
    
	engfunc(EngFunc_TraceLine, fvOrigin, feOrigin, 0, id);
	global_get(glb_trace_endpos, hOrigin);
    
	return 1;
} 

public event_newround(id)
{
	new pallets = -1;
	
	while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
		fm_remove_entity(pallets);
		
	palletscout = 0;
	g_bolsas[id] = 2;
}

public checkstuck(id) {
	if ( get_pcvar_num(ZPSTUCK) == 1 )
	{
		static players[32], pnum, player
		get_players(players, pnum)
		static Float:origin[3]
		static Float:mins[3], hull
		static Float:vec[3]
		static o,i
		for(i=0; i<pnum; i++){
			player = players[i]
			if (is_user_connected(player) && is_user_alive(player)) {
				pev(player, pev_origin, origin)
				hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
				if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
					++stuck[player]
					if(stuck[player] >= get_pcvar_num(cvar[2])) {
						pev(player, pev_mins, mins)
						vec[2] = origin[2]
						for (o=0; o < sizeof size; ++o) {
							vec[0] = origin[0] - mins[0] * size[o][0]
							vec[1] = origin[1] - mins[1] * size[o][1]
							vec[2] = origin[2] - mins[2] * size[o][2]
							if (is_hull_vacant(vec, hull,player)) {
								engfunc(EngFunc_SetOrigin, player, vec)
								effects(player)
								set_pev(player,pev_velocity,{0.0,0.0,0.0})
								o = sizeof size
							}
						}
					}
				}
				else
				{
					stuck[player] = 0
				}
			}
		}
	}
}

stock bool:is_hull_vacant(const Float:origin[3], hull,id) {
	static tr
	engfunc(EngFunc_TraceHull, origin, origin, 0, hull, id, tr)
	if (!get_tr2(tr, TR_StartSolid) || !get_tr2(tr, TR_AllSolid)) //get_tr2(tr, TR_InOpen))
		return true
	
	return false
}

public effects(id) {
	if(get_pcvar_num(cvar[1])) {
		message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0},id )      
		write_short(1<<10)   // fade lasts this long duration
		write_short(1<<10)   // fade lasts this long hold time
		write_short(1<<1)   // fade type (in / out)
		write_byte(20)            // fade red
		write_byte(255)    // fade green
		write_byte(255)        // fade blue
		write_byte(255)    // fade alpha
		message_end()
		client_cmd(id,"spk fvox/blip.wav")
	}
}

Last edited by Adomaz1; 04-01-2017 at 06:35.
Adomaz1 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-01-2017 , 06:24   Re: doesn't reset on new round
Reply With Quote #2

PHP Code:

public event_newround()
{
    new 
pallets = -1;
    
    while((
pallets fm_find_ent_by_class(pallets"amxx_pallets")))
        
fm_remove_entity(pallets);
        
    
palletscout 0;
    for(new 
i33i++)
        
g_bolsas[i] = 2;

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-01-2017 at 06:27.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Adomaz1
Senior Member
Join Date: Feb 2014
Old 04-01-2017 , 06:34   Re: doesn't reset on new round
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
PHP Code:

public event_newround()
{
    new 
pallets = -1;
    
    while((
pallets fm_find_ent_by_class(pallets"amxx_pallets")))
        
fm_remove_entity(pallets);
        
    
palletscout 0;
    for(new 
i33i++)
        
g_bolsas[i] = 2;

thank you!
Adomaz1 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:47.


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