Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
NiGHT

[CS:GO] - [Plugin] "Team Bet"

Recommended Posts

  • Descriere: Dubleaza banii pariati pe echipa care va castiga runda.
  • Descărcare: 
    #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;
    }

     

  • 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 + https://github.com/bcserv/smlib/tree/transitional_syntax
  • Like 1
  • Love 1

b_560_95_1.png

 

-> DISCORD <-

-> STEAM <-

-> STEAM GROUP <-

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Also by continuing using this website you agree with the Terms of Use and Privacy Policy.