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

[L4D2] How get CI kill ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KoreanPeople
Junior Member
Join Date: Jun 2019
Old 07-11-2019 , 15:55   [L4D2] How get CI kill ?
Reply With Quote #1

Code:
decl MaxEntities, String:mName[64], Float:entPos[3];

MaxEntities = GetMaxEntities();
for(new i = 1; i <= MaxEntities; i++) {
	if(IsValidEdict(i) && IsValidEntity(i)) {
		GetEntPropString(i, Prop_Data, "m_ModelName", mName, sizeof(mName));
		if(StrContains(mName, "infected") != -1) {
			GetEntPropVector(i, Prop_Send, "m_vecOrigin", entPos);
			entPos[2] += 50;
			if(GetVectorDistance(trsPos[client], entPos) < radius) {
				DamageEffect(i, 150.0 + (5.0 * medic_emfp[client]));
			}
		}
	}
}
Code:
stock DamageEffect(target, Float:damage)
{
	decl String:tName[20];
	Format(tName, 20, "target%d", target);
	new pointHurt = CreateEntityByName("point_hurt");
	DispatchKeyValue(target, "targetname", tName);
	DispatchKeyValueFloat(pointHurt, "Damage", damage);
	DispatchKeyValue(pointHurt, "DamageTarget", tName);
	DispatchKeyValue(pointHurt, "DamageType", "65536");
	DispatchSpawn(pointHurt);
	AcceptEntityInput(pointHurt, "Hurt");
	AcceptEntityInput(pointHurt, "Kill");
}
Hello! my engilish really really.. bad..
i can give a damage/sec to common infected.

but i can not comfirm the CI dead.
Can not I get information(CI health or CI dead) about the CI from other function?
If you have to move to Event Infected Hurt, it will.
KoreanPeople is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 07-12-2019 , 21:26   Re: [L4D2] How get CI kill ?
Reply With Quote #2

u can check the m_ihealth netprop or datamap to see if its above 0 maybe...should work in your current code. Also no need to check if its a valid edict and a valid entity...just checking its a valid entity will be enough.
MasterMind420 is offline
Skyy
AlliedModders Donor
Join Date: Jan 2010
Location: Toronto, Canada
Old 07-16-2019 , 02:07   Re: [L4D2] How get CI kill ?
Reply With Quote #3

Code:
bool:IsCommonInfected(entity) {

	if (entity <= 0 || !IsValidEntity(entity)) return false;

	decl String:className[16];
	GetEntityClassname(entity, className, sizeof(className));
	return strcmp(className, "infected") == 0;
}
You can run the function inside of OnEntityDestroyed, or create an array, and store all the common infected entity id's in it, via OnEntityCreated; then, you'd just compare it to the entity destroyed, but there are several ways to go about it, really, depending on what you're doing.

Last edited by Skyy; 07-16-2019 at 02:10.
Skyy is offline
KoreanPeople
Junior Member
Join Date: Jun 2019
Old 07-16-2019 , 09:22   Re: [L4D2] How get CI kill ?
Reply With Quote #4

Quote:
Originally Posted by MasterMind420 View Post
u can check the m_ihealth netprop or datamap to see if its above 0 maybe...should work in your current code. Also no need to check if its a valid edict and a valid entity...just checking its a valid entity will be enough.
i can this.
if(GetEntProp(i, Prop_Data, "m_iHealth") <= SKILLDMG &&
GetEntProp(i, Prop_Data, "m_iHealth") > 0) {
ComZombieClientCount[client] += 1;
}

thanks u so much.
but this code one problem exists.

If the skill is strong enough to kill CI or SI, the count will not work.
However, if i do not do calculration, the calculartion repeats several times before it disappears.
KoreanPeople is offline
KoreanPeople
Junior Member
Join Date: Jun 2019
Old 07-16-2019 , 09:29   Re: [L4D2] How get CI kill ?
Reply With Quote #5

Quote:
Originally Posted by Skyy View Post
Code:
bool:IsCommonInfected(entity) {

	if (entity <= 0 || !IsValidEntity(entity)) return false;

	decl String:className[16];
	GetEntityClassname(entity, className, sizeof(className));
	return strcmp(className, "infected") == 0;
}
You can run the function inside of OnEntityDestroyed, or create an array, and store all the common infected entity id's in it, via OnEntityCreated; then, you'd just compare it to the entity destroyed, but there are several ways to go about it, really, depending on what you're doing.
thx solution.
there is one other question.

i use env_explosion
The amount of damage done by this entity varies from the center radius to the edge when set to 1000.0, this is right?

and, I want to do different damage to the survivor and the infected person.
KoreanPeople is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 07-16-2019 , 10:33   Re: [L4D2] How get CI kill ?
Reply With Quote #6

Just use this to track zombie kills...

Code:
public void OnPluginStart()
{
	HookEvent("player_death", ePlayerDeath);
}

public void ePlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
	int victim = event.GetInt("entityid");
	int attacker = GetClientOfUserId(event.GetInt("attacker"));

	char name[10];
	char clsname[10];

	int victimname = event.GetString("victimname", name, sizeof(name));
	GetEntityClassname(victim, clsname, sizeof(clsname));

	if (StrEqual(name, "infected") || StrEqual(clsname, "infected"))
		ComZombieClientCount[attacker]++;
}
I got both the victimname field as well as entityid to track the zombie deaths...u don't need both that and entityid but as is should work...u can modify to your liking. if u just want to track when a common infected is killed this is what u want. PS...i'm not sure the victimname field actually gives an infected name when a zombie is killed...never tested it but getting the entityid and checking the classname does work.

Last edited by MasterMind420; 07-16-2019 at 10:42.
MasterMind420 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 02:33.


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