Raised This Month: $ Target: $400
 0% 

remove healthkits problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pcquad
Member
Join Date: Jan 2012
Old 05-09-2013 , 05:57   remove healthkits problem
Reply With Quote #1

Hi, i have a script that should remove all healthkits , but when i load it, as soon as a player joins the server crashes

Code:
#include <sourcemod>
#include <sdktools>
	#include <sdkhooks>
	

	new bool:ignoreNextEntity = false;
	new bool:mapRunning = false;
	
	public OnMapStart() {

	        mapRunning = true;
	}
	
	public OnMapEnd() {
	        mapRunning = false;
	}
	
	public OnEntityCreated(entity, const String:classname[]) {
	        if(ignoreNextEntity) {
	                ignoreNextEntity = false;
	                LogMessage("Ignored entity");
	                return;
	        }
	        if(!mapRunning) {
	                return;
	        }

decl String:clsname[64];
GetEntityClassname(entity, clsname , sizeof(clsname));

		if(StrEqual( clsname, "item_healthkit_full", false )){
	        AcceptEntityInput(entity, "kill");
//RemoveEdict(entity);
		}
	if(StrEqual( clsname, "item_healthkit_large", false )){
	        AcceptEntityInput(entity, "kill");
//RemoveEdict(entity);
		}
	if(StrEqual( clsname, "item_healthkit_medium", false )){
	        AcceptEntityInput(entity, "kill");
//RemoveEdict(entity);
		}

	}
this function seems to be the problem:
AcceptEntityInput(entity, "kill");


does anyone have an idea?

edit :// its for TF2
__________________

Last edited by pcquad; 05-09-2013 at 06:02.
pcquad is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 05-09-2013 , 06:25   Re: remove healthkits problem
Reply With Quote #2

kill seems to be a valid input. try killing it when it spawns, not when it is created.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
pcquad
Member
Join Date: Jan 2012
Old 05-09-2013 , 06:27   Re: remove healthkits problem
Reply With Quote #3

okay testing now
__________________

Last edited by pcquad; 05-09-2013 at 06:38.
pcquad is offline
pcquad
Member
Join Date: Jan 2012
Old 05-09-2013 , 06:55   Re: remove healthkits problem
Reply With Quote #4

tested

okay strangely the healthkits weren't removed
__________________

Last edited by pcquad; 05-09-2013 at 07:16.
pcquad is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 05-09-2013 , 07:28   Re: remove healthkits problem
Reply With Quote #5

but it's not crashing anymore, is it? kill should do the work, print some messages to chat or server to check if the code is being runned or not, otherwise post it here.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
floube
SourceMod Donor
Join Date: Jan 2013
Location: Austria
Old 05-09-2013 , 11:48   Re: remove healthkits problem
Reply With Quote #6

Well, something like this would work...

PHP Code:
new entityIndex = -1;

while ((
entityIndex FindEntityByClassname(entityIndex"item_healthkit_full")) != -1) {
    if (
IsValidEntity(entityIndex)) {
        
AcceptEntityInput(entityIndex"Kill");
    }

but only if there is at least one player on the server.

Also, replace the
PHP Code:
item_healthkit_large 
with
PHP Code:
item_healthkit_medium 

Last edited by floube; 05-09-2013 at 11:49.
floube is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 05-09-2013 , 16:52   Re: remove healthkits problem
Reply With Quote #7

The entities are created at the start of every round in tf2, you can kill them there.
You may just want to hook teamplay_round_start, then findentitybyclassname and kill what you do not want around.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 05-09-2013 , 17:05   Re: remove healthkits problem
Reply With Quote #8

but isn't those healthkits spawned again everytime it is picked?
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-09-2013 , 17:14   Re: remove healthkits problem
Reply With Quote #9

Quote:
Originally Posted by Bimbo1 View Post
but isn't those healthkits spawned again everytime it is picked?
I always assumed that healthkits were just deactivated when they were picked up and reactivated later on when they "respawned".
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
floube
SourceMod Donor
Join Date: Jan 2013
Location: Austria
Old 05-09-2013 , 17:56   Re: remove healthkits problem
Reply With Quote #10

With AcceptEntityInput(entityIndex, "Kill"); they won't respawn, I tested it.
floube 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 14:14.


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