Raised This Month: $ Target: $400
 0% 

Request Costume Shop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xeloxded
Member
Join Date: Dec 2016
Old 03-18-2017 , 21:48   Request Costume Shop
Reply With Quote #1

Hello, I have this plugin, Its works fine but lacks some things that i need, if someone can help me with this, I would be grateful

#include <adv_vault> alternative to sql, sqlite, nvault.
#include <expmod> where i have my custom natives, alternatives to cs_set_user... and cs_get_user...

What i need, 2 separate menu where you can buy customes and a Menu like a Inventory where you can choose your already bought costumes, You can use up to 3 costumes at the same time but not the same costumes, because you have <HEAD> <PELVIS> and <BACK>, at the moment you can just use 1, either Head, Pelvis and Back, so its seems a bit useless.

If you bought a costume, it will NOT appear again on the menu but on Inventory
When you choose a Costume (max. 3) it will appear on Inventory: Costume Name #1 - On Use



PHP Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <amx_settings_api>
#include <adv_vault>
#include <expmod> // cs_get_user_money and cs_set_user_money natives -> exp_get_user_monets and exp_set_user_monets
#include <colorchat>

new gVaultgF1gF2;
new const 
__VAULTNAME[] = "data_costumes";

/* ======================================================================================================================= */

new const __Plugin[][] = { "Costume Shop" "1.0" "kikizon" };
new const 
__Commands[][] = { "say /shopcostumes""say /hats" };
new const 
__COSTUMES_FILE[] = "costumes.ini";

const 
MAX_COSTUMES 56 ;

new 
cached_costume_name[MAX_COSTUMES][32], cached_costume_model[MAX_COSTUMES][64], cached_costume_submodel[MAX_COSTUMES], 
cached_costume_price[MAX_COSTUMES], costume_countergMaxPlayers;
new 
gSelectedCostume33 ][ ], gUnlockedCostumes33 ][ MAX_COSTUMES ], gPlayerName33 ][ 32 ];


/* ======================================================================================================================= */

public plugin_precache()
{
    new 
iszBuffer[128];
    for( 
MAX_COSTUMES ; ++)
    {
        if( 
costume_counter >= MAX_COSTUMES )
            break;

        
formatexszBuffer127"COSTUME_%d");

        if( !
amx_load_setting_string__COSTUMES_FILEszBuffer"NOMBRE"cached_costume_name[i], 31 )) continue;

        
amx_load_setting_string__COSTUMES_FILEszBuffer"MODEL"cached_costume_model[i], 31);
        
amx_load_setting_int__COSTUMES_FILEszBuffer"SUB MODEL"cached_costume_submodel[i] );
        
amx_load_setting_int__COSTUMES_FILEszBuffer"PRICE"cached_costume_price[i]);
        
        
precache_model(cached_costume_model[i]);

        ++
costume_counter;
    }
}

public 
plugin_init()
{
    
register_plugin__Plugin0x0000 ] , __Plugin0x0001 ] , __Plugin0x0002 ] );
    
register_cvar"costumes"__Plugin0x0002 ], FCVAR_SERVER|FCVAR_SPONLY );
    
set_cvar_string"costumes"__Plugin0x0002 ] );

    
register_event"HLTV" "ev_RoundStart" "a" "1=0" "2=0" );

    new 
i;
    for( 
sizeof __Commands ; ++)
        
register_clcmd__Commands[i] , "clcmdCostumes" );

    
RegisterHamHam_Spawn"player""hamSpawnPost"true );
    
RegisterHamHam_Killed"player""hamKilledPost"true );

    
gMaxPlayers get_maxplayers();

    
gVault adv_vault_open__VAULTNAME );
    
gF1 adv_vault_register_fieldgVault"Selected" );
    
gF2 adv_vault_register_fieldgVault"Unlocked"DATATYPE_ARRAYMAX_COSTUMES );
    
adv_vault_initgVault );
}

/* ======================================================================================================================= */

public client_putinserverindex )
{
    
get_user_nameindex gPlayerNameindex ] , 31 );

    
gSelectedCostumeindex ][ ] = gSelectedCostumeindex ][ ] = 0;

    new 
i;
    for( 
costume_counter ; ++)
        
gUnlockedCostumesindex ][ ] = 0;

    
LoadDataindex );
}

public 
client_disconnectindex 
{
    if( 
gSelectedCostume[index][0] )
    {
        
remove_entitygSelectedCostume[index][1] );
        
gSelectedCostume[index][1] = 0;
    }

    
SaveDataindex );
}

public 
hamSpawnPostindex )
{
    if( 
gSelectedCostume[index][0])
    {
        
DeleteCostume(indexfalse);
        
SetCostume(index);
    }
}

public 
hamKilledPostvictim attacker sg )
    if( 
gSelectedCostume[victim][0])
        
DeleteCostumevictim false );

public 
ev_RoundStart()
{
    new 
i;
    for( 
<= gMaxPlayers ; ++)
    {
        if( !
is_user_connected(i)) continue;

        
DeleteCostume(ifalse);
        
SaveData(i);
    }
}

/* ======================================================================================================================= */

public clcmdCostumesindex )
{
    new 
szBuffer[64], menu menu_create"\yCostume Shop" "menu_clcmd");

    
menu_additemmenu gSelectedCostume[index][0] ? "\yRemover Current Costume" "\dCostume not found" );

    if(
gSelectedCostume[index][0]) formatexszBuffer 63 "Select Costume: [\y%s\w]"cached_costume_namegSelectedCostume[index][0] ] )
    else 
formatexszBuffer 63"Select Costume" );
    
menu_additemmenu szBuffer );

    
menu_displayindex menu );
    return 
PLUGIN_HANDLED;
}

public 
menu_clcmdindex menuitem )
{
    if( 
item != MENU_EXIT )
    {
        if(!
itemDeleteCostumeindextrue );
        else 
ShowCostumeMenuindex );
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

ShowCostumeMenuindex )
{
    new 
iszBuffer[64], moneymenuszNum[4];
    
menu menu_create"\wCostume Shop" "menu_costume" );
    
money exp_get_user_monets(index);

    for( 
<= costume_counter ; ++)
    {
        if ( !
cached_costume_name[i][0] ) continue;

        if( 
gUnlockedCostumes[index][i] == 1)
            
formatexszBuffer63cached_costume_name[i] );
        else if( 
gSelectedCostume[index][0] == )
            
formatexszBuffer 63 "\d%s \y[On Use]"cached_costume_name[i] );
        else if( 
money cached_costume_price[i] )
            
formatexszBuffer 63 "\d%s \y[Cost: $%d]"cached_costume_name[i], cached_costume_price[i] );
        else 
            
formatexszBuffer 63 "\w%s \y[Cost: $%d]"cached_costume_name[i], cached_costume_price[i] );

        
num_to_strszNum );
        
menu_additemmenu szBuffer szNum );
    }

    
menu_displayindex menu );
}

public 
menu_costumeindex menu item )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[3], Name[64], accesscallbacki;
    
menu_item_getinfo(menuitemaccessdata2Name63callback);
    
str_to_num(data);

    if( 
gUnlockedCostumes[index][i] == )
    {
        
DeleteCostumeindex true );
        
ColorChat(indexGREEN"^x04[JailBreaK PaiN]^x01 Choosed:^x03 %s"cached_costume_name[i] );
        
gSelectedCostume[index][0] = i;
        
SetCostumeindex );
    }
    else if( 
gSelectedCostume[index][0] == )
        
ColorChat(indexGREEN"^x04[JailBreaK PaiN]^x01 Costume already choosed" );
    else if( 
exp_get_user_monets(index) < cached_costume_price[i] )
        
ColorChat(indexGREEN"^x04[JailBreaK PaiN]^x01 You dont have enough money" );
    else
    {
        
gUnlockedCostumes[index][i] = 1;
        
DeleteCostume(indextrue);
        
exp_set_user_monets(indexexp_get_user_monets(index) - cached_costume_price[i])
        
ColorChat(indexGREEN"^x04[JailBreaK PaiN]^x01 Bought:^x03 %s"cached_costume_name[i] );
        
gSelectedCostume[index][0] = i;
        
SetCostume(index);
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

/* ======================================================================================================================= */

LoadDataindex )
{
    if( !
adv_vault_get_preparegVault gPlayerNameindex ] ))
        return;

    
gSelectedCostumeindex ][0] = adv_vault_get_fieldgVault gF1 );
    
adv_vault_get_fieldgVault gF2 gUnlockedCostumes[index], MAX_COSTUMES-);
}

SaveDataindex )
{
    if( !
is_user_connected(index) ) return;

    
adv_vault_set_startgVault );

    
adv_vault_set_fieldgVault gF1 gSelectedCostumeindex ][0] );
    
adv_vault_set_fieldgVault gF2 gUnlockedCostumesindex ] );

    
adv_vault_set_endgVault gPlayerName[index] );
}

stock SetCostume(index)
{
    if( !
is_user_alive(index)) return ;
        
    
gSelectedCostume[index][1] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));

    
set_pev(gSelectedCostume[index][1], pev_movetypeMOVETYPE_FOLLOW );
    
set_pev(gSelectedCostume[index][1], pev_aimentindex );
    
set_pev(gSelectedCostume[index][1], pev_rendermodekRenderNormal );
            
    
engfunc(EngFunc_SetModelgSelectedCostume[index][1], cached_costume_modelgSelectedCostume[index][0] ]);
            
    
set_pev(gSelectedCostume[index][1], pev_bodycached_costume_submodelgSelectedCostume[index][0] ]);
    
set_pev(gSelectedCostume[index][1], pev_sequencecached_costume_submodelgSelectedCostume[index][0] ]);
    
set_pev(gSelectedCostume[index][1], pev_animtimeget_gametime());
    
set_pev(gSelectedCostume[index][1], pev_framerate1.0);
}

stock DeleteCostumeindex type )
{
    if( 
type )
    {
        
remove_entity(gSelectedCostume[index][1] );
        
gSelectedCostume[index][1] = 0;
        
gSelectedCostume[index][0] = 0;
    }
    else 
    {
        
remove_entity(gSelectedCostume[index][1] );
        
gSelectedCostume[index][1] = 0;
    }

xeloxded is offline
xeloxded
Member
Join Date: Dec 2016
Old 03-19-2017 , 20:02   Re: Request Costume Shop
Reply With Quote #2

Any help?
xeloxded 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 18:14.


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