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

Problem giving out XP with a for loop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sytremelaker
Senior Member
Join Date: Jun 2006
Location: Staples Center, Los Ange
Old 12-23-2009 , 03:12   Problem giving out XP with a for loop
Reply With Quote #1

I'm running an XP-type mod on my server with a sort-of reverse CSDM Tickets running on it; whenever a player kills someone, they add to the team score, first team score to (x) wins. When a team wins, the losing team is supposed to be slayed while the winning team gets an XP rewards (dubbed totalkills[id] in the code below)

The problem is that I set the XP reward to be given to the winning players to 300 but it never gives that actual number. Instead, it gives something much larger, anywhere from 300 to 5000 and thats causing some
inflation in the server.

Anyone mind giving it a look? All the relevant code is posted below:

Some extra notes: -Using the CSDM define a bunch of times within the mod, so the csdm_PostDeath is off CSDM.
- totalkills[id] is the variable for the XP i'm trying to hand out on win.

Code:
new g_WinTeam
new g_LoseTeam
new g_Respawns[3]

public csdm_RoundRestart()
{
	g_Respawns[_TEAM_T] = 0
	g_Respawns[_TEAM_CT] = 0
}

public csdm_PostDeath(killer, victim, headshot, const weapon[])
{		
	new death = get_user_team(victim)
	new kill = get_user_team(killer)
	
	if (g_Respawns[kill] >= 1500)
	{
		g_WinTeam = kill;
		g_LoseTeam = death;
		round_win();
	}
	else
	{
		g_Respawns[kill] += 10;
	}
	return PLUGIN_CONTINUE
}

public round_win()
{
	new g_players[32], num;
	get_players(g_players, num);
		
	new x;
	for(new i = 0; i < num; i++)
	{
		x = g_players[i];
		
		if(get_user_team(x) == g_LoseTeam)
		{
			user_silentkill(x);
			cs_set_user_deaths(x, get_user_deaths(x) - 1);
		}
		else if(get_user_team(x) == g_WinTeam)
		{
			new killpts = 300;
			totalkills[x] += killpts;
			client_cmd(x, "spk %s", gKillstreak);
		}
	}
}
__________________
@ PC Shop Gaming
LetShannonDunk.com - 2010 All-Star Dunk Contest hopeful!
sytremelaker is offline
Send a message via AIM to sytremelaker
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 18:42.


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