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

Coinflip (zephyrus-store)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Simon.
Member
Join Date: Oct 2016
Location: Sweden
Plugin ID:
5534
Plugin Version:
1.0.3
Plugin Category:
Fun Stuff
Plugin Game:
Counter-Strike: GO
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Old 02-15-2017 , 12:24   Coinflip (zephyrus-store)
    Reply With Quote #1

    Description:

    A simple coinflip plugin for Zephyrus store!

    Commands:

    !coinflip <team> <amount>
    !flip <team> <amount>

    Cvars:
    Code:
      
    // Maximum credits to bet!
    // -
    // Default: "10000"
    sm_coinflip_max_credits "10000"
    
    // Minimum credits to bet!
    // -
    // Default: "10"
    sm_coinflip_min_credits "10"
    Installation:

    Just simply drag the smx file into the plugins folder, (addons/sourcemod/plugins)

    When the plugin has been loaded it will automatically create a config file, (cfg/sourcemod/zephyrus-coinflip.cfg)

    Todo:

    Nothing for now but it's always room for improvement !

    Changelog:
    Code:
            
    Changelog
    
    1.0.3 - 2017 02/22 - More bug fixes!
    
    1.0.2 - 2017 02/20 - Bug fixes, added config/cvars to minimum/maximum bet 
    
    1.0.1 - 2017 02/15 - Mitchell cleaned up the code, special thanks to him!
    	
    1.0.0 - 2017 02/15 - Published the plugin!

    ps, this is my first plugin post, I hope that I did it right
    Attached Files
    File Type: smx zephyrus-coinflip.smx (14.0 KB, 847 views)
    File Type: sp Get Plugin or Get Source (zephyrus-coinflip.sp - 769 views - 2.6 KB)
    File Type: zip includes.zip (14.3 KB, 708 views)
    __________________

    Last edited by Simon.; 02-22-2017 at 17:56.
    Simon. is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 02-15-2017 , 12:35   Re: Coinflip (zephyrus-store)
    Reply With Quote #2

    Code:
    		if(StrEqual(arg1, "ct")){}
    		else if(StrEqual(arg1, "t")){}
    		else if(StrEqual(arg1, "CT")){}
    		else if(StrEqual(arg1, "T")){}
    		else
    		{
    			CPrintToChat(client, "%s Invalid team!", MSG_PREFIX);
    			return;
    		}
    Why not just use one if statement??
    And you literally do #pragma tabsize 0 just to get around the fact that you are using both tabs and spaces to indent no to mention where you use both to indent on the same line!
    You're copying and pasting also leads to mixed syntax, either stick to the old syntax (which I don't recommend) or go full new syntax.
    edit: not to mention that you have a ton of stuff that's in there for no reason, like the variable won.

    Last edited by Mitchell; 02-15-2017 at 12:44.
    Mitchell is offline
    Simon.
    Member
    Join Date: Oct 2016
    Location: Sweden
    Old 02-15-2017 , 12:55   Re: Coinflip (zephyrus-store)
    Reply With Quote #3

    I'm still learning as I said this is my first plugin posted on am, and as I also said its always room for improvements especially when you're new like me....

    But now that I know how bad my plugin is I also know what I can do better in the next one.
    __________________

    Last edited by Simon.; 02-15-2017 at 13:00.
    Simon. is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 02-15-2017 , 13:02   Re: Coinflip (zephyrus-store)
    Reply With Quote #4

    Well i got bored, so i cleaned up the code, didn't test it, maybe you can learn from what's different.

    Last edited by Mitchell; 02-15-2017 at 16:33.
    Mitchell is offline
    plock
    Senior Member
    Join Date: Feb 2016
    Location: noitacoL
    Old 02-15-2017 , 16:03   Re: Coinflip (zephyrus-store)
    Reply With Quote #5

    Quote:
    Originally Posted by Mitchell View Post
    Well i got bored, so i cleaned up the code, didn't test it, maybe you can learn from what's different.
    Instead of:
    Code:
    if(!StrEqual(arg1, "ct",false) || !StrEqual(arg1, "t",false)) {
    You should use:
    Code:
    if(!StrEqual(arg1, "ct",false) && !StrEqual(arg1, "t",false)) {
    Because if it's not CT and not T then it's invalid.

    Btw, awesome plugin! I just tested on custom shop and it works like a charm!
    Attached Files
    File Type: sp Get Plugin or Get Source (zephyrus-coinflip.sp - 396 views - 1.9 KB)
    __________________
    ~tuturu

    Owner/Developer at Kniv
    My Steam Profile

    Last edited by plock; 02-15-2017 at 16:06.
    plock is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 02-15-2017 , 16:34   Re: Coinflip (zephyrus-store)
    Reply With Quote #6

    Yep, got those mixed up, nice catch.
    Mitchell is offline
    Nexicon
    Senior Member
    Join Date: Feb 2017
    Old 02-18-2017 , 22:16   Re: Coinflip (zephyrus-store)
    Reply With Quote #7

    Will be SO nice if you can create a max coinflip price like 500 and cooldown so you maybe can flip specific times every map/round.. And win chance a littlebit lower

    Else, nice plugin!
    Nexicon is offline
    TheRealToxic
    Senior Member
    Join Date: Jul 2015
    Old 02-20-2017 , 03:46   Re: Coinflip (zephyrus-store)
    Reply With Quote #8

    coinflip is a nice thing, but there is a lot more that needs to be fixed.

    - check the chat ingame.
    - max amount via cfg
    - some other cfg's
    - maybe menu if !flip comes: You choose? "CT" "T" and u can click

    other than that cool!
    TheRealToxic is offline
    Simon.
    Member
    Join Date: Oct 2016
    Location: Sweden
    Old 02-20-2017 , 14:06   Re: Coinflip (zephyrus-store)
    Reply With Quote #9

    Quote:
    Originally Posted by TheRealToxic View Post
    coinflip is a nice thing, but there is a lot more that needs to be fixed.

    - check the chat ingame.
    - max amount via cfg
    - some other cfg's
    - maybe menu if !flip comes: You choose? "CT" "T" and u can click

    other than that cool!

    Thanks for the feedback, there is now an option for minimum/maximum amount of credits per bet.
    __________________
    Simon. is offline
    xfusionlockx
    AlliedModders Donor
    Join Date: Aug 2014
    Old 07-19-2017 , 20:40   Re: Coinflip (zephyrus-store)
    Reply With Quote #10

    Code:
    //Coinflip system originally coded by siimon. Cleaned by FusionLock.
    
    #pragma semicolon 1
    
    #include <multicolors>
    #include <sourcemod>
    #include <store>
    
    #pragma newdecls required
    
    #define MSG_PREFIX "{default}[{blue}Coinflip{default}]"
    
    #define PLUGIN_NAME "Coinflip"
    #define PLUGIN_VERSION "1.0.3"
    
    ConVar g_hMincredits;
    ConVar g_hMaxcredits;
    
    public Plugin myinfo = {
    	name = PLUGIN_NAME,
    	author = "siimon",
    	description = "A basic coinflip system for the Zephyrus Store.",
    	version = PLUGIN_VERSION,
    	url = "siimon.org"
    }
    
    public void OnPluginStart()
    {
    	CreateConVar("sm_coinflip_version", PLUGIN_VERSION, PLUGIN_NAME, FCVAR_SPONLY|FCVAR_DONTRECORD|FCVAR_NOTIFY);
    	
    	RegConsoleCmd("sm_coinflip", Command_CoinFlip, "FLIP THAT COIN!");
    	RegConsoleCmd("sm_flip", Command_CoinFlip, "FLIP THAT COIN!");
        
    	g_hMincredits = CreateConVar("sm_coinflip_min_credits", "10", "Minimum credits to bet!");
    	g_hMaxcredits = CreateConVar("sm_coinflip_max_credits", "10000", "Maximum credits to bet!");
    	
    	AutoExecConfig(true, "zephyrus-coinflip");
    }
    
    public Action Command_CoinFlip(int iClient, int iArgs)
    {
    	if(iClient <= 0 && iClient > MaxClients && !IsClientInGame(iClient))
    	{
    		return Plugin_Handled;
    	}
    	
    	if(iArgs < 2)
    	{
    		CReplyToCommand(iClient, "%s Usage: {blue}%scoinflip{default} <{blue} T / CT {default}> <{blue}amount{default}>", MSG_PREFIX, GetCmdReplySource() == SM_REPLY_TO_CONSOLE ? "sm_" : "!");
    		return Plugin_Handled;
    	}
    
    	char sArg1[3], sArg2[16];
    	
    	GetCmdArg(1, sArg1, sizeof(sArg1));
    
    	if(!StrEqual(sArg1, "ct", false) && !StrEqual(sArg1, "t", false))
    	{
    		CPrintToChat(iClient, "%s: Invalid team! ", MSG_PREFIX);
    		
    		CReplyToCommand(iClient, "%s Usage: {blue}%scoinflip{default} <{blue} T / CT {default}> <{blue}amount{default}>", MSG_PREFIX, GetCmdReplySource() == SM_REPLY_TO_CONSOLE ? "sm_" : "!");
    		
    		return Plugin_Handled;
    	}
    
    	GetCmdArg(2, sArg2, sizeof(sArg2));
    	
    	int iAmount = StringToInt(sArg2);
    	
    	int iCurrentCredits = Store_GetClientCredits(iClient);
    	
    	int iMinAmount = g_hMincredits.IntValue;
    	int iMaxAmount = g_hMaxcredits.IntValue;
    	
    	if(iCurrentCredits < iAmount)
    	{
    		CPrintToChat(iClient, "%s: Not enough credits!", MSG_PREFIX);
    		
    		return Plugin_Handled;
    	}else if(iAmount < iMinAmount)
    	{
    		CPrintToChat(iClient, "%s: You have to spend at least {blue}%d{default} credits!", MSG_PREFIX, iMinAmount);
    		
    		return Plugin_Handled;
    	}else if(iAmount > iMaxAmount)
    	{
    		CPrintToChat(iClient, "%s: You can't spend that much credits (Max: {blue}%d{default}).", MSG_PREFIX, iMaxAmount);
    		
    		return Plugin_Handled;
    	}
    	
    	bool bWon = (GetRandomInt(1,100) > 50);
    	
    	CPrintToChat(iClient, "%s You choose {blue}%s{default} and %s {blue}%d{default} credits", MSG_PREFIX, sArg1, bWon ? "won additional" : "lost your", iAmount);
    	
    	Store_SetClientCredits(iClient, iCurrentCredits + (bWon ? iAmount : -iAmount));
    	
    	return Plugin_Handled;
    }
    I cleaned up and changed a bit of the latest version of this store module.
    Attached Files
    File Type: smx coinflip.smx (14.7 KB, 404 views)
    xfusionlockx 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 07:24.


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