Jump to content

[CSGO PLUGIN] - Team Bet


Vali M.

Recommended Posts

Denumire plugin: [CS:GO] Team Bet
Link oficial: - 
Imagini (opţional): - 
Alte precizari/detalii: Pentru a pune un pariu se foloseste: primul argument: bet + al 2-lea argument(echipa): t sau ct + al 3-lea argument: suma. Ex: bet ct all, bet t 5490.
Cerinte pentru compilare: sourcemod + 
CLICK

 

#pragma semicolon 1
#pragma newdecls required;

#include <sourcemod>
#include <smlib>

#define BET_SUM 1
#define BET_TEAM 2

int g_iPlayerBet[MAXPLAYERS+1][3];
bool restrict = false;
public Plugin myinfo = 
{
	name = "Bet Team",
	author = "NiGHT#1846",
	description = "bet team amount",
	version = "0.2",
	url = "https://steamcommunity.com/id/night757/"
};

public void OnPluginStart()
{
	RegConsoleCmd("say", cmd_bet, "Bet team(t/ct) money(all/amount)");
	RegConsoleCmd("say_team", cmd_bet, "Bet team(t/ct) money(all/amount)");
	
	HookEvent("round_end", Event_RoundEnd, EventHookMode_Post);
	HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}

public void Event_RoundEnd(Event event, const char[] name, bool db)
{
	int team_win = event.GetInt("winner");
	if(team_win == 2 || team_win == 3)
	{
		int amount;
		for(int i = 1; i <= MaxClients; i++)
		{
			if(!IsClientInGame(i) || g_iPlayerBet[i][BET_TEAM] == 0)
				continue;
			
			if(team_win == g_iPlayerBet[i][BET_TEAM])
			{
				amount = Client_GetMoney(i) + g_iPlayerBet[i][BET_SUM] > 16000 ? 16000 - Client_GetMoney(i) + g_iPlayerBet[i][BET_SUM] : Client_GetMoney(i) + g_iPlayerBet[i][BET_SUM];
				Client_SetMoney(i, amount);
				PrintToChat(i, "[\x02USP\x01] You \x04won $%d", amount);
			}
			else{
				Client_SetMoney(i, Client_GetMoney(i) - g_iPlayerBet[i][BET_SUM]);
				PrintToChat(i, "[\x02USP\x01] You \x0Flost $%d", g_iPlayerBet[i][BET_SUM]);
			}
		}
	}
	restrict = true;
}

public void Event_RoundStart(Event event, const char[] name, bool db)
{
	for(int i = 1; i <= MaxClients; i++)
	{
		g_iPlayerBet[i][BET_SUM] = 0;
		g_iPlayerBet[i][BET_TEAM] = 0;
	}
	restrict = false;
}

public void OnClientDisconnect(int client)
{
	g_iPlayerBet[client][BET_SUM] = 0;
	g_iPlayerBet[client][BET_TEAM] = 0;
}

public Action cmd_bet(int client, int args)
{
	if(!IsClientInGame(client))
		return Plugin_Continue;
	
	static char text[64];
	GetCmdArgString(text, sizeof(text));
	StripQuotes(text);
	static char sExploded[3][16];
	ExplodeString(text, " ", sExploded, 3, 16);
	if(strcmp(sExploded[0], "bet", false) == 0)
	{
		if(g_iPlayerBet[client][BET_SUM] != 0 || g_iPlayerBet[client][BET_TEAM] != 0)
		{
			PrintToChat(client, " \x02ERROR:\x01 You already bet, your bet: \x09bet %s \x04$%d", g_iPlayerBet[client][BET_TEAM] == 2 ? "\x0FT\x01" : "\x0BCT\x01", g_iPlayerBet[client][BET_SUM]);
			return Plugin_Continue;
		}

		if(GetClientTeam(client) <= 1)
		{
			PrintToChat(client, " \x02ERROR:\x01 You need to be in a playable team to bet.");
			return Plugin_Continue;
		}
		
		int iround = GetTeamScore(2) + GetTeamScore(3);
		if(restrict || iround == 0 || iround == 15 || iround+1 == 15 || iround+1 == 30)
		{
			PrintToChat(client, " \x02ERROR:\x01 You cannot bet right now.");
			return Plugin_Continue;
		}
		if(IsPlayerAlive(client))
		{
			PrintToChat(client, " \x02ERROR:\x01 You need to be dead to bet.");
			return Plugin_Continue;
		}
		if(GetTeamPlayersAlive(2) == 0 || GetTeamPlayersAlive(3) == 0)
		{
			PrintToChat(client, " \x02ERROR:\x01 No players alive found in your or enemy team.");
			return Plugin_Continue;
		}
		switch(sExploded[1][0])
		{
			case 't': g_iPlayerBet[client][BET_TEAM] = 2;
			case 'c': g_iPlayerBet[client][BET_TEAM] = 3;
			default: {
				PrintToChat(client, " \x02ERROR:\x01 Invalid team, syntax example: \x04bet ct/t all/amount\x01.");
				g_iPlayerBet[client][BET_SUM] = 0;
				g_iPlayerBet[client][BET_TEAM] = 0;
				return Plugin_Continue;
			}
		}
		if(!sExploded[2][0])
		{
			PrintToChat(client, " \x02ERROR:\x01 Invalid amount, syntax example: \x04bet ct/t all/amount\x01.");
			g_iPlayerBet[client][BET_SUM] = 0;
			g_iPlayerBet[client][BET_TEAM] = 0;
			return Plugin_Continue;
		}
		if(strcmp(sExploded[2], "all", false) == 0)
		{
			g_iPlayerBet[client][BET_SUM] = Client_GetMoney(client);
		}
		else
		{
			int iValue = StringToInt(sExploded[2]);
			if(iValue != 0 && Client_GetMoney(client) >= iValue)
				g_iPlayerBet[client][BET_SUM] = iValue;
			else{
				PrintToChat(client, " \x02ERROR:\x01 Invalid amount.");
				g_iPlayerBet[client][BET_SUM] = 0;
				g_iPlayerBet[client][BET_TEAM] = 0;
				return Plugin_Continue;
			}
		}
		PrintToChat(client, "[\x02USP\x01] You \x09bet %s \x04$%d", g_iPlayerBet[client][BET_TEAM] == 2 ? "\x0FT\x01" : "\x0BCT\x01", g_iPlayerBet[client][BET_SUM]);
	}
	return Plugin_Continue;
}

stock int GetTeamPlayersAlive(int team)
{
	int j = 0;
	for(int i = 1; i <= MaxClients; i++)
	{
		if(!IsClientInGame(i))
			continue;
		if(GetClientTeam(i) != team || !IsPlayerAlive(i))
			continue;
		
		j++;
	}
	return j;
}

 

  TS.ELDERS.RO - OLD.ELDERS.RO - IP : 5.183.171.37:27015

Pentru orice problema ma gasiti pe ts la canalu OLD cu numele : Vali M. sau PM pe forum.

Daca vrei sa ma adaugi pe Steam da click AICI

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

By using this website, you agree to our Terms of Use and Guidelines