AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Kewaii Roulette in Command (https://forums.alliedmods.net/showthread.php?t=328699)

Shins 11-21-2020 15:34

Kewaii Roulette in Command
 
Hello

I would like to make this in command !roulette <color> <credits>


PHP Code:

#pragma semicolon 1
#include <csgocolors>
#include <store>
#include <sourcemod>
#include <sdktools>
#pragma newdecls required

int ScrollTimes[MAXPLAYERS 1];
int WinNumber[MAXPLAYERS 1];
int betAmount[MAXPLAYERS 1];
bool isSpinning[MAXPLAYERS 1] = false;


//ConVar g_Cvar_NormalItems;
//ConVar g_Cvar_VIPItems;
ConVar g_Cvar_VIPFlag;

char FULL_SOUND_PATH[] = "sound/ruleta/ruleta.mp3";
char RELATIVE_SOUND_PATH[] = "*ruleta/ruleta.mp3";
    
//char g_sNormalItems[64];
//char g_sVIPItems[64];
#define PLUGIN_NAME "Store Roulette by Kewaii"
#define PLUGIN_AUTHOR "Kewaii"
#define PLUGIN_DESCRIPTION "Zephyrus Store Roulette"
#define PLUGIN_VERSION "1.3.9"
#define PLUGIN_TAG " \x07[ HAWKS ]"

public Plugin myinfo =
{
    
name        =    PLUGIN_NAME,
    
author        =    PLUGIN_AUTHOR,
    
description    =    PLUGIN_DESCRIPTION,
    
version        =    PLUGIN_VERSION,
    
url            =    "http://steamcommunity.com/id/KewaiiGamer"
};

public 
void OnPluginStart()
{    
    
g_Cvar_VIPFlag CreateConVar("kewaii_roulette_vip_flag""a""VIP Access Flag");
    
//g_Cvar_NormalItems = CreateConVar("kewaii_roulette_normal_items", "100,500,750,1000,1500,1750,2000,2500,3000,4000,5000", "Lists all the menu items for normal player roulette. Separate each item with a comma. Only integers allowed");
    //g_Cvar_VIPItems = CreateConVar("kewaii_roulette_vip_items", "5000,5500,6000,6500,7000,7500,8000,8500,9000,10000,12500,15000", "Lists all the menu items for VIP player roulette. Separate each item with a comma. Only integers allowed");
    
RegConsoleCmd("sm_ruleta"CommandRoulette);
    
LoadTranslations("kewaii_roulette.phrases");
    
AutoExecConfig(true"kewaii_roulette");
}

public 
void OnMapStart()
{
    
AddFileToDownloadsTableFULL_SOUND_PATH);
    
FakePrecacheSound(RELATIVE_SOUND_PATH);
}

public 
void OnClientPostAdminCheck(int client)
{
    
isSpinning[client] = false;
}

public 
Action CommandRoulette(int clientint args)
{
    if (
args 1)
    {
        
ReplyToCommand(client"[SM] Usage: sm_ruleta <culoare> <suma>");
        return 
Plugin_Handled;
    }
}

/*Menu CreateRouletteMenu(int client)
{
    Menu menu = new Menu(RouletteMenuHandler);
    char buffer[128];
    Format(buffer, sizeof(buffer), "%T", "ChooseType", client);
    menu.SetTitle(buffer);    
    menu.AddItem("player", "Player");
    menu.AddItem("vip", "VIP", !HasClientVIP(client) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT);        
    return menu;
}

public int RouletteMenuHandler(Menu menu, MenuAction action, int client, int selection)
{
    switch(action)
    {
        case MenuAction_Select:
        {
            if(IsClientInGame(client))
            {
                char option[32];
                menu.GetItem(selection, option, sizeof(option));
                if (StrEqual(option, "player"))
                {
                    CreatePlayerRouletteMenu(client).Display(client, MENU_TIME_FOREVER);
                }
                if (StrEqual(option, "vip"))
                {
                    CreateVIPRouletteMenu(client).Display(client, MENU_TIME_FOREVER);
                }
            }
        }
        case MenuAction_End:
        {
            delete menu;
        }
    }
}


Menu CreatePlayerRouletteMenu(int client)
{
    Menu menu = new Menu(CreditsChosenMenuHandler);
    char buffer[128];
    Format(buffer, sizeof(buffer), "%T", "ChooseCredits", client, Store_GetClientCredits(client));
    menu.SetTitle(buffer);    
    GetConVarString(g_Cvar_NormalItems, g_sNormalItems, sizeof(g_sNormalItems));
    char sItems[18][16];
    ExplodeString(g_sNormalItems, ",", sItems, sizeof(sItems), sizeof(sItems[]));
    for (int i = 0; i < sizeof(sItems); i++) {
        if (!StrEqual(sItems[i], "")) {
            menu.AddItem(sItems[i], sItems[i], Store_GetClientCredits(client) >= StringToInt(sItems[i]) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED);    
        }
    }
    menu.ExitBackButton = true;
    return menu;
}


Menu CreateVIPRouletteMenu(int client)
{
    Menu menu = new Menu(CreditsChosenMenuHandler);
    char buffer[128];        
    Format(buffer, sizeof(buffer), "%T", "ChooseCredits", client, Store_GetClientCredits(client));
    menu.SetTitle(buffer);    
    GetConVarString(g_Cvar_VIPItems, g_sVIPItems, sizeof(g_sVIPItems));
    char sItems[18][16];
    ExplodeString(g_sVIPItems, ",", sItems, sizeof(sItems), sizeof(sItems[]));
    for (int i = 0; i < sizeof(sItems); i++) {
        if (!StrEqual(sItems[i], "")) {
            menu.AddItem(sItems[i], sItems[i], Store_GetClientCredits(client) >= StringToInt(sItems[i]) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED);    
        }
    }
    menu.ExitBackButton = true;
    return menu;
}

public int CreditsChosenMenuHandler(Menu menu, MenuAction action, int client, int selection)
{
    switch(action)
    {
        case MenuAction_Select:
        {
            if(IsClientInGame(client))
            {
                char option[32];
                menu.GetItem(selection, option, sizeof(option));
                                
                int crd = Store_GetClientCredits(client);
                int bet = StringToInt(option);
                if(crd >= bet)
                {
                    if (!isSpinning[client])
                    {
                        Store_SetClientCredits(client, crd - bet);
                        betAmount[client] = bet;
                        SpinCredits(client);
                        isSpinning[client] = true;
                    }
                    else
                    {
                        CPrintToChat(client, "%s %t", PLUGIN_TAG, "AlreadySpinning");
                    }
                } 
                else
                {
                    CPrintToChat(client, "%s %t", PLUGIN_TAG,  "NoEnoughCredits", bet - crd);
                }
            }
        }
        case MenuAction_Cancel:
        {
            if (IsClientInGame(client) && selection == MenuCancel_ExitBack)
            {
                CreateRouletteMenu(client).Display(client, 10);
            }
        }
        case MenuAction_End:
        {
            delete menu;
        }
    }
}*/

public void SpinCredits(int client)
{
    
int    FakeNumber GetRandomInt(0,999);
    if(
FakeNumber && FakeNumber 111)
    {
    
PrintHintText(client"</font><font color='#75D1FF'>→ </font><font color='#FFFFFF'>Culoare: </font><font color='#00FF00'> Verde  </font><font color='#75D1FF'>←"FakeNumber);
    }
    if(
FakeNumber 111 && FakeNumber 555)
    {
    
PrintHintText(client"</font><font color='#75D1FF'>→ </font><font color='#FFFFFF'>Culoare: </font><font color='#000000'>Negru </font><font color='#75D1FF'>←"FakeNumber);
    }
    if(
FakeNumber >= 555 && FakeNumber 999)
    {
    
PrintHintText(client"</font><font color='#75D1FF'>→ </font><font color='#FFFFFF'>Culoare: </font><font color='#E60000'>Rosu  </font><font color='#75D1FF'>←"FakeNumber);
    }
    if(
ScrollTimes[client] == 0)
    {
        
ClientCommand(client"playgamesound *ui/csgo_ui_crate_open.wav");
    }
    if(
ScrollTimes[client] < 20)
    {
        
CreateTimer(0.05TimerNextclient);
        
ScrollTimes[client] += 1;
        
ClientCommand(client"playgamesound *ui/csgo_ui_crate_item_scroll.wav");
    } 
    else if(
ScrollTimes[client] < 30)
    {
        
float AddSomeTime 0.05 ScrollTimes[client] / 3;
        
CreateTimer(AddSomeTimeTimerNextclient);
        
ScrollTimes[client] += 1;
        
ClientCommand(client"playgamesound *ui/csgo_ui_crate_item_scroll.wav");
    }
    else if(
ScrollTimes[client] == 30)
    {
        
int troll GetRandomInt(1,2);
        if(
troll == 1)
        {
            
ClientCommand(client"playgamesound *ui/csgo_ui_crate_item_scroll.wav");
            
ScrollTimes[client] += 1;
            
CreateTimer(1.5TimerNextclient);
        }
        else
        {
            
ClientCommand(client"playgamesound *ui/csgo_ui_crate_item_scroll.wav");
            
CreateTimer(1.5TimerFinishingclient);
            
WinNumber[client] = FakeNumber;
            
ScrollTimes[client] = 0;
        }
    } 
    else
    {
        
ClientCommand(client"playgamesound *ui/csgo_ui_crate_item_scroll.wav");
        
CreateTimer(1.5TimerFinishingclient);
        
WinNumber[client] = FakeNumber;
        
ScrollTimes[client] = 0;
    }
}

public 
Action TimerFinishing(Handle timerany client)
{
    if (
IsClientInGame(client))
    {
        
isSpinning[client] = false;
        
WinCredits(clientWinNumber[client], betAmount[client]);
    }
}

public 
void WinCredits(int clientint Numberint Bet)
{
    if(
IsClientInGame(client))
    {            
        
int multiplier;
        if(
Number >= && Number 111)
        {
            
multiplier 14;
            if(
Bet multiplier >= 70000)
            {
                
EmitSoundToAll(RELATIVE_SOUND_PATH);
            }
            else
            {
            
ClientCommand(client"playgamesound *ui/item_drop3_rare.wav");
            }
        }
        if(
Number >= 111 && Number 555)
        {
            
multiplier 2;
            
ClientCommand(client"playgamesound *ui/item_drop3_rare.wav");
        }
        if(
Number >= 555 && Number 999)
        {
            
multiplier 2;
            
ClientCommand(client"playgamesound *ui/item_drop3_rare.wav");
        }
        if (
multiplier 0)
        {    
            if(
Bet multiplier >= 10000)
            {
                if(
Number >= && Number 111)
                {
                
CPrintToChatAll("%s \x04%N \x01a castigat \x07%i \x01credite pe culoarea verde!"PLUGIN_TAGclientBet multiplier);
                }
                if(
Number >= 111 && Number 555)
                {
                
CPrintToChatAll("%s \x04%N \x01a castigat \x07%i \x01credite pe culoarea neagra!"PLUGIN_TAGclientBet multiplier);
                }
                if(
Number >= 555 && Number 999)
                {
                
CPrintToChatAll("%s \x04%N \x01a castigat \x07%i \x01credite pe culoarea rosie!"PLUGIN_TAGclientBet multiplier);
                }
            }
            if(
Number >= && Number 111)
            {
                
CPrintToChat(client"%s \x01Ai castigat {red}%i credite \x01pe culoare verde!"PLUGIN_TAGBet multiplier);
            }
            if(
Number >= 111 && Number 555)
            {
                
CPrintToChat(client"%s \x01Ai castigat {red}%i credite \x01pe culoarea neagra!"PLUGIN_TAGBet multiplier);
            }
            if(
Number >= 555 && Number 999)
            {
                
CPrintToChat(client"%s \x01Ai castigat {red}%i credite \x01pe culoarea rosie!"PLUGIN_TAGBet multiplier);
            }
            
Store_SetClientCredits(clientStore_GetClientCredits(client) + Bet * (multiplier 1));
        }
    }
}

public 
Action TimerNext(Handle timerany client)
{
    if (
IsClientInGame(client))
    {
        
SpinCredits(client);
    }
}

public 
bool HasClientVIP(int client)
{
    
char ConVarValue[32];
    
GetConVarString(g_Cvar_VIPFlagConVarValuesizeof(ConVarValue));
    
int flag ReadFlagString(ConVarValue);
    return 
CheckCommandAccess(client""flagtrue);
    
}

void FakePrecacheSound(const char[] szPath)
{
    
AddToStringTable(FindStringTable"soundprecache" ), szPath);



StrikeR14 11-21-2020 15:53

Re: Kewaii Roulette in Command
 
If you mean having 2 commands that do the same thing:
PHP Code:

RegConsoleCmd("sm_ruleta"CommandRoulette);
RegConsoleCmd("sm_roulette"CommandRoulette); 


Shins 11-22-2020 04:10

Re: Kewaii Roulette in Command
 
Quote:

Originally Posted by StrikeR14 (Post 2725814)
If you mean having 2 commands that do the same thing:
PHP Code:

RegConsoleCmd("sm_ruleta"CommandRoulette);
RegConsoleCmd("sm_roulette"CommandRoulette); 


This plugin is a RouletteMenu and i want this in a command !roulette <color> <credits>
sm_ruleta is in my language

StrikeR14 11-22-2020 11:17

Re: Kewaii Roulette in Command
 
With the current code you have, if you type !ruleta <color> <credits> it opens your roullete menu, theoretically.
If you'll add the code part I posted above, you'll have both !ruleta <color> <credits> and !roulette<color> <credits>
However, the part of creating the roulette menu in your code is commented out, so I'm not really sure what you're asking for.

Shins 11-23-2020 07:05

Re: Kewaii Roulette in Command
 
Quote:

Originally Posted by StrikeR14 (Post 2725882)
With the current code you have, if you type !ruleta <color> <credits> it opens your roullete menu, theoretically.
If you'll add the code part I posted above, you'll have both !ruleta <color> <credits> and !roulette<color> <credits>
However, the part of creating the roulette menu in your code is commented out, so I'm not really sure what you're asking for.

You do not understand
When you write !ruleta the menu opens.
And I want to delete the whole menu and to do it command !ruleta <color> <credits> "Color: Red [x2], Black [x2], Green [x14]."

GsiX 11-24-2020 02:42

Re: Kewaii Roulette in Command
 
PHP Code:

public Action CommandRouletteint clientint args )
{
    if( 
client || client MaxClients )
    {
        return 
Plugin_Handled;
    }
    
    if( 
args )
    {
        
ReplyToCommand(client"[SM] Usage: sm_ruleta <culoare_rgb> <suma>");
        return 
Plugin_Handled;
    }
    
    
char argsCmd[16];
    
GetCmdArg1argsCmdsizeofargsCmd ));
    
    
char color[3][8];
    
ExplodeStringargsCmd","colorsizeofcolor ), sizeofcolor[] ));
    
    
int color_rgb[3];
    
color_rgba[0] = StringToIntcolor[0] ); // r
    
color_rgba[1] = StringToIntcolor[1] ); // g
    
color_rgba[2] = StringToIntcolor[2] ); // b
    
    
GetCmdArg2argsCmdsizeofargsCmd ));
    
int money StringToIntargsCmd ); // money
    
    // give them the color here << int color_rgb
    // drain they money here    << int money
    
SpinCreditsclient ); // i suppost this is Spend.. never spin a money.. mama gonna upset.
    
    
return Plugin_Handled;




All times are GMT -4. The time now is 18:48.

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