Raised This Month: $ Target: $400
 0% 

TeamBets 2.6 (Mani Conversion)


Post New Thread Reply   
 
Thread Tools Display Modes
Bigsplash
Senior Member
Join Date: Mar 2009
Old 11-18-2015 , 22:36   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #201

Thanks Wiczek I found it!!!

227:44 sm_cmdinfo sm_bet
227:44
[SM] sm_bet is registered to:
store.smx
__________________

Last edited by Bigsplash; 11-18-2015 at 22:41.
Bigsplash is offline
Wilczek
AlliedModders Donor
Join Date: Oct 2012
Location: Poland
Old 11-19-2015 , 05:18   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #202

No problem ;)
__________________
Wilczek is offline
Derpanator
Junior Member
Join Date: Dec 2015
Location: Australia
Old 12-29-2015 , 06:00   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #203

Would this work with the store plugin?
Derpanator is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 12-29-2015 , 08:02   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #204

Quote:
Originally Posted by Derpanator View Post
Would this work with the store plugin?
-> https://forums.alliedmods.net/showpo...46&postcount=9
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Anonymous_OG
New Member
Join Date: Apr 2016
Old 06-12-2016 , 21:08   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #205

Hey! Love the plugin but I just was wondering if you had any way or if it was easy to create a pot that allowed you to type !pot to see how much credits/money is being bet at the moment. I'd really appreciate it!
Anonymous_OG is offline
Wilczek
AlliedModders Donor
Join Date: Oct 2012
Location: Poland
Old 06-13-2016 , 11:52   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #206

Try this one:

PHP Code:
/**
 * teambets.sp
 * Adds team betting. After dying, a player can bet on which team will win. 
 */

#include <sourcemod>

#pragma semicolon 1

#define PLUGIN_VERSION "2.7.2"

public Plugin:myinfo 
{
    
name "Team Bets",
    
author "VieuxGnome fork GrimReaper - ferret",
    
description "Bet on Team to Win For CS:Go",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?t=85914"
};

#define LIFE_ALIVE 0
new g_iLifeState = -1;
new 
g_iAccount = -1;

#define BET_AMOUNT 0
#define BET_WIN 1
#define BET_TEAM 2

new g_bEnabled false;
new 
g_bHooked false;

new 
g_iPlayerBetData[MAXPLAYERS 1][3];
new 
bool:g_bPlayerBet[MAXPLAYERS 1] = {false, ...};
new 
bool:g_bBombPlanted false;
new 
bool:g_bBombDefused false;
new 
bool:g_bOneVsMany false;
new 
g_iOneVsManyPot;
new 
g_iOneVsManyTeam;
new 
g_iWinnerLastRnd;
new 
g_iConfig_mp_maxmoney;
int g_iInPotTotal;

new 
Handle:g_hSmBet INVALID_HANDLE;
new 
Handle:g_hSmBetDeadOnly INVALID_HANDLE;
new 
Handle:g_hSmBetOneVsMany INVALID_HANDLE;
new 
Handle:g_hSmBetAnnounce INVALID_HANDLE;
new 
Handle:g_hSmBetAdvert INVALID_HANDLE;
new 
Handle:g_hSmBetPlanted INVALID_HANDLE;
        
public 
OnPluginStart()
{
    
g_iAccount FindSendPropOffs("CCSPlayer""m_iAccount");
    
g_iLifeState FindSendPropOffs("CBasePlayer""m_lifeState");
    new 
Handle:CvarHandle;
    if ((
CvarHandle FindConVar("mp_maxmoney")) != INVALID_HANDLE)
        
g_iConfig_mp_maxmoney     GetConVarInt(CvarHandle);
    if (
g_iAccount == -|| g_iLifeState == -1)
    {
        
g_bEnabled false;
        
PrintToServer("[TeamBets] - Unable to start, cannot find necessary send prop offsets.");
        return;
    }
    
    
LoadTranslations("common.phrases");
    
LoadTranslations("plugin.teambets");    

    
CreateConVar("sm_teambets_version"PLUGIN_VERSION"TeamBets Version"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
    
RegConsoleCmd("say"Command_Say);
    
RegConsoleCmd("say_team"Command_Say);
    
RegConsoleCmd("pot"Command_Pot);
    
    
g_hSmBet CreateConVar("sm_bet""1""Enable team betting? (0 off, 1 on, def. 1)");    
    
g_hSmBetDeadOnly CreateConVar("sm_bet_deadonly""1""Only dead players can bet. (0 off, 1 on, def. 1)");    
    
g_hSmBetOneVsMany CreateConVar("sm_bet_onevsmany""0""The winner of a 1 vs X fight gets the losing pot (def. 0)");    
    
g_hSmBetAnnounce CreateConVar("sm_bet_announce""0""Announce 1 vs 1 situations (0 off, 1 on, def. 0)");
    
g_hSmBetAdvert CreateConVar("sm_bet_advert""1""Advertise plugin instructions on client connect? (0 off, 1 on, def. 1)");
    
g_hSmBetPlanted CreateConVar("sm_bet_planted""0""Prevent betting if the bomb has been planted. (0 off, 1 on, def. 0)");
    
    
HookConVarChange(g_hSmBetConVarChange_SmBet);

    
g_bEnabled true;
    
    
CreateTimer(5.0Timer_DelayedHooks);

    
AutoExecConfig(true"teambets");
}

public 
Action:Timer_DelayedHooks(Handle:timer)
{
    if (
g_bEnabled)
    {
        
HookEvent("round_end"Event_RoundEndEventHookMode_Post);
        
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
        
HookEvent("bomb_planted"Event_PlantedEventHookMode_PostNoCopy);
        
HookEvent("bomb_defused"Event_DefusedEventHookMode_Post);    
        
HookEvent("round_start"Event_RoundStartEventHookMode_Post);    
        
g_bHooked true;

        
PrintToServer("[TeamBets] - Loaded");
    }
}

public 
ConVarChange_SmBet(Handle:convar, const String:oldValue[], const String:newValue[])
{
    new 
iNewVal StringToInt(newValue);
    
    if (
g_bEnabled && iNewVal != 1)
    {
        if (
g_bHooked)
        {
            
UnhookEvent("round_end"Event_RoundEnd);
            
UnhookEvent("player_death"Event_PlayerDeath);
            
UnhookEvent("bomb_planted"Event_Planted);
            
UnhookEvent("bomb_defused"Event_Defused);
            
UnhookEvent("round_start"Event_RoundStart);
            
g_bHooked false;
        }
        
        
g_bEnabled false;
    }
    else if (!
g_bEnabled && iNewVal == 1)
    {
        if (!
g_bHooked)
        {
            
HookEvent("round_end"Event_RoundEndEventHookMode_Post);
            
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
            
HookEvent("bomb_planted"Event_PlantedEventHookMode_PostNoCopy);    
            
HookEvent("bomb_defused"Event_DefusedEventHookMode_Post);    
            
HookEvent("round_start"Event_RoundStartEventHookMode_Post);
            
g_bHooked true;            
        }
        
        
g_bEnabled true;        
    }
}

public 
Event_Planted(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return ;
    
    if (
GetConVarInt(g_hSmBetPlanted) == 1)
    {
        
g_bBombPlanted true;
    }
}

public 
Event_Defused(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return ;
        
    
g_bBombDefused true;
}
        

public 
Action:Command_Say(clientargs)
{
    if (!
g_bEnabled)
        return 
Plugin_Continue;
    
    new 
String:szText[192];
    
GetCmdArgString(szTextsizeof(szText));
    
    new 
startarg 0;
    if (
szText[0] == '"')
    {
        
startarg 1;
        
/* Strip the ending quote, if there is one */
        
new szTextlen strlen(szText);
        if (
szText[szTextlen-1] == '"')
        {
            
szText[szTextlen-1] = '\0';
        }
    }
    
    new 
String:szParts[3][16];
      
ExplodeString(szText[startarg], " "szParts316);

     if (
strcmp(szParts[0],"bet",false) == 0)
    {
        if (
g_bBombPlanted == true || g_bBombDefused == true)
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""No bets after bomb planted");
            return 
Plugin_Handled;
        }
    
        if (
GetClientTeam(client) <= 1)
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Must Be On A Team To Vote");
            return 
Plugin_Handled;
        }
        
        if (
g_bPlayerBet[client])
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Already Betted");
            return 
Plugin_Handled;    
        }

        if (
GetConVarInt(g_hSmBetDeadOnly) == && IsAlive(client))
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Must Be Dead To Vote");
            return 
Plugin_Handled;
        }
    
        if (
strcmp(szParts[1],"ct",false) != && strcmp(szParts[1],"t"false) != 0)
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Invalid Team for Bet");
            return 
Plugin_Handled;
        }

        if (
strcmp(szParts[1],"ct",false) == || strcmp(szParts[1],"t"false) == 0)
        {
    
            new 
iAmount 0;
            new 
iBank GetMoney(client);
    
            if (
IsCharNumeric(szParts[2][0]))
            {
                
iAmount StringToInt(szParts[2]);
            }
            else if (
strcmp(szParts[2],"all",false) == 0)
            {
                
iAmount iBank;
            }
            if (
strcmp(szParts[2],"half"false) == 0)
            {
                
iAmount = (iBank 2) + 1;
            }
            if (
strcmp(szParts[2],"third"false) == 0)
            {
                
iAmount = (iBank 3) + 1;
            }

            if (
iAmount 1)
            {
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Invalid Bet Amount");
                return 
Plugin_Handled;
            }        
    
            if (
iAmount iBank || iBank 1)
            {
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Not Enough Money");
                return 
Plugin_Handled;
            }
    
            new 
iOdds[2] = {00}, iTeam;
            new 
iMaxClients GetMaxClients();

            for (new 
1<= iMaxClientsi++)
            {
                if (
IsClientInGame(i) && IsAlive(i))
                {
                    
iTeam GetClientTeam(i);
                    if (
iTeam == 2// 2 = t, 3 = ct
                    
{
                        
iOdds[0]++;
                    }
                    else if (
iTeam == 3)
                    {
                        
iOdds[1]++;            
                    }
                }
            }
    
            if (
iOdds[0] < || iOdds[1] < 1)
            {
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Players Are Dead");
                return 
Plugin_Continue;        
            }
    
            
g_iPlayerBetData[client][BET_AMOUNT] = iAmount;
            
g_iPlayerBetData[client][BET_TEAM] = (strcmp(szParts[1],"t",false) == 3); // 2 = t, 3 = ct
            
g_iInPotTotal += iAmount;
    
            new 
iWin;
    
            if (
g_iPlayerBetData[client][BET_TEAM] == 2// 2 = t, 3 = ct
            
{
                
iWin RoundToNearest((float(iOdds[1]) / float(iOdds[0])) * float(iAmount));
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Bet Made"iOdds[1], iOdds[0], iWing_iPlayerBetData[client][BET_AMOUNT]);        
            }
            else
            {
                
iWin RoundToNearest((float(iOdds[0]) / float(iOdds[1])) * float(iAmount));
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Bet Made"iOdds[0], iOdds[1], iWing_iPlayerBetData[client][BET_AMOUNT]);
            }

            
g_iPlayerBetData[client][BET_WIN] = iWin;
            
g_bPlayerBet[client] = true;
    
            if (
g_bOneVsMany && g_iOneVsManyTeam != g_iPlayerBetData[client][BET_TEAM])
            { 
                
g_iOneVsManyPot += iAmount;
            }

            
SetMoney(clientiBank iAmount);

            return 
Plugin_Handled;
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action Command_Pot(clientargs)
{
    if (!
g_bEnabled)
        return 
Plugin_Continue;
        
    if (
IsClientInGame(client) && !IsFakeClient(client))
        
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""In Pot Total"g_iInPotTotal);
    
    return 
Plugin_Continue;
}

public 
bool:OnClientConnect(clientString:rejectmsg[], maxlen)
{
    if (!
g_bEnabled)
        return 
true;    
    
    
g_iPlayerBetData[client][BET_AMOUNT] = 0;
    
g_iPlayerBetData[client][BET_TEAM] = 0;
    
g_iPlayerBetData[client][BET_WIN] = 0;
    
g_bPlayerBet[client] = false;
    
    
CreateTimer(15.0Timer_Advertiseclient);
    
    return 
true;
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return;    
    
    if (
GetConVarInt(g_hSmBetAnnounce) == && GetConVarInt(g_hSmBetOneVsMany) < 2// We don't care about player deaths
        
return;

    new 
iMaxClients GetMaxClients();
    new 
iTeamiTeams[2] = {00}, iTPlayeriCTPlayer;
    
    for (new 
1<= iMaxClientsi++)
    {
        if (
IsClientInGame(i) && IsAlive(i))
        {
            
iTeam GetClientTeam(i);
            if (
iTeam == 2)
            {
                
iTeams[0]++;
                if (
iTPlayer == 0) { iTPlayer i; }
            }
            else if (
iTeam == 3)
            {
                
iTeams[1]++;
                if (
iCTPlayer == 0) { iCTPlayer i; }
            }
        }    
    }

    if (
iTeams[0] == && iTeams[1] == && !g_bOneVsMany && GetConVarInt(g_hSmBetAnnounce) > 0)
    {
        
PrintToChatAll("\x04-\x04[TeamBets]\x01 %T""One Vs One"LANG_SERVER);
        return;
    }
    
    if (
GetConVarInt(g_hSmBetOneVsMany) > 1)
    {
        new 
String:pname[64];
        
        if ((
iTeams[0] == && iTeams[1] > GetConVarInt(g_hSmBetOneVsMany)) || (iTeams[1] == && iTeams[0] > GetConVarInt(g_hSmBetOneVsMany)) && !g_bOneVsMany)
        {
            
g_bOneVsMany true;
            
g_iOneVsManyPot 0;
            
            if (
iTeams[0] == 1)
            {
                
GetClientName(iTPlayerpname64);
                
g_iOneVsManyTeam 2;
            }
            else
            {
                
GetClientName(iCTPlayerpname64);
                
g_iOneVsManyTeam 3;
            }
            
            
PrintToChatAll("\x04-\x04[TeamBets]\x01 %T""One Vs Many Start"LANG_SERVERpname, (iTeams[1] == "Terrorist" "Counter-Terrorist"));
        }
        else if (
iTeams[0] == && iTeams[1] == && g_bOneVsMany && g_iOneVsManyTeam == 2)
        {
            
GetClientName(iTPlayerpname64);
            
PrintToChatAll("\x04-\x04[TeamBets]\x01 %T""One Vs Many Winner"LANG_SERVERpnameg_iOneVsManyPot);
            
SetMoney(iTPlayerGetMoney(iTPlayer) + g_iOneVsManyPot);
        }
        else if (
iTeams[1] == && iTeams[0] == && g_bOneVsMany && g_iOneVsManyTeam == 3)
        {
            
GetClientName(iCTPlayerpname64);
            
PrintToChatAll("\x04-\x04[TeamBets]\x01 %T""One Vs Many Winner"LANG_SERVERpnameg_iOneVsManyPot);
            
SetMoney(iCTPlayerGetMoney(iCTPlayer) + g_iOneVsManyPot);        
        }
    }
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return ;            
        
    
g_bBombPlanted false;
    
g_bBombDefused false;
    new 
iMaxClients GetMaxClients();
    new 
iMoney 0;
    for (new 
1<= iMaxClientsi++)
    {
        if (
IsClientInGame(i) && g_bPlayerBet[i])
        {
            if (
g_iWinnerLastRnd == g_iPlayerBetData[i][BET_TEAM])
            {
                if ((
iMoney GetMoney(i) + g_iPlayerBetData[i][BET_AMOUNT] + g_iPlayerBetData[i][BET_WIN]) > g_iConfig_mp_maxmoneyiMoney g_iConfig_mp_maxmoney;
                
SetMoney(i,iMoney);
                
PrintToChat(i"\x04-\x04[TeamBets]\x05 %t""Bet Won"g_iPlayerBetData[i][BET_WIN], g_iPlayerBetData[i][BET_AMOUNT]);
            }
            else
            {
                
PrintToChat(i"\x04-\x04[TeamBets]\x02 %t""Bet Lost"g_iPlayerBetData[i][BET_AMOUNT]);
            }
        }
        
g_bPlayerBet[i] = false;
    }
}

public 
Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return ;        

    new 
iWinner GetEventInt(event"winner");        
    
g_iWinnerLastRnd iWinner;
    
g_bOneVsMany false;
    
g_iOneVsManyPot 0;
    
g_iInPotTotal 0;
}

public 
Action:Timer_Advertise(Handle:timerany:client)
{
    if (
GetConVarInt(g_hSmBetAdvert) == 1)
        {
            if (
IsClientInGame(client))
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Advertise Bets");
            else if (
IsClientConnected(client))
                
CreateTimer(15.0Timer_Advertiseclient);
        }
}
 
public 
bool:IsAlive(client)
{
    if (
g_iLifeState != -&& GetEntData(clientg_iLifeState1) == LIFE_ALIVE)
        return 
true;
 
    return 
false;


public 
SetMoney(clientamount)
{
    if (
g_iAccount != -1)
        
SetEntData(clientg_iAccountamount);
}

public 
GetMoney(client)
{
    if (
g_iAccount != -1)
        return 
GetEntData(clientg_iAccount);

    return 
0;

Translations:
PHP Code:
    "In Pot Total"
    
{
        
"#format"        "{1:d}"
        "en"            "There are 
${1} in the pot."
    

Chat trigger - !pot
Based on this version.
__________________
Wilczek is offline
Pintuz
Junior Member
Join Date: Feb 2013
Old 01-23-2017 , 09:12   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #207

Hi!,

Tried the script. It seem to work nicely however if theres a warmup players seem to be able to place bets before match starts and then retain that money from warmup to the first round. Dunno if anyone experienced that before?. I tried delaying hooks but that doesnt seem to sustain for the next map.


./Pintuz
Pintuz is offline
FulliFR
Junior Member
Join Date: Feb 2013
Old 06-26-2017 , 07:08   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #208

After the CSS update from 25.06.2017 this plugin does not work anymore! Hope anybody can bring this beloved plugin again to the latest state.

Many greetings Fulli
FulliFR is offline
Obyboby
Veteran Member
Join Date: Sep 2013
Old 08-28-2017 , 19:43   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #209

Quote:
Originally Posted by Wilczek View Post
Try this one:

PHP Code:
/**
 * teambets.sp
 * Adds team betting. After dying, a player can bet on which team will win. 
 */

#include <sourcemod>

#pragma semicolon 1

#define PLUGIN_VERSION "2.7.2"

public Plugin:myinfo 
{
    
name "Team Bets",
    
author "VieuxGnome fork GrimReaper - ferret",
    
description "Bet on Team to Win For CS:Go",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?t=85914"
};

#define LIFE_ALIVE 0
new g_iLifeState = -1;
new 
g_iAccount = -1;

#define BET_AMOUNT 0
#define BET_WIN 1
#define BET_TEAM 2

new g_bEnabled false;
new 
g_bHooked false;

new 
g_iPlayerBetData[MAXPLAYERS 1][3];
new 
bool:g_bPlayerBet[MAXPLAYERS 1] = {false, ...};
new 
bool:g_bBombPlanted false;
new 
bool:g_bBombDefused false;
new 
bool:g_bOneVsMany false;
new 
g_iOneVsManyPot;
new 
g_iOneVsManyTeam;
new 
g_iWinnerLastRnd;
new 
g_iConfig_mp_maxmoney;
int g_iInPotTotal;

new 
Handle:g_hSmBet INVALID_HANDLE;
new 
Handle:g_hSmBetDeadOnly INVALID_HANDLE;
new 
Handle:g_hSmBetOneVsMany INVALID_HANDLE;
new 
Handle:g_hSmBetAnnounce INVALID_HANDLE;
new 
Handle:g_hSmBetAdvert INVALID_HANDLE;
new 
Handle:g_hSmBetPlanted INVALID_HANDLE;
        
public 
OnPluginStart()
{
    
g_iAccount FindSendPropOffs("CCSPlayer""m_iAccount");
    
g_iLifeState FindSendPropOffs("CBasePlayer""m_lifeState");
    new 
Handle:CvarHandle;
    if ((
CvarHandle FindConVar("mp_maxmoney")) != INVALID_HANDLE)
        
g_iConfig_mp_maxmoney     GetConVarInt(CvarHandle);
    if (
g_iAccount == -|| g_iLifeState == -1)
    {
        
g_bEnabled false;
        
PrintToServer("[TeamBets] - Unable to start, cannot find necessary send prop offsets.");
        return;
    }
    
    
LoadTranslations("common.phrases");
    
LoadTranslations("plugin.teambets");    

    
CreateConVar("sm_teambets_version"PLUGIN_VERSION"TeamBets Version"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
    
RegConsoleCmd("say"Command_Say);
    
RegConsoleCmd("say_team"Command_Say);
    
RegConsoleCmd("pot"Command_Pot);
    
    
g_hSmBet CreateConVar("sm_bet""1""Enable team betting? (0 off, 1 on, def. 1)");    
    
g_hSmBetDeadOnly CreateConVar("sm_bet_deadonly""1""Only dead players can bet. (0 off, 1 on, def. 1)");    
    
g_hSmBetOneVsMany CreateConVar("sm_bet_onevsmany""0""The winner of a 1 vs X fight gets the losing pot (def. 0)");    
    
g_hSmBetAnnounce CreateConVar("sm_bet_announce""0""Announce 1 vs 1 situations (0 off, 1 on, def. 0)");
    
g_hSmBetAdvert CreateConVar("sm_bet_advert""1""Advertise plugin instructions on client connect? (0 off, 1 on, def. 1)");
    
g_hSmBetPlanted CreateConVar("sm_bet_planted""0""Prevent betting if the bomb has been planted. (0 off, 1 on, def. 0)");
    
    
HookConVarChange(g_hSmBetConVarChange_SmBet);

    
g_bEnabled true;
    
    
CreateTimer(5.0Timer_DelayedHooks);

    
AutoExecConfig(true"teambets");
}

public 
Action:Timer_DelayedHooks(Handle:timer)
{
    if (
g_bEnabled)
    {
        
HookEvent("round_end"Event_RoundEndEventHookMode_Post);
        
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
        
HookEvent("bomb_planted"Event_PlantedEventHookMode_PostNoCopy);
        
HookEvent("bomb_defused"Event_DefusedEventHookMode_Post);    
        
HookEvent("round_start"Event_RoundStartEventHookMode_Post);    
        
g_bHooked true;

        
PrintToServer("[TeamBets] - Loaded");
    }
}

public 
ConVarChange_SmBet(Handle:convar, const String:oldValue[], const String:newValue[])
{
    new 
iNewVal StringToInt(newValue);
    
    if (
g_bEnabled && iNewVal != 1)
    {
        if (
g_bHooked)
        {
            
UnhookEvent("round_end"Event_RoundEnd);
            
UnhookEvent("player_death"Event_PlayerDeath);
            
UnhookEvent("bomb_planted"Event_Planted);
            
UnhookEvent("bomb_defused"Event_Defused);
            
UnhookEvent("round_start"Event_RoundStart);
            
g_bHooked false;
        }
        
        
g_bEnabled false;
    }
    else if (!
g_bEnabled && iNewVal == 1)
    {
        if (!
g_bHooked)
        {
            
HookEvent("round_end"Event_RoundEndEventHookMode_Post);
            
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
            
HookEvent("bomb_planted"Event_PlantedEventHookMode_PostNoCopy);    
            
HookEvent("bomb_defused"Event_DefusedEventHookMode_Post);    
            
HookEvent("round_start"Event_RoundStartEventHookMode_Post);
            
g_bHooked true;            
        }
        
        
g_bEnabled true;        
    }
}

public 
Event_Planted(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return ;
    
    if (
GetConVarInt(g_hSmBetPlanted) == 1)
    {
        
g_bBombPlanted true;
    }
}

public 
Event_Defused(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return ;
        
    
g_bBombDefused true;
}
        

public 
Action:Command_Say(clientargs)
{
    if (!
g_bEnabled)
        return 
Plugin_Continue;
    
    new 
String:szText[192];
    
GetCmdArgString(szTextsizeof(szText));
    
    new 
startarg 0;
    if (
szText[0] == '"')
    {
        
startarg 1;
        
/* Strip the ending quote, if there is one */
        
new szTextlen strlen(szText);
        if (
szText[szTextlen-1] == '"')
        {
            
szText[szTextlen-1] = '\0';
        }
    }
    
    new 
String:szParts[3][16];
      
ExplodeString(szText[startarg], " "szParts316);

     if (
strcmp(szParts[0],"bet",false) == 0)
    {
        if (
g_bBombPlanted == true || g_bBombDefused == true)
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""No bets after bomb planted");
            return 
Plugin_Handled;
        }
    
        if (
GetClientTeam(client) <= 1)
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Must Be On A Team To Vote");
            return 
Plugin_Handled;
        }
        
        if (
g_bPlayerBet[client])
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Already Betted");
            return 
Plugin_Handled;    
        }

        if (
GetConVarInt(g_hSmBetDeadOnly) == && IsAlive(client))
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Must Be Dead To Vote");
            return 
Plugin_Handled;
        }
    
        if (
strcmp(szParts[1],"ct",false) != && strcmp(szParts[1],"t"false) != 0)
        {
            
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Invalid Team for Bet");
            return 
Plugin_Handled;
        }

        if (
strcmp(szParts[1],"ct",false) == || strcmp(szParts[1],"t"false) == 0)
        {
    
            new 
iAmount 0;
            new 
iBank GetMoney(client);
    
            if (
IsCharNumeric(szParts[2][0]))
            {
                
iAmount StringToInt(szParts[2]);
            }
            else if (
strcmp(szParts[2],"all",false) == 0)
            {
                
iAmount iBank;
            }
            if (
strcmp(szParts[2],"half"false) == 0)
            {
                
iAmount = (iBank 2) + 1;
            }
            if (
strcmp(szParts[2],"third"false) == 0)
            {
                
iAmount = (iBank 3) + 1;
            }

            if (
iAmount 1)
            {
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Invalid Bet Amount");
                return 
Plugin_Handled;
            }        
    
            if (
iAmount iBank || iBank 1)
            {
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Not Enough Money");
                return 
Plugin_Handled;
            }
    
            new 
iOdds[2] = {00}, iTeam;
            new 
iMaxClients GetMaxClients();

            for (new 
1<= iMaxClientsi++)
            {
                if (
IsClientInGame(i) && IsAlive(i))
                {
                    
iTeam GetClientTeam(i);
                    if (
iTeam == 2// 2 = t, 3 = ct
                    
{
                        
iOdds[0]++;
                    }
                    else if (
iTeam == 3)
                    {
                        
iOdds[1]++;            
                    }
                }
            }
    
            if (
iOdds[0] < || iOdds[1] < 1)
            {
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Players Are Dead");
                return 
Plugin_Continue;        
            }
    
            
g_iPlayerBetData[client][BET_AMOUNT] = iAmount;
            
g_iPlayerBetData[client][BET_TEAM] = (strcmp(szParts[1],"t",false) == 3); // 2 = t, 3 = ct
            
g_iInPotTotal += iAmount;
    
            new 
iWin;
    
            if (
g_iPlayerBetData[client][BET_TEAM] == 2// 2 = t, 3 = ct
            
{
                
iWin RoundToNearest((float(iOdds[1]) / float(iOdds[0])) * float(iAmount));
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Bet Made"iOdds[1], iOdds[0], iWing_iPlayerBetData[client][BET_AMOUNT]);        
            }
            else
            {
                
iWin RoundToNearest((float(iOdds[0]) / float(iOdds[1])) * float(iAmount));
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Bet Made"iOdds[0], iOdds[1], iWing_iPlayerBetData[client][BET_AMOUNT]);
            }

            
g_iPlayerBetData[client][BET_WIN] = iWin;
            
g_bPlayerBet[client] = true;
    
            if (
g_bOneVsMany && g_iOneVsManyTeam != g_iPlayerBetData[client][BET_TEAM])
            { 
                
g_iOneVsManyPot += iAmount;
            }

            
SetMoney(clientiBank iAmount);

            return 
Plugin_Handled;
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action Command_Pot(clientargs)
{
    if (!
g_bEnabled)
        return 
Plugin_Continue;
        
    if (
IsClientInGame(client) && !IsFakeClient(client))
        
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""In Pot Total"g_iInPotTotal);
    
    return 
Plugin_Continue;
}

public 
bool:OnClientConnect(clientString:rejectmsg[], maxlen)
{
    if (!
g_bEnabled)
        return 
true;    
    
    
g_iPlayerBetData[client][BET_AMOUNT] = 0;
    
g_iPlayerBetData[client][BET_TEAM] = 0;
    
g_iPlayerBetData[client][BET_WIN] = 0;
    
g_bPlayerBet[client] = false;
    
    
CreateTimer(15.0Timer_Advertiseclient);
    
    return 
true;
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return;    
    
    if (
GetConVarInt(g_hSmBetAnnounce) == && GetConVarInt(g_hSmBetOneVsMany) < 2// We don't care about player deaths
        
return;

    new 
iMaxClients GetMaxClients();
    new 
iTeamiTeams[2] = {00}, iTPlayeriCTPlayer;
    
    for (new 
1<= iMaxClientsi++)
    {
        if (
IsClientInGame(i) && IsAlive(i))
        {
            
iTeam GetClientTeam(i);
            if (
iTeam == 2)
            {
                
iTeams[0]++;
                if (
iTPlayer == 0) { iTPlayer i; }
            }
            else if (
iTeam == 3)
            {
                
iTeams[1]++;
                if (
iCTPlayer == 0) { iCTPlayer i; }
            }
        }    
    }

    if (
iTeams[0] == && iTeams[1] == && !g_bOneVsMany && GetConVarInt(g_hSmBetAnnounce) > 0)
    {
        
PrintToChatAll("\x04-\x04[TeamBets]\x01 %T""One Vs One"LANG_SERVER);
        return;
    }
    
    if (
GetConVarInt(g_hSmBetOneVsMany) > 1)
    {
        new 
String:pname[64];
        
        if ((
iTeams[0] == && iTeams[1] > GetConVarInt(g_hSmBetOneVsMany)) || (iTeams[1] == && iTeams[0] > GetConVarInt(g_hSmBetOneVsMany)) && !g_bOneVsMany)
        {
            
g_bOneVsMany true;
            
g_iOneVsManyPot 0;
            
            if (
iTeams[0] == 1)
            {
                
GetClientName(iTPlayerpname64);
                
g_iOneVsManyTeam 2;
            }
            else
            {
                
GetClientName(iCTPlayerpname64);
                
g_iOneVsManyTeam 3;
            }
            
            
PrintToChatAll("\x04-\x04[TeamBets]\x01 %T""One Vs Many Start"LANG_SERVERpname, (iTeams[1] == "Terrorist" "Counter-Terrorist"));
        }
        else if (
iTeams[0] == && iTeams[1] == && g_bOneVsMany && g_iOneVsManyTeam == 2)
        {
            
GetClientName(iTPlayerpname64);
            
PrintToChatAll("\x04-\x04[TeamBets]\x01 %T""One Vs Many Winner"LANG_SERVERpnameg_iOneVsManyPot);
            
SetMoney(iTPlayerGetMoney(iTPlayer) + g_iOneVsManyPot);
        }
        else if (
iTeams[1] == && iTeams[0] == && g_bOneVsMany && g_iOneVsManyTeam == 3)
        {
            
GetClientName(iCTPlayerpname64);
            
PrintToChatAll("\x04-\x04[TeamBets]\x01 %T""One Vs Many Winner"LANG_SERVERpnameg_iOneVsManyPot);
            
SetMoney(iCTPlayerGetMoney(iCTPlayer) + g_iOneVsManyPot);        
        }
    }
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return ;            
        
    
g_bBombPlanted false;
    
g_bBombDefused false;
    new 
iMaxClients GetMaxClients();
    new 
iMoney 0;
    for (new 
1<= iMaxClientsi++)
    {
        if (
IsClientInGame(i) && g_bPlayerBet[i])
        {
            if (
g_iWinnerLastRnd == g_iPlayerBetData[i][BET_TEAM])
            {
                if ((
iMoney GetMoney(i) + g_iPlayerBetData[i][BET_AMOUNT] + g_iPlayerBetData[i][BET_WIN]) > g_iConfig_mp_maxmoneyiMoney g_iConfig_mp_maxmoney;
                
SetMoney(i,iMoney);
                
PrintToChat(i"\x04-\x04[TeamBets]\x05 %t""Bet Won"g_iPlayerBetData[i][BET_WIN], g_iPlayerBetData[i][BET_AMOUNT]);
            }
            else
            {
                
PrintToChat(i"\x04-\x04[TeamBets]\x02 %t""Bet Lost"g_iPlayerBetData[i][BET_AMOUNT]);
            }
        }
        
g_bPlayerBet[i] = false;
    }
}

public 
Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
g_bEnabled)
        return ;        

    new 
iWinner GetEventInt(event"winner");        
    
g_iWinnerLastRnd iWinner;
    
g_bOneVsMany false;
    
g_iOneVsManyPot 0;
    
g_iInPotTotal 0;
}

public 
Action:Timer_Advertise(Handle:timerany:client)
{
    if (
GetConVarInt(g_hSmBetAdvert) == 1)
        {
            if (
IsClientInGame(client))
                
PrintToChat(client"\x04-\x04[TeamBets]\x01 %t""Advertise Bets");
            else if (
IsClientConnected(client))
                
CreateTimer(15.0Timer_Advertiseclient);
        }
}
 
public 
bool:IsAlive(client)
{
    if (
g_iLifeState != -&& GetEntData(clientg_iLifeState1) == LIFE_ALIVE)
        return 
true;
 
    return 
false;


public 
SetMoney(clientamount)
{
    if (
g_iAccount != -1)
        
SetEntData(clientg_iAccountamount);
}

public 
GetMoney(client)
{
    if (
g_iAccount != -1)
        return 
GetEntData(clientg_iAccount);

    return 
0;

Translations:
PHP Code:
    "In Pot Total"
    
{
        
"#format"        "{1:d}"
        "en"            "There are 
${1} in the pot."
    

Chat trigger - !pot
Based on this version.

The code says sm_bets as a cvar, isn't !bet the trigger needed in order to bet?
Why then, players need to type it without the "!" in order to place a bet?
I thought that sm_bet -> !bet and not sm_bet -> bet.
Can anyone explain please?
I'd like to modify it since many players are wrongfully saying !bet pretty often.
__________________
Obyboby is offline
St00ne
Veteran Member
Join Date: Jan 2011
Location: Annecy - France
Old 08-29-2017 , 19:31   Re: TeamBets 2.6 (Mani Conversion)
Reply With Quote #210

It's because it uses say_commands as a chat trigger and detects if the word bet is the 1st word.
It's not based on sm_bet console command. The sm_bet you see in the file is only the enable cvar.
Anyway this plugin would need a rewrite for this reason (maybe others?), but I'm quite lazy right now.

And it works, and I don't think it harms servers, even if it would've been better to avoid all this chat detections... so personally, I use the default version.
__________________

*** *** ***
-My plugins-

Last edited by St00ne; 08-29-2017 at 19:32.
St00ne is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode