Raised This Month: $12 Target: $400
 3% 

[CS:GO] coinflip credits for store plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drespy
Member
Join Date: Jul 2018
Old 07-07-2018 , 22:15   [CS:GO] coinflip credits for store plugin
Reply With Quote #1

I'm looking for a plugin that makes a wrap style like coinflip, the command would be "!coinflip <Heads or Tails> <quantity>"


Store plugin
https://forums.alliedmods.net/showthread.php?t=276677


thx...
drespy is offline
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
drespy
Member
Join Date: Jul 2018
Old 07-08-2018 , 14:03   Re: [CS:GO] coinflip credits for store plugin
Reply With Quote #3

Quote:
Originally Posted by LenHard View Post
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;  


Plugin is not working due to the following error:

coinflip_store.smx: Unable to load plugin (no debug string table)





edit:
It was just a bug in the compile, I solved it, thanks the plugin worked perfectly!

Last edited by drespy; 07-08-2018 at 15:33.
drespy is offline
drespy
Member
Join Date: Jul 2018
Old 07-19-2018 , 15:30   Re: [CS:GO] coinflip credits for store plugin
Reply With Quote #4

Quote:
Originally Posted by LenHard View Post
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;  

It's possible add 10 sec. delay to use command? xD
drespy is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 07-19-2018 , 20:01   Re: [CS:GO] coinflip credits for store plugin
Reply With Quote #5

Quote:
Originally Posted by drespy View Post
It's possible add 10 sec. delay to use command? xD
PHP Code:
#include <sourcemod>   
#include <store> 

#pragma semicolon 1   
#pragma newdecls required   

#define DELAY 10.0

float gF_Delay[MAXPLAYERS 1];

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

public 
void OnClientPostAdminCheck(int client) {
    
gF_Delay[client] = 0.0;    
}

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;     
        } 
        
        
float fTime GetGameTime();
        
        if (
gF_Delay[client] > fTime)
        {
            
ReplyToCommand(client"[SM] You need to wait \x04%.02f\x01 seconds before using the command again."gF_Delay[client] - fTime); 
            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
            } 
            
            
gF_Delay[client] = fTime DELAY;
             
            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-19-2018 at 20:02.
LenHard is offline
drespy
Member
Join Date: Jul 2018
Old 07-19-2018 , 20:31   Re: [CS:GO] coinflip credits for store plugin
Reply With Quote #6

Quote:
Originally Posted by LenHard View Post
PHP Code:
#include <sourcemod>   
#include <store> 

#pragma semicolon 1   
#pragma newdecls required   

#define DELAY 10.0

float gF_Delay[MAXPLAYERS 1];

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

public 
void OnClientPostAdminCheck(int client) {
    
gF_Delay[client] = 0.0;    
}

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;     
        } 
        
        
float fTime GetGameTime();
        
        if (
gF_Delay[client] > fTime)
        {
            
ReplyToCommand(client"[SM] You need to wait \x04%.02f\x01 seconds before using the command again."gF_Delay[client] - fTime); 
            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
            } 
            
            
gF_Delay[client] = fTime DELAY;
             
            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;   

Worked fine! thanks.
drespy is offline
Reply


Thread Tools
Display Modes

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 19:14.


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