(I'm currently out driving around town, but I'll be back in a short while!)
So I've recently gotten into the
teamplay_point_capture event, and getting it set up to work properly. Here's what I've got going on in the code below:
To begin, if the "team bonus credits" CVAR is enabled, when the point is captured, the entire team gets a credit bonus, the amount of which is determined by the team bonus credits CVAR.
If that CVAR isn't enabled, we continue on anyway, and check to see how many players had just captured the point, then we give those players an amount of credits, determined by the respective CVAR.
The only reason I'm having trouble with this in particular is that i<x stuff, and the way it's set up. By using "client" in the latter part of the code, will that just make the plugin give ONE player credits? The way I'm 'reading' the code, I think in the end, "client" actually ends up "=" that "x" thing.
Does this look correct? I *think* it looks correct, I'm just not 100% sure. This is by far the most advanced thing I've ever coded
PHP Code:
public Event_CapturedPoint(Handle:event, const String:name[], bool:dontBroadcast)
{
if (g_bIsCreditsActive && g_bIsCreditsEnabled)
{
if (g_bTeamPointCapBonus)
{
new team = GetEventInt(event, "team");
new String:teamname[MAX_LINE_WIDTH];
GetTeamName(team, teamname, sizeof(teamname));
for (new i=1; i<=MaxClients; i++)
{
if (IsClientInGame[i] == true)
{
new teamcredits = GetConVarInt(Credits_CapturePointTeam);
Store_GiveCreditsToUsers(Store_GetClientAccountID(i), teamcredits);
if (GetConVarInt(Credits_CapturePointTeam) > 1)
{
PrintToChat(i, "%s%t", STORE_PREFIX, "Capture Point Team Bonus", teamname, teamcredits, g_strCurrencyName);
}
}
}
}
decl String:g_strPointCappers[MAXPLAYERS+1] = "";
GetEventString(event, "cappers", g_strPointCappers, MAXPLAYERS);
new x = strlen(g_strPointCappers);
//PrintToChatAll("Point capped by %i total players!", x);
for(new i=0; i<x; i++)
{
new client = g_strPointCappers{i}; //Is the "i" supposed to be in brackets, or parenthesis?
if (IsClientInGame[client] == true)
{
new credits = GetConVarInt(Credits_CapturePointPlayer);
Store_GiveCreditsToUsers(Store_GetClientAccountID(client), credits);
if (GetConVarInt(Credits_CapturePointPlayer) > 1)
{
PrintToChat(client, "%s%t", STORE_PREFIX, "Capture Point Player", credits, g_strCurrencyName);
}
}
}
}
}