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

[ANY] Gifts!


Post New Thread Reply   
 
Thread Tools Display Modes
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 01-11-2012 , 06:34   Re: [ANY] Gifts!
Reply With Quote #11

ill do it
__________________
Taking private C++/PHP/SourcePawn requests, PM me.
Zephyrus is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 07-24-2012 , 00:31   Re: [ANY] Gifts!
Reply With Quote #12

I need this customized. I need a better algorithm for the number of gifts and I need it to read a text file and remove stuff from a line by line from a text file. Then I need some cool effects when the gift is found.
__________________

DontWannaName is offline
iamevilbear
Member
Join Date: Mar 2010
Old 12-03-2012 , 10:47   Re: [ANY] Gifts!
Reply With Quote #13

Hi I just want to report a bug with this plugin. We used your stock gift spawning function and it works great. There is a memory leak issue however that should be corrected in the OnStartTouch entity hook.

You are hooking the child entity to detect touches
Code:
SDKHook(ent, SDKHook_StartTouch, OnStartTouch);
But inside of the SDK hook, you are only killing the child entity and not the parent entity.
Code:
AcceptEntityInput(ent, "Kill");
If you have a server with a never ending map, you will quickly run out of available edicts if you don't kill the parent entity as well. (No free edicts error)

I fixed this in my setup by creating an array pointing to the parent entities then killing the parent entity which in turn kills the child. Right now you are only killing 1 of 2 entities created and it eventually will max out the entities used.

What I changed to fix the No Free Edicts crash from this stock. Note.. I used an array because I didn't know if hooking the touch to the parent would create a smaller area to grab the gift. So not sure there..:

Declared my parent entity array:
new a_entityParent[4096];

Modified my Stock to record the parent ent
Code:
stock Stock_SpawnGift(client)
{
	new ent;

	if((ent = CreateEntityByName("prop_physics_override")) != -1)
	{
		new Float:pos[3], String:targetname[100], String:tmp[256];

		GetClientAbsOrigin(client, pos);
		pos[2]-=50.0;

		Format(targetname, sizeof(targetname), "gift_%i", ent);

		DispatchKeyValue(ent, "model", g_sModel);
		DispatchKeyValue(ent, "physicsmode", "2");
		DispatchKeyValue(ent, "massScale", "1.0");
		DispatchKeyValue(ent, "targetname", targetname);
		DispatchSpawn(ent);
		
		SetEntProp(ent, Prop_Send, "m_usSolidFlags", 8);
		SetEntProp(ent, Prop_Send, "m_CollisionGroup", 1);
		
		if(FloatCompare(g_fLifetime, 0.0)!=0)
		{
			Format(tmp, sizeof(tmp), "OnUser1 !self:kill::%0.2f:-1", g_fLifetime);
			SetVariantString(tmp);
			AcceptEntityInput(ent, "AddOutput");
			AcceptEntityInput(ent, "FireUser1");
		}
		
		TeleportEntity(ent, pos, NULL_VECTOR, NULL_VECTOR);
		
		new rot = CreateEntityByName("func_rotating");
		DispatchKeyValueVector(rot, "origin", pos);
		DispatchKeyValue(rot, "targetname", targetname);
		DispatchKeyValue(rot, "maxspeed", "200");
		DispatchKeyValue(rot, "friction", "0");
		DispatchKeyValue(rot, "dmg", "0");
		DispatchKeyValue(rot, "solid", "0");
		DispatchKeyValue(rot, "spawnflags", "64");
		DispatchSpawn(rot);
		
		SetVariantString("!activator");
		AcceptEntityInput(ent, "SetParent", rot, rot);
		AcceptEntityInput(rot, "Start");
		
		a_entityParent[ent] = rot;
		SDKHook(ent, SDKHook_StartTouch, OnStartTouch);
	}
}
Killed the parent instead of the child in the sdk hook
Code:
public OnStartTouch(ent, client)
{
	if(g_eConditions[client]==Condition_InCondition)
		return;

	AcceptEntityInput(a_entityParent[ent], "KillHierarchy");
	
	if(GetArraySize(g_hPlugins)!=0)
	{
		new id = GetRandomInt(0, GetArraySize(g_hPlugins)-1);
		
		new Module:tmp[Module];
		GetArrayArray(g_hPlugins, id, tmp[0]);
		
		Call_StartFunction(tmp[PluginHndl], tmp[FunctionId]);
		Call_PushCell(client);
		Call_Finish();
	}
}
This solved the memory error No Free Edicts for me. Thanks for the plugin. The stock really helped and sent us in the right direction for coding purposes.
iamevilbear is offline
Kahl_Drogo
Senior Member
Join Date: Apr 2012
Old 12-04-2012 , 08:42   Re: [ANY] Gifts!
Reply With Quote #14

I have error when I try compile this plugin:
Code:
/home/groups/sourcemod/upload_tmp/phpk2jBHd.sp(3) : fatal error 120: cannot read from file: "sdkhooks"
Kahl_Drogo is offline
rowedahelicon
Senior Member
Join Date: Feb 2011
Location: The Observatory
Old 12-04-2012 , 23:06   Re: [ANY] Gifts!
Reply With Quote #15

Quote:
Originally Posted by Kahl_Drogo View Post
I have error when I try compile this plugin:
Code:
/home/groups/sourcemod/upload_tmp/phpk2jBHd.sp(3) : fatal error 120: cannot read from file: "sdkhooks"
https://forums.alliedmods.net/showth...52#post1721652

Get the .sp from here and drop it in your includes folder.
__________________
SCG, A furry community in the stars - https://www.scg.wtf
rowedahelicon is offline
Send a message via Skype™ to rowedahelicon
InB
AlliedModders Donor
Join Date: Aug 2012
Location: Los Angeles
Old 12-06-2012 , 14:47   Re: [ANY] Gifts!
Reply With Quote #16

How to make something happen when it's been picked up?

Like RTD when you typed rtd you get random prizes.
But how do u make it give u random prizes if you picked up the Gifts?
__________________
InB is offline
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 12-06-2012 , 23:24   Re: [ANY] Gifts!
Reply With Quote #17

code your plugin


example in attach
Attached Files
File Type: smx gifts_test.smx (8.3 KB, 522 views)
File Type: sp Get Plugin or Get Source (gifts_test.sp - 663 views - 808 Bytes)

Last edited by Despirator; 12-06-2012 at 23:27.
Despirator is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 12-07-2012 , 01:05   Re: [ANY] Gifts!
Reply With Quote #18

Quote:
Originally Posted by iamevilbear View Post
Hi I just want to report a bug with this plugin. We used your stock gift spawning function and it works great. There is a memory leak issue however that should be corrected in the OnStartTouch entity hook.

You are hooking the child entity to detect touches
Code:
SDKHook(ent, SDKHook_StartTouch, OnStartTouch);
But inside of the SDK hook, you are only killing the child entity and not the parent entity.
Code:
AcceptEntityInput(ent, "Kill");
If you have a server with a never ending map, you will quickly run out of available edicts if you don't kill the parent entity as well. (No free edicts error)

I fixed this in my setup by creating an array pointing to the parent entities then killing the parent entity which in turn kills the child. Right now you are only killing 1 of 2 entities created and it eventually will max out the entities used.

What I changed to fix the No Free Edicts crash from this stock. Note.. I used an array because I didn't know if hooking the touch to the parent would create a smaller area to grab the gift. So not sure there..:

Declared my parent entity array:
new a_entityParent[4096];

Modified my Stock to record the parent ent
Code:
stock Stock_SpawnGift(client)
{
    new ent;

    if((ent = CreateEntityByName("prop_physics_override")) != -1)
    {
        new Float:pos[3], String:targetname[100], String:tmp[256];

        GetClientAbsOrigin(client, pos);
        pos[2]-=50.0;

        Format(targetname, sizeof(targetname), "gift_%i", ent);

        DispatchKeyValue(ent, "model", g_sModel);
        DispatchKeyValue(ent, "physicsmode", "2");
        DispatchKeyValue(ent, "massScale", "1.0");
        DispatchKeyValue(ent, "targetname", targetname);
        DispatchSpawn(ent);
        
        SetEntProp(ent, Prop_Send, "m_usSolidFlags", 8);
        SetEntProp(ent, Prop_Send, "m_CollisionGroup", 1);
        
        if(FloatCompare(g_fLifetime, 0.0)!=0)
        {
            Format(tmp, sizeof(tmp), "OnUser1 !self:kill::%0.2f:-1", g_fLifetime);
            SetVariantString(tmp);
            AcceptEntityInput(ent, "AddOutput");
            AcceptEntityInput(ent, "FireUser1");
        }
        
        TeleportEntity(ent, pos, NULL_VECTOR, NULL_VECTOR);
        
        new rot = CreateEntityByName("func_rotating");
        DispatchKeyValueVector(rot, "origin", pos);
        DispatchKeyValue(rot, "targetname", targetname);
        DispatchKeyValue(rot, "maxspeed", "200");
        DispatchKeyValue(rot, "friction", "0");
        DispatchKeyValue(rot, "dmg", "0");
        DispatchKeyValue(rot, "solid", "0");
        DispatchKeyValue(rot, "spawnflags", "64");
        DispatchSpawn(rot);
        
        SetVariantString("!activator");
        AcceptEntityInput(ent, "SetParent", rot, rot);
        AcceptEntityInput(rot, "Start");
        
        a_entityParent[ent] = rot;
        SDKHook(ent, SDKHook_StartTouch, OnStartTouch);
    }
}
Killed the parent instead of the child in the sdk hook
Code:
public OnStartTouch(ent, client)
{
    if(g_eConditions[client]==Condition_InCondition)
        return;

    AcceptEntityInput(a_entityParent[ent], "KillHierarchy");
    
    if(GetArraySize(g_hPlugins)!=0)
    {
        new id = GetRandomInt(0, GetArraySize(g_hPlugins)-1);
        
        new Module:tmp[Module];
        GetArrayArray(g_hPlugins, id, tmp[0]);
        
        Call_StartFunction(tmp[PluginHndl], tmp[FunctionId]);
        Call_PushCell(client);
        Call_Finish();
    }
}
This solved the memory error No Free Edicts for me. Thanks for the plugin. The stock really helped and sent us in the right direction for coding purpotses.
thank you for the info altho the proper fix would be using GetEntPropEnt(ent, Prop_Data, "m_iParent"); to find out the parent entity, i will update the plugin later
__________________
Taking private C++/PHP/SourcePawn requests, PM me.
Zephyrus is offline
applemes
Senior Member
Join Date: Mar 2013
Old 04-01-2013 , 22:40   Re: [ANY] Gifts!
Reply With Quote #19

How do i make it so when u drop gift, and some1 picks up, you get _ store credits.?
applemes is offline
4bdul
AlliedModders Donor
Join Date: Dec 2011
Location: United Kingdom
Old 04-10-2013 , 13:16   Re: [ANY] Gifts!
Reply With Quote #20

This isn't working for me at the moment on TF2 - no errors. Gifts don't drop on death at all, even though chance is 1.
__________________
4bdul 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 23:55.


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