Author Topic: End Of Round Gold  (Read 698 times)

doctavio

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • Email
End Of Round Gold
« on: June 05, 2016, 04:07:59 PM »
Hey, ive searched everywhere and i cant seem to find the information i need, i would really appreciate it if someone could help me find a plugin or write one that will give gold on both a win and a lose, like 2 gold for lose 4 for a win. i would be willing to pay for something like this, thank you. And i dont know how to actually write code so just telling me what to write probably wont do any good. i would need the full code or what not. thanks for your time

abgar

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: End Of Round Gold
« Reply #1 on: June 05, 2016, 09:00:42 PM »
Here you go.  Just change the WinGold or LoseGold value to whatever amount of gold you want to give.  It's only basic, can be updated to include CVARs, and it might also allocate the 'lose gold' amount to specators (untested) but that can all be fixed / updated fairly easily.

Code: [Select]
#pragma semicolon 1

#include <sdktools>
#include <sourcemod>
#include "W3SIncs/War3Source_Interface"


public Plugin:myinfo =
{
name = "Give Gold on Round End",
author = "ABGar",
description = "Gold given to players based on Team Win or Team Lose",
version = "1.0"
};

new WinGold=4;
new LoseGold=2;

public OnPluginStart()
{
HookEvent("round_end", OnRoundEnd);
}


public Action:OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
new WinningTeam = GetEventInt(event, "winner");

for(new i=1;i<=MaxClients;i++)
{
if(ValidPlayer(i))
{
if(GetClientTeam(i)==WinningTeam)
{
PrintToChat(i,"You have received %i gold for winning the round",WinGold);
War3_AddCurrency(i, WinGold);
}
else
{
PrintToChat(i,"You have received %i gold for losing the round",LoseGold);
War3_AddCurrency(i, LoseGold);
}
}
}
}

doctavio

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • Email
Re: End Of Round Gold
« Reply #2 on: June 06, 2016, 03:04:41 PM »
Created a new text document named it goldwin.sp and compiled it to an smx and slapped it in csgo/addons/sourcemod/plugins/w3s  works perfectly! thank you so much man much respect!
« Last Edit: June 06, 2016, 03:13:53 PM by doctavio »

doctavio

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • Email
Re: End Of Round Gold
« Reply #3 on: June 07, 2016, 02:42:40 PM »
yea it does give gold to spectators, not a huge problem but if ya got a easy fix ill use it :-) <3

abgar

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: End Of Round Gold
« Reply #4 on: June 07, 2016, 04:20:05 PM »
This should resolve (again, untested):

Code: [Select]
public Action:OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
new WinningTeam = GetEventInt(event, "winner");

for(new i=1;i<=MaxClients;i++)
{
if(ValidPlayer(i))
{
if(GetClientTeam(i)==CS_TEAM_SPECTATOR)
break;
else if(GetClientTeam(i)==WinningTeam)
{
PrintToChat(i,"You have received %i gold for winning the round",WinGold);
War3_AddCurrency(i, WinGold);
}
else
{
PrintToChat(i,"You have received %i gold for losing the round",LoseGold);
War3_AddCurrency(i, LoseGold);
}
}
}
}

Revan

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: End Of Round Gold
« Reply #5 on: June 08, 2016, 01:55:13 PM »
Replace break with continue

Code: [Select]
public Action:OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
new WinningTeam = GetEventInt(event, "winner");

for(new i=1;i<=MaxClients;i++)
{
if(ValidPlayer(i))
{
if(GetClientTeam(i)==CS_TEAM_SPECTATOR)
continue;
else if(GetClientTeam(i)==WinningTeam)
{
PrintToChat(i,"You have received %i gold for winning the round",WinGold);
War3_AddCurrency(i, WinGold);
}
else
{
PrintToChat(i,"You have received %i gold for losing the round",LoseGold);
War3_AddCurrency(i, LoseGold);
}
}
}
}

 :)
#war3source on gamesurge

doctavio

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • Email
Re: End Of Round Gold
« Reply #6 on: June 08, 2016, 02:57:02 PM »
right on ill test, thanks for the help /salute!

doctavio

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • Email
Re: End Of Round Gold
« Reply #7 on: June 08, 2016, 07:15:21 PM »
100% working you guys are the best

abgar

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: End Of Round Gold
« Reply #8 on: June 08, 2016, 08:01:29 PM »
Whoops - that's what I get for typing in the morning haha. Thanks for the clarification Revan
Replace break with continue

Code: [Select]
public Action:OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
new WinningTeam = GetEventInt(event, "winner");

for(new i=1;i<=MaxClients;i++)
{
if(ValidPlayer(i))
{
if(GetClientTeam(i)==CS_TEAM_SPECTATOR)
continue;
else if(GetClientTeam(i)==WinningTeam)
{
PrintToChat(i,"You have received %i gold for winning the round",WinGold);
War3_AddCurrency(i, WinGold);
}
else
{
PrintToChat(i,"You have received %i gold for losing the round",LoseGold);
War3_AddCurrency(i, LoseGold);
}
}
}
}

 :)

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: End Of Round Gold
« Reply #9 on: August 15, 2016, 09:05:42 AM »
is there a final version that can be uploaded to github. Would be nice if the gold amount are cvars