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

Giving 20 credit to winner team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hkkelvin1995
Senior Member
Join Date: Jun 2009
Location: Hong Kong
Old 04-25-2014 , 12:09   Giving 20 credit to winner team
Reply With Quote #1

I am adding a sub-plugin for the Store plugins on my TF2 server
It will give each player on the winner team
Code:
public Event_RoundWin(Handle:event, const String:name[], bool:dontBroadcast)
{
	new team = GetEventInt(event, "team");
	new accountIds[MaxClients];
	new count = 0;
	new credits = 20;
	
	for (new client = 1; client <= MaxClients; client++) // Foreshadows here.
	{
		if (GetClientTeam(client) == team && IsClientInGame(client))
		{
			accountIds[count] = GetSteamAccountID(client);
 			count++;
		}
	}
	
	Store_GiveCreditsToUsers(accountIds, count, credits);
}
But it doesn't work
Any idea?
hkkelvin1995 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-25-2014 , 13:12   Re: Giving 20 credit to winner team
Reply With Quote #2

Just to be clear, you're aware that the round event in TF2 is teamplay_round_win (not round_end), right?

Actually, I was writing a wiki page with the differences between different games but it's not complete... I should go back and work on that more.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
hkkelvin1995
Senior Member
Join Date: Jun 2009
Location: Hong Kong
Old 04-25-2014 , 15:16   Re: Giving 20 credit to winner team
Reply With Quote #3

Code:
HookEvent("teamplay_round_win", Event_RoundWin);
We are using this
but it seems doesn't work...
hkkelvin1995 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-25-2014 , 15:22   Re: Giving 20 credit to winner team
Reply With Quote #4

Code:
if (GetClientTeam(client) == team && IsClientInGame(client))
needs to be
Code:
if (IsClientInGame(client) && GetClientTeam(client) == team)
because otherwise, when a client index isn't in game, GetClientTeam will throw an error.

("&&" is short circuiting in SourcePawn, meaning that if IsClientInGame(client) returns false, it never runs GetClientTeam(client) )
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-25-2014 at 16:11.
Powerlord 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 06:46.


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