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

Counting how many kills a player has


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
twitchatic
Junior Member
Join Date: Jan 2017
Location: here...
Old 05-06-2017 , 07:10   Counting how many kills a player has
Reply With Quote #1

I'm currently working on a gamemode where you shove players off the level, (surprisingly easy) and I'm trying to give players a weapon when they kill enough players without dying.
Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "Twitchatic"
#define PLUGIN_VERSION "0.00"

#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#include <tf2items>
#include <tf2items_giveweapon>
#include <sdkhooks>

public Plugin myinfo = 
{
	name = "shovie",
	author = PLUGIN_AUTHOR,
	description = "push each other off haha yes",
	version = PLUGIN_VERSION,
	url = "www.nothing.tk"
};

public void OnPluginStart() {
	HookEvent("post_inventory_application", Event_PlayerResupply);
	HookEvent("player_death", Event_PlayerDeath);
	TF2Items_CreateWeapon(30759, "TF_WEAPON_HANDGUN_SCOUT_PRIMARY", 220, 0, 5, 1, "3 ; 0 250 ; 1", 32);
	TF2Items_CreateWeapon(30760, "TF_WEAPON_PIPEBOMBLAUNCHER", 20, 1, 5, 1, "3 ; 0.125 669 ; 5 2025 ; 1", 3);
}

public void OnMapStart() {
	
}

public void Event_PlayerResupply(Event event, const char[] name, bool dontBroadcast) {
	new client_id = GetEventInt(event, "userid");
	new client = GetClientOfUserId(client_id);
	TF2_SetPlayerClass(client, TFClass_Scout);
	CreateTimer (0.1, GiveShortstop, client);
}

public Action GiveShortstop(Handle Timer, any client) {
	//TF2Items_GiveWeapon(client, 220);
	TF2Items_GiveWeapon(client, 30759);
	TF2_RemoveWeaponSlot(client, 1);
	TF2_RemoveWeaponSlot(client, 2);
}

public Action Event_PlayerDeath(Event event,const char[] name, bool dontBroadcast) {
	int attackerId = event.GetInt("attacker");
	int attacker = GetClientOfUserId(attackerId);
	int weaponId = event.GetInt(weapon_def_index);
	int killCount = event.GetInt(kill_streak_wep);
	int killCount_victim = event.GetInt(kill_streak_victim);
	if(killCount = 5) {
		TF2Items_GiveWeapon(attacker, 30760);
	}
	else if(killCount_victim > 3) {
		TF2Items_GiveWeapon(attacker, 30760);
	}
}
I tried to do a kill counter by using a Killstreak Shortstop and then counting that, but it doesn't seem to work, it might just be because shoving people to their deaths doesn't actually count.
twitchatic is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-08-2017 , 00:35   Re: Counting how many kills a player has
Reply With Quote #2

Why not a simple...

Code:
int g_iClientKills[MAXPLAYERS+1];
__________________
Neuro Toxin is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 05-08-2017 , 12:37   Re: Counting how many kills a player has
Reply With Quote #3

yeah i think the only thing you need to do is make an int like how Neuro Toxin said and just add one value to it on certain killer and get the value when ever you want to use it.
__________________
ambn is offline
NewbSkiddy
Junior Member
Join Date: Mar 2017
Old 05-09-2017 , 07:35   Re: Counting how many kills a player has
Reply With Quote #4

My solution would be just creating an array for it, probably the easiest way anyways.
NewbSkiddy is offline
StrikeR14
AlliedModders Donor
Join Date: Apr 2016
Location: Behind my PC
Old 07-19-2017 , 09:00   Re: Counting how many kills a player has
Reply With Quote #5

Quote:
Originally Posted by twitchatic View Post
if(killCount = 5) {
TF2Items_GiveWeapon(attacker, 30760);
}
1.

Code:
if(killCount == 5) {
       TF2Items_GiveWeapon(attacker, 30760);
}
2. As Neuro said, you should add an array that will save each client's killstreak, and not mess up with one integer between every player on the server.
StrikeR14 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 10:03.


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