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

Problem with entities and disconnecting players for same


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cile1993
Junior Member
Join Date: Dec 2011
Old 10-16-2013 , 05:44   Problem with entities and disconnecting players for same
Reply With Quote #1

Hi there, i have a problem of disconnecting a players from server because of too much entities at once, i would change max entities number but first i want to fix a bad plugin rather than to make more fps drops and lag on my server... So here is the .sma:

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

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fun>

#define PLUGIN "NekiTamoPlugin"
#define VERSION "1.0b"
#define AUTHOR "Megastorm"

new weapons_ct[][] = 
{
	"weapon_knife",
	"weapon_awp",
	"weapon_m4a1",
	"weapon_deagle",
	"weapon_hegrenade",
	"weapon_flashbang"
}
new weapons_t[][] = 
{
	"weapon_knife",
	"weapon_awp",
	"weapon_ak47",
	"weapon_deagle",
	"weapon_hegrenade",
	"weapon_flashbang"
}

new g_msgStatusIcon
new const w_modeli[][] = 
{
	"",
	"models/w_ak47.mdl",
	"models/w_m4a1.mdl",
	""
}

new cvar_vreme
new const maxAmmo[31]={0, 200, 0, 180, 1, 64, 1, 120, 180, 1, 200, 200, 180, 180, 180, 180, 200, 200, 30, 180, 200, 64, 180, 180, 90, 2, 70, 90, 120, 0, 150}

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_forward(FM_Touch, "EntTouch")
	register_forward(FM_Think, "EntThinks")
	RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1)
	g_msgStatusIcon = get_user_msgid("StatusIcon")
	register_message(g_msgStatusIcon, "msgStatusIcon")
	register_forward(FM_SetModel, "fw_SetModel")
	register_event("DeathMsg", "death", "a")
	
	cvar_vreme = register_cvar("amx_trajanje_oruzja", "15.0")
	register_event("HLTV", "eNewRound", "a", "1=0", "2=0")
	// Add your code here...
}


public eNewRound()
{
	new iEnt = engfunc(EngFunc_FindEntityByString, -1, "classname", "oruzje")
	while(iEnt > 0)
	{
		if(pev_valid(iEnt))
		engfunc(EngFunc_RemoveEntity, iEnt)
		iEnt = engfunc(EngFunc_FindEntityByString, -1, "classname", "oruzje")
	}
}

public EntThinks(ent)
{
	if(!pev_valid(ent))
		return;
	
	new szCName[32]
	pev(ent, pev_classname, szCName, charsmax(szCName))
	if(equal(szCName, "oruzje"))
	{
		engfunc(EngFunc_RemoveEntity, ent)
	}
}

public EntTouch(ent, id)
{
	if(!pev_valid(ent) || !is_user_alive(id))
		return;
	
	new szCName[32], szModel[32]
	pev(ent, pev_classname, szCName, charsmax(szCName))
	pev(ent, pev_model, szModel, charsmax(szModel))
	
	if(equal(szCName, "oruzje"))
	{
		if(equal(szModel, "models/m4a1.mdl"))
		{
			give_item(id, "weapon_m4a1")
			fm_set_user_bpammo(id, CSW_M4A1, 90)
		}
		else if(equal(szModel, "models/w_ak47.mdl"))
		{
			give_item(id, "weapon_ak47")
			fm_set_user_bpammo(id, CSW_AK47, 90)
		}
		
		engfunc(EngFunc_RemoveEntity, ent)
	}
}

public death()
{
	new victim = read_data(2)
	new team = get_user_team(victim)
	new Float:forigin[3]
	pev(victim, pev_origin, forigin)
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	set_pev(ent, pev_classname, "oruzje")
	set_pev(ent, pev_movetype, MOVETYPE_TOSS)
	set_pev(ent, pev_solid, SOLID_TRIGGER)
	set_pev(ent, pev_size, Float:{-16.0,-16.0,0.0},Float:{16.0,16.0,2.0})
	set_pev(ent, pev_origin, forigin)
	engfunc(EngFunc_DropToFloor, ent)
	set_pev(ent, pev_nextthink, get_gametime() + get_pcvar_float(cvar_vreme))
	engfunc(EngFunc_SetModel, ent, w_modeli[team])
}

public PlayerSpawn(id)
{
	set_task(0.1, "ItsShowTime", id)
}

public ItsShowTime(id)
{
	if(!is_user_alive(id))
		return;
	
	new iTeam = get_user_team(id)
	
	strip_user_weapons(id)
	switch(iTeam)
	{
		case 1:
		{
			for(new i = 0; i < sizeof weapons_t; i++)
				give_item(id, weapons_t[i])
		}
		case 2:
		{
			for(new i = 0; i < sizeof weapons_ct; i++)
				give_item(id, weapons_ct[i])
		}
	}
	new weapons[32]
	new weaponsnum
	get_user_weapons(id, weapons, weaponsnum)
	for(new i=0; i<weaponsnum; i++)
		if(maxAmmo[weapons[i]] > 0)
			fm_set_user_bpammo(id, weapons[i], maxAmmo[weapons[i]])
	
}

public msgStatusIcon(msgid, msgdest, id)
{
	static szIcon[8]
	get_msg_arg_string(2, szIcon, charsmax(szIcon))
	
	if(equal(szIcon, "buyzone") && get_msg_arg_int(1))
	{
		set_pdata_int(id, 235, get_pdata_int(id, 235) & ~(1<<0))
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}

public fw_SetModel(entity, model[])
{
	if(!pev_valid(entity))
		return FMRES_IGNORED
	
	static szClassName[33]
	pev(entity, pev_classname, szClassName, charsmax(szClassName))
	
	if(!equal(szClassName, "weaponbox"))
		return FMRES_IGNORED
	
	if(equal(model, "models/w_awp.mdl"))
	{
		new Float:fOrigin[3]
		pev(entity, pev_origin, fOrigin)
		set_pev(entity, pev_flags, pev(entity, pev_flags)|FL_KILLME)
		
		return FMRES_SUPERCEDE
	}
	return FMRES_IGNORED
}

stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) {
	new strtype[11] = "classname", ent = index
	switch(jghgtype)
	{
		case 1: strtype = "target"
		case 2: strtype = "targetname"
	}
	
	while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
	
	return; ent
}

stock fm_set_user_bpammo(id, weaponid, amnt) 
{
	static offset
	switch(weaponid)
	{
		case CSW_AWP: offset = 377
			case CSW_SCOUT,CSW_AK47,CSW_G3SG1: offset = 378
			case CSW_M249: offset = 379
			case CSW_FAMAS,CSW_M4A1,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552: offset = 380
			case CSW_M3,CSW_XM1014: offset = 381
			case CSW_USP,CSW_UMP45,CSW_MAC10: offset = 382
			case CSW_FIVESEVEN,CSW_P90: offset = 383
			case CSW_DEAGLE: offset = 384
			case CSW_P228: offset = 385
			case CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITE: offset = 386
			case CSW_FLASHBANG: offset = 387
			case CSW_HEGRENADE: offset = 388
			case CSW_SMOKEGRENADE: offset = 389
			default: return 0
	}
	set_pdata_int(id,offset,amnt,5)
	
	return 1
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Does anyone have any idea how to fix this?
Thanks.
cile1993 is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 10-16-2013 , 07:12   Re: Problem with entities and disconnecting players for same
Reply With Quote #2

You dont provide any information of what to fix.
You do not show what you did to fix it.
You are on the bad section.
mottzi is offline
Send a message via MSN to mottzi
cile1993
Junior Member
Join Date: Dec 2011
Old 10-16-2013 , 10:21   Re: Problem with entities and disconnecting players for same
Reply With Quote #3

I'm sorry i am not so familiar with aliied mods forums and i badly speak english so i am sorry but i do not know what to do any more...
Problem is:
After some time playing server kicks almost all the players (except steam) and shows them this message:

Requesting tempdecal.wad from server
GnOoN eNsAn connected
Error: server failed to transmit file 'customization'
GnOoN eNsAn is joining the Terrorist force
Host_Error: CL_EntityNum: 1366 is an invalid number, cl.max_edicts is

So i think it is because of too much entities that creates this plugin... But in plugin the entities are disapearring (like weapons) after 15 secs so that makes me no sense... I read something about setting a -num_edicts 4096 to both server and players launch options, i can do it for server but how to do it for players? :S
cile1993 is offline
devilicioux
Veteran Member
Join Date: Jun 2013
Location: Delhi,India
Old 10-16-2013 , 12:04   Re: Problem with entities and disconnecting players for same
Reply With Quote #4

Quote:
Originally Posted by cile1993 View Post
After some time playing server kicks almost all the players (except steam) and shows them this message
And we dont care about non steamers.

Read Rules.

No Steam = No Support.
__________________
You keep bringing ANTICHRISTUS down .. He will rise again and kick asses !

#RespectList ANTICHRISTUS fysiks Bugsy

Most Common Errors You Can Encounter Every Now and Then
devilicioux is offline
Reply


Thread Tools
Display Modes

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 12:41.


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