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

[CSGO] Chicken death/spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheeDeer
Junior Member
Join Date: Dec 2016
Old 03-24-2017 , 20:29   [CSGO] Chicken death/spawn
Reply With Quote #1

I am attempting to spawn a chicken, at at the end of the round kill the spawned chicken.

Spawn code:
Quote:
new Ent = CreateEntityByName("chicken");
if(IsValidEntity(Ent))
{

new Floatrigin[3];
DispatchKeyValue(Ent, "rendercolor", "0, 0, 255");
GetClientAbsOrigin(client, origin);
DispatchSpawn(Ent);
origin[0] += 20.0;
TeleportEntity(Ent, origin, NULL_VECTOR, NULL_VECTOR);
ChickenCount = 1;
ChickenAlive = true;
Chicken = Ent;
}
On round end kill code:
Quote:
if (ChickenAlive)
{
new realEntity = EntRefToEntIndex(Chicken);
if (realEntity > 0 && IsValidEntity(realEntity))
{
AcceptEntityInput(realEntity, "Kill");
}
ChickenAlive = false;
ChickenCount = 0;
}
TheeDeer is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-24-2017 , 20:31   Re: [CSGO] Chicken death/spawn
Reply With Quote #2

u don't need to kill them
they are automatically reset i believe
u just need the ChickenAlive = false;
ChickenCount = 0; part in round end i think
8guawong is offline
TheeDeer
Junior Member
Join Date: Dec 2016
Old 03-24-2017 , 20:38   Re: [CSGO] Chicken death/spawn
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
u don't need to kill them
they are automatically reset i believe
u just need the ChickenAlive = false;
ChickenCount = 0; part in round end i think
Chickens do not reset automatically, if they did I would not be attempting do remove them on round end...
TheeDeer is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-24-2017 , 20:55   Re: [CSGO] Chicken death/spawn
Reply With Quote #4

Quote:
Originally Posted by TheeDeer View Post
Chickens do not reset automatically, if they did I would not be attempting do remove them on round end...
how do you know they are not reset?
its like create weapon_ entity which gets reset/deleted when next round starts
8guawong is offline
TheeDeer
Junior Member
Join Date: Dec 2016
Old 03-24-2017 , 21:09   Re: [CSGO] Chicken death/spawn
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
how do you know they are not reset?
its like create weapon_ entity which gets reset/deleted when next round starts
I know because I have tested it. Chickens do not reset on round end.
TheeDeer is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 03-25-2017 , 05:22   Re: [CSGO] Chicken death/spawn
Reply With Quote #6

You are saving the entity index in the variable instead of the ent reference and then later you are trying to receive an entity index from an entity index instead of a ent reference.

So
PHP Code:
Chicken Ent 
should be
PHP Code:
Chicken EntIndexToEntRef(Ent); 
and then later when you delete it:
PHP Code:
int realEntity EntRefToEntIndex (Chicken);
if(
IsValidEntity(realEntity))
// More code here... 

Last edited by xerox8521; 03-25-2017 at 05:24.
xerox8521 is offline
lay295
Senior Member
Join Date: Sep 2013
Old 03-25-2017 , 20:37   Re: [CSGO] Chicken death/spawn
Reply With Quote #7

If you're just trying to kill all the chickens and not specifically the chickens you spawned you could just loop though all of them. I kill it on round start on my server though.

Code:
public void OnPluginStart()
{
	HookEvent("round_start", Event_RoundStarted);
}

public Action Event_RoundStarted(Handle event , const char[] name , bool dontBroadcast)
{
	int entity = -1;
	while ((entity = FindEntityByClassname(entity, "chicken")) != INVALID_ENT_REFERENCE)
	{
		AcceptEntityInput(entity, "Kill");
	}
}
__________________

lay295 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 23:23.


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