Hushang
Участник
- Сообщения
- 134
- Реакции
- 26
Здравствуйте, кто подскажет, как сделать так, чтобы в 1 раунде и после мены сторон было 800 долларов, а в остальных раундах по 16к?
исходник:
#pragma semicolon 1
#include <cstrike>
ConVar mp_startmoney;
bool bFirstRound;
int m_iAccount,
iFirstMoney,
iDefMoney;
public Plugin:myinfo =
{
name = "First round startmoney",
author = "Grey83",
description = "Changes the initial amount of money for the first round.",
version = "1.0.1",
url = "https://steamcommunity.com/groups/grey83ds"
};
public void OnPluginStart()
{
EngineVersion ver = GetEngineVersion();
if(ver != Engine_CSS && ver != Engine_CSGO) SetFailState("Plugin for CS:S and CS:GO only!");
m_iAccount = FindSendPropInfo("CCSPlayer", "m_iAccount");
(mp_startmoney = CreateConVar("sm_startmoney_first", "800", "Сколько денег будет выдавать в первом раунде", _, true, 800.0, true, 16000.0)).AddChangeHook(CVarChange_First);
iFirstMoney = mp_startmoney.IntValue;
(mp_startmoney = CreateConVar("sm_startmoney_def", "16000", "Сколько денег будет выдавать в начале каждого из всех остальных раундов", _, true, 800.0, true, 16000.0)).AddChangeHook(CVarChange_Def);
iDefMoney = mp_startmoney.IntValue;
AutoExecConfig(true, "StartMoney");
if((mp_startmoney = FindConVar("mp_startmoney")) == null) SetFailState("Can't find ConVar 'mp_startmoney'!");
}
public void CVarChange_First(ConVar convar, const char[] oldValue, const char[] newValue)
{
convar.IntValue = iFirstMoney;
if(bFirstRound) mp_startmoney.IntValue = iFirstMoney;
}
public void CVarChange_Def(ConVar convar, const char[] oldValue, const char[] newValue)
{
convar.IntValue = iDefMoney;
if(!bFirstRound) mp_startmoney.IntValue = iDefMoney;
}
public void OnMapStart()
{
bFirstRound = true;
mp_startmoney.IntValue = iFirstMoney;
}
public Action CS_OnTerminateRound(float& delay, CSRoundEndReason& reason)
{
static bool start;
start = (reason == CSRoundEnd_GameStart);
if(bFirstRound != start)
{
bFirstRound = start;
mp_startmoney.IntValue = bFirstRound ? iFirstMoney : iDefMoney;
if(m_iAccount > 0) for(int i = 1, diff = iDefMoney - iFirstMoney; i <= MaxClients; i++)
if(IsClientInGame(i)) SetEntData(i, m_iAccount, GetEntData(i, m_iAccount) + diff);
}
return Plugin_Continue;
}