Raised This Month: $32 Target: $400
 8% 

[TF2] Create tf_projectile_arrow problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
w1200441
Senior Member
Join Date: Dec 2011
Old 08-24-2014 , 06:02   [TF2] Create tf_projectile_arrow problem
Reply With Quote #1

I would like to make a plugin to spawn muti-arrow

this is my code:

Code:
public OnEntityCreated(entity, const String:classname[])
{
	if (StrEqual(classname, "tf_projectile_arrow"))
	{
		SDKHook(entity, SDKHook_Spawn, Hook_ArrowSpawn);
	}
}

public Hook_ArrowSpawn(entity)
{
	new iOwner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
	for(new i=1; i<=MaxClients; i++)
	{
		if(IsValidClient(i) && iOwner == i)
		{
			decl Float:Pos[3], Float:Ang[3];
			GetClientAbsOrigin(i, Pos);
			GetClientEyeAngles(i, Ang);
	
			new Arrow01 = CreateEntityByName("tf_projectile_arrow");
			SetEntDataEnt2(Arrow01, FindSendPropInfo("CTFProjectile_Arrow", "m_hOwnerEntity"), i, true);
			SetEntData(Arrow01, FindSendPropInfo("CTFProjectile_Arrow", "m_iTeamNum"), GetClientTeam(i), true);
			SetEntDataVector(Arrow01, FindSendPropInfo("CTFProjectile_Arrow", "m_angRotation"), Ang, true); 
			DispatchSpawn(Arrow01);
						
			new Float:fwd[3], Float:right[3], Float:up[3];
			GetEntDataVector(Arrow01, FindSendPropInfo("CTFProjectile_Arrow", "m_angRotation"), Ang);
			GetAngleVectors(Ang, fwd, right, up);
			ScaleVector(fwd, 800.0);
			TeleportEntity(Arrow01, Pos, Ang, fwd);
		}
	}
}
After I shot the arrow, the server crashed.
Does anyone knows what is the problem?
w1200441 is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 08-24-2014 , 07:27   Re: [TF2] Create tf_projectile_arrow problem
Reply With Quote #2

do if owner > 0 && owner <= maxclients && isclientingame(owner)

But this is badically all wrong, because it is making an arrow when an arrow is made, so it will just recur infinitely.

If you want to check a owner var, do so, but then all you need to do is
Get the ang rotation, can just use getentpropvector...
Get the angle vectors
Scale, teleport
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
w1200441
Senior Member
Join Date: Dec 2011
Old 08-25-2014 , 11:49   Re: [TF2] Create tf_projectile_arrow problem
Reply With Quote #3

Now I understand the proplem...
Infinite spawn caused the server crashed.
I will try other ways. Thx
w1200441 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 01:53.


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