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

[TF2] Dropping Weapons at Specific Points


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Requiesta
Senior Member
Join Date: May 2012
Location: Texas
Old 03-18-2018 , 20:07   [TF2] Dropping Weapons at Specific Points
Reply With Quote #1

I made a map littered with info_point entities (about 32) which marked places for tf_dropped_weapons to spawn for a new game mode I'm designing. Below is the code I'm using for it.

Code:
// Weapon Setup
stock InitWeapons()
{
	new iEnt = -1;
	decl Float:fCoordinates[3];
	while((iEnt = FindEntityByClassname(iEnt, "info_target")) != INVALID_ENT_REFERENCE)
	{
		GetEntPropVector(iEnt, Prop_Send, "m_vecOrigin", fCoordinates);
		DropWeapon(fCoordinates);
	}
}

public Action:Call_Drop(iClient, iArgs)
{
	InitWeapons();
}

stock DropWeapon(Float:fWeaponCoordinates[3])
{
	new i = GetRandomInt(0, sizeof(g_iEngineerPrimaries) - 1);

	int Entity = CreateEntityByName("tf_dropped_weapon");
	SetEntProp(Entity, Prop_Send, "m_iItemDefinitionIndex", g_iEngineerPrimaries[i]);
	SetEntProp(Entity, Prop_Send, "m_iEntityLevel", 5);
	SetEntProp(Entity, Prop_Send, "m_iEntityQuality", 6);
	SetEntProp(Entity, Prop_Send, "m_bInitialized", 1);
	TeleportEntity(Entity, fWeaponCoordinates, NULL_VECTOR, NULL_VECTOR);
	SetEntityModel(Entity, g_strEngineerPrimaries[i]);
	DispatchSpawn(Entity);
	
	if(!IsValidEntityEx(Entity))
		LogError("[BR] Error creating weapon %i", g_iEngineerPrimaries[i]);
}
I've successfully caused a singular version of this to drop (namely a rocket launcher) but when I tried to activate all of them the server just crashed.

Any ideas on why and how to fix it?
__________________
YouTuber, Modder, Accountant, and somehow I still enjoy programming after all that.

Check out my YouTube Channel.
Requiesta is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-18-2018 , 21:44   Re: [TF2] Dropping Weapons at Specific Points
Reply With Quote #2

Did you precache the models first?
Mitchell is offline
Requiesta
Senior Member
Join Date: May 2012
Location: Texas
Old 03-19-2018 , 08:49   Re: [TF2] Dropping Weapons at Specific Points
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
Did you precache the models first?

Maaaaaybe....
__________________
YouTuber, Modder, Accountant, and somehow I still enjoy programming after all that.

Check out my YouTube Channel.
Requiesta 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 11:11.


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