View Single Post
LenHard
Senior Member
Join Date: Jan 2016
Old 07-08-2018 , 04:33   Re: [CS:GO] coinflip credits for store plugin
Reply With Quote #2

PHP Code:
#include <sourcemod>  
#include <store>

#pragma semicolon 1  
#pragma newdecls required  

public void OnPluginStart()  
{  
    
RegConsoleCmd("sm_coinflip"Cmd_FlipCoin"Flips a coin.");
}  

public 
Action Cmd_FlipCoin(int clientint args)  
{  
    if (
client <= MaxClients && IsClientInGame(client))  
    {  
        if (
args != 2)
        {
            
ReplyToCommand(client"[SM] Usage: sm_coinflip <heads | tails> <quantity>");
            return 
Plugin_Handled;    
        }
        
        
char[] sArg = new char[10];
        
GetCmdArg(1sArg10);
        
        
bool bHead;
        
        if (
StrContains(sArg"head"false) != -1)
            
bHead true;
            
        
GetCmdArg(2sArg10);
        
        
int iValue StringToInt(sArg);
        
        if (
iValue 0)
        {
            
int iCredits Store_GetClientCredits(client);
            
            if (
iCredits iValue)
            {
                
ReplyToCommand(client"[SM] Insufficient funds.");
                return 
Plugin_Handled;
            }
            
            if (
view_as<bool>(GetRandomInt(01)) == bHead)
            {
                
Store_SetClientCredits(clientiCredits iValue);
                
PrintToChat(client"[SM] You won \x04%i\x01 credits due to the result being \"\x04Heads\x01\""iValue);
            }
            else
            {
                
Store_SetClientCredits(clientiCredits iValue);
                
PrintToChat(client"[SM] You lost \x04%i\x01 credits due to the result being \"\x04Tails\x01\""iValue);
            }
        }
        else 
ReplyToCommand(client"[SM] You need to bet higher than 0");
    }  
    return 
Plugin_Handled;  

__________________

Last edited by LenHard; 07-08-2018 at 04:38.
LenHard is offline