Едит на /shop плъгин (смяна на оръжията)

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
hds-forever
Извън линия
Потребител
Потребител
Мнения: 52
Регистриран на: 05 Яну 2017, 21:51

Едит на /shop плъгин (смяна на оръжията)

Мнение от hds-forever » 31 Дек 2017, 12:44

Код за потвърждение: Избери целия код

#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fakemeta >
#include < fun >
#include < engine >

// Some globals
new shop
new sw_cost
new health_cost
new armour_cost
new awp_cost
new speed_cost
new gravity_cost
new norecoil_cost
new chameleon_cost
new invisibility_cost
new gSpeedCvar
new gGravityCvar
new g_CZ
new p_iHealth
new p_iMaxHealth
new p_iAdd_Health
new gInvisPercent

// Item variables
new HasSW[ 33 ];
new HasHealth[ 33 ];
new HasArmour[ 33 ];
new HasAWP[ 33 ];
new HasSpeed[ 33 ];
new HasGravity[ 33 ];
new HasNoRecoil[ 33 ];
new HasChameleon[ 33 ];
new HasInvisibility[ 33 ];

// Those models are for the chameleon effect
new const t_models[][] =
{
    "arctic",
    "guerilla",
    "leet",
    "terror",
    "militia"
}

new const ct_models[][] =
{
    "gign",
    "gsg9",
    "sas",
    "urban",
    "spetsnaz"
}

public plugin_init()
{
    // Some events right here
    register_event( "DeathMsg", "event_death", "a")
    register_event( "DeathMsg", "Hook_Deathmessage", "a" );
    register_logevent( "logevent_round_start", 2, "1=Round_Start" );
    
    register_plugin("Shop Menu", "1.0", "Obada");
    register_clcmd("say /shop", "ShowMenu", _, "Brings up shop menu");
    
    // Price of each item in the shop, except for the first one ofcourse
    shop = register_cvar ( "amx_shop", "1" ); // 1 = On , 2 = Off
    sw_cost = register_cvar ( "amx_silentwalk_price", "2500" );
    health_cost = register_cvar ( "amx_health_price", "4000" );
    armour_cost = register_cvar ( "amx_armour_price", "3500" );
    awp_cost = register_cvar ( "amx_awp_price", "5000" );
    speed_cost = register_cvar ( "amx_speed_price", "3500" );
    gravity_cost = register_cvar ( "amx_gravity_price", "3500" );
    norecoil_cost = register_cvar ( "amx_norecoil_price", "12000" );
    chameleon_cost = register_cvar ( "amx_chameleon_price", " 14000" );
    invisibility_cost = register_cvar ( "amx_invisibility_price", "16000" );
    
    // The power of some effects on players
    gSpeedCvar = register_cvar( "amx_speed_power", "400.0" );
    gGravityCvar = register_cvar( "amx_gravity_power", "0.7" );
    g_CZ        = is_running("czero")
    p_iHealth     = register_cvar("chameleon_health", "1")
    p_iMaxHealth    = register_cvar("cham_killer_max_health", "120")
    p_iAdd_Health     = register_cvar("cham_killer_health", "20")
    gInvisPercent    = register_cvar("invisibility_percent", "111")
}

// When client is connecting, let's reset stuff
public client_connect( id )
{
    HasSW[ id ] = false;
    HasHealth[ id ] = false;
    HasArmour[ id ] = false;
    HasAWP[ id ] = false;
    HasSpeed[ id] = false;
    HasGravity[ id ] = false;
    HasNoRecoil[ id ] = false;
    HasChameleon[ id ] = false;
    HasInvisibility[ id ] = false;
}

// When client has disconnected let's reset stuff
public client_disconnect( id )
{
    HasSW[ id ] = false;
    HasHealth[ id ] = false;
    HasArmour[ id ] = false;
    HasAWP[ id ] = false;
    HasSpeed[ id] = false;
    HasGravity[ id ] = false;
    HasNoRecoil[ id ] = false;
    HasChameleon[ id ] = false;
    HasInvisibility[ id ] = false;
}

public ShowMenu(id)
{
    // If cvar is set to 0, player can't open the shop
    if( get_pcvar_num( shop ) != 1 )
    {
        client_print( id, print_chat, "[Shop] Sorry, the shop is currently disabled" );
        return PLUGIN_HANDLED;
    }
    
    // If player is dead, he/she cant buy items
    if( !is_user_alive( id ) )
    {
        client_print( id, print_chat, "[Shop] You must be alive to buy from the shop" );
        return PLUGIN_HANDLED;
    }
    
    new menu = menu_create("Shop Menu", "Shop_Menu");
    
    menu_additem(menu, "Silent Walk - \y2500$", "", 0); // case 0
    menu_additem(menu, "200 hp - \y4000$", "", 0); // case 1
    menu_additem(menu, "200 armor - \y3500$", "", 0); // case 2
    menu_additem(menu, "AWP - \y5000$", "",  0); // case 3
    menu_additem(menu, "Speed - \y3500$", "",  0); // case 4
    menu_additem(menu, "Gravity - \y3500$", "", 0); // case 5
    menu_additem(menu, "No recoil - \y12000$", "",  0); // case 6
    menu_additem(menu, "Chameleon (change skin) - \y14000$", "", 0); // case 7
    menu_additem(menu, "Invisibility - \y16000$", "", 0); // case 8
    
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
    
    menu_display(id, menu, 0);
    
    return PLUGIN_HANDLED;
}

public Shop_Menu(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_cancel(id);
        return PLUGIN_HANDLED;
    }
    
    new command[6], name[64], access, callback;
    
    menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);
    
    switch(item)
    {
        case 0: // ---------- Silent Walk ----------
        {
            if( HasSW[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num( sw_cost ) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id)- get_pcvar_num(sw_cost))
            
            // Gives the player silent walk 
            set_user_footsteps( id, 1 );
                
            client_print(id, print_chat, "*** You have bought Silent Walk");
            HasSW[ id ] = true;
        }
        
        case 1: // ---------- Health Points ----------
        {
            if( HasHealth[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num( health_cost) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id) - health_cost) 

            // Gives the player 200 Health Points
            set_user_health( id, 200 )
                
            client_print(id, print_chat, "*** You have bought 200 HP");
            HasHealth[ id ] = true;
            
        }
        case 2: // ---------- Armour Points ----------
        {
            if( HasArmour[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num(armour_cost) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(armour_cost) ) 

            // Gives the player 200 Armour Points
            set_user_armor( id, 200 )
                
            client_print(id, print_chat, "*** You have bought 200 armor");
            HasArmour[ id ] = true;
        }
        
        case 3: // ---------- AWP ----------
        {
            if( HasAWP[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num( awp_cost) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(awp_cost) )

            // Give the player AWP
            give_item ( id, "weapon_awp" );
                
            client_print(id, print_chat, "*** You have bought AWP");
            HasAWP[ id ] = true;

        }
        
        case 4: // ---------- Speed ----------
        {
            if( HasSpeed[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num( speed_cost) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(speed_cost) )
            
            // Gives the player speed
            set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
                
            client_print(id, print_chat, "*** You have bought Speed");
            HasSpeed[ id ] = true;
        }
        
        case 5: // ---------- Gravity ----------
        {
            if( HasGravity[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num( gravity_cost) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(gravity_cost) )

            // Gives the player some lower gravity
            set_user_gravity( id, get_pcvar_float( gGravityCvar ) );
                
            client_print(id, print_chat, "*** You have bought Gravity");
            HasGravity[ id ] = true;
        }
        
        case 6: // ---------- No Recoil ----------
        {
            if( HasNoRecoil[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num( norecoil_cost) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(norecoil_cost) )

            // Gives the player no recoil
            if(get_user_button(id) & IN_ATTACK)
                entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0});

                
            client_print(id, print_chat, "*** You have bought No recoil");
            HasNoRecoil[ id ] = true;
        }
        
        case 7: // ---------- Chameleon --------------------
        {
            if( HasChameleon[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num( chameleon_cost) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(chameleon_cost) )

            //Gives the player some chameleon effect
            new name [32]
            get_user_name(id, name, 31)
                
            switch(cs_get_user_team(id))
            {
                case CS_TEAM_T:
                {
                    cs_set_user_model(id, ct_models[random(g_CZ ? 5 : 4 )])
                    client_print(id, print_chat, "*** You have bought the Chameleon effect");
                    client_print(id, print_chat, "*** Make sure that cl_minmodels is set to 0, else it won't work.");
                    HasChameleon[id] = true
                }
                case CS_TEAM_CT:
                {
                    cs_set_user_model(id, t_models[random(g_CZ ? 5 : 4 )])
                    client_print(id, print_chat, "*** You have bought the Chameleon effect");
                    client_print(id, print_chat, "*** Make sure that cl_minmodels is set to 0, else it won't work.");
                    HasChameleon[ id ] = true;
                }
            }
        }
        
        case 8: // ---------- Invisibility ----------
        {    
            if( HasInvisibility[ id ] )
            {
                client_print( id, print_chat, "[Shop] You already have this item." );
                return PLUGIN_HANDLED;
            }
            
            if( cs_get_user_money(id) < get_pcvar_num( invisibility_cost) )
            {
                client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
                return PLUGIN_HANDLED;
            }
            
            cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(invisibility_cost) )
            
            // Gives the player invisibility
            set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, get_pcvar_num( gInvisPercent ) );
            
            client_print(id, print_chat, "*** You have bought Invisibility");
            HasInvisibility[ id ] = true;
            
        }
        
    }
    
    menu_display(id, menu, 0);
    
    return PLUGIN_HANDLED;
}

public event_death()
{
    new iKiller = read_data(1)
    new iVictim = read_data(2)
    
    if(iKiller != iVictim && is_user_connected(iKiller) )
    {
        if(HasChameleon[iVictim])
        {
            if(get_pcvar_num(p_iHealth))
            {
                new szKillerName[32]
                get_user_name(iKiller, szKillerName, charsmax(szKillerName))
                client_print(0, print_chat, "*** %s Receives an additional health for killing chameleon!", szKillerName)
                
                set_user_health(iKiller, get_user_health(iKiller) + get_pcvar_num(p_iAdd_Health))
                
                if(get_user_health(iKiller) >= get_pcvar_num(p_iMaxHealth))
                {
                    set_user_health(iKiller, get_pcvar_num(p_iMaxHealth))
                }
            }
            
        }
    }
}

// ------------------------------------- Stock(s) -------------------------------------

// Event for round start

public logevent_round_start()
{
    // If plugin is on
    if( get_pcvar_num( shop ) == 1 )
    {
        // I used this native because with get_maxplayers will recieve an error with invalid player id
        // This is good because we can skip bots
        new iPlayers[ 32 ], iNum, i, id;
        get_players( iPlayers, iNum, "c" );
        
        for( i = 0; i < iNum; i++ )
        {
            // Find the index
            id = iPlayers[ i ];
            
            // Reseting items
            HasSW[ id ] = false;
            HasHealth[ id ] = false;
            HasArmour[ id ] = false;
            HasAWP[ id ] = false;
            HasSpeed[ id] = false;
            HasGravity[ id ] = false;
            HasNoRecoil[ id ] = false;
            HasChameleon[ id ] = false;
            HasInvisibility[ id ] = false;
            
            set_user_footsteps( id, 0 );
            set_user_health( id, 100 );
            set_user_armor( id, 100 );
            set_user_maxspeed( id, 0.0 );
            set_user_gravity( id, 1.0 );    
            
            cs_reset_user_model(id)
            set_user_rendering( id );
            
            remove_task( id );
        }
    }
}

// Event when player died
public Hook_Deathmessage(id)
{
    // If plugin is on
    if( get_pcvar_num( shop ) == 1 )
    {
        // Get the killer and attacker
        new killer = read_data( 1 );
        new victim = read_data( 2 );

        // If player has died with world
        if( killer == victim )
        {
            return PLUGIN_HANDLED;
        }
        
    
        // Reseting items
        HasSW[ id ] = false;
        HasHealth[ id ] = false;
        HasArmour[ id ] = false;
        HasAWP[ id ] = false;
        HasSpeed[ id] = false;
        HasGravity[ id ] = false;
        HasNoRecoil[ id ] = false;
        HasChameleon[ id ] = false;
        HasInvisibility[ id ] = false;
            
        set_user_footsteps( id, 0 );
        set_user_health( id, 100 );
        set_user_armor( id, 100 );
        set_user_maxspeed( id, 0.0 );
        set_user_gravity( id, 1.0 );    
            
        cs_reset_user_model(id)
        set_user_rendering( id );
    }
    
    return PLUGIN_CONTINUE;
}
Значи проблема е следния - Когато си купя предмет от шопа, след смяна на оръжието, прим. от нож на калашник предмета спира да работи..
Ако някой може да го оправи, защото моите познания по Pawn са доста ограничени, ще съм много благодарен!
Последно промяна от hds-forever на 03 Яну 2018, 12:48, променено общо 2 пъти.
[18+] Zombie BaseBuilder
IP: 93.123.18.49:27017

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Едит на плъгин

Мнение от OciXCrom » 31 Дек 2017, 15:05

Оправи си заглавието.

Аватар
hds-forever
Извън линия
Потребител
Потребител
Мнения: 52
Регистриран на: 05 Яну 2017, 21:51

Едит на плъгин на /shop плъгин!

Мнение от hds-forever » 03 Яну 2018, 12:48

ъп?
[18+] Zombie BaseBuilder
IP: 93.123.18.49:27017

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Едит на /shop плъгин (смяна на оръжията)

Мнение от OciXCrom » 03 Яну 2018, 16:50

Ами ъп, досега чакахме да си оправиш заглавието. Обясни по-добре, какво ще каже "предметът спира да работи", тъй като нищо не разбрах. Как точно може да "спре да работи" закупената кръв?...

Аватар
hds-forever
Извън линия
Потребител
Потребител
Мнения: 52
Регистриран на: 05 Яну 2017, 21:51

Едит на /shop плъгин (смяна на оръжията)

Мнение от hds-forever » 03 Яну 2018, 18:18

Приятел.. примерно слагам на нож и пиша /shop купувам си Speed и тичам без проблем (бързо), след като превключа на калашник отново започвам да тичам нормално. Този проблем е при Chameleon, Gravity, Invisible и NoRecoil
[18+] Zombie BaseBuilder
IP: 93.123.18.49:27017

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Едит на /shop плъгин (смяна на оръжията)

Мнение от OciXCrom » 03 Яну 2018, 19:48

За speed е напълно нормално това да се случва, тъй като плъгинът не е правилно направен. За другите няма логика да става това, освен ако ти грешно си разбрал. Кажи дали наистина се случва с gravity, chameleon и останалите, а не само със speed. Ако е така - проблемът няма как да е от плъгина, съответно няма какво да се оправя в кода.

Аватар
hds-forever
Извън линия
Потребител
Потребител
Мнения: 52
Регистриран на: 05 Яну 2017, 21:51

Едит на /shop плъгин (смяна на оръжията)

Мнение от hds-forever » 03 Яну 2018, 22:08

Добре, а ако проблема със speed не е от плъгина, от какво е?
[18+] Zombie BaseBuilder
IP: 93.123.18.49:27017

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Едит на /shop плъгин (смяна на оръжията)

Мнение от OciXCrom » 04 Яну 2018, 00:58

Прочети внимателно какво написах. Проблемът със speed мога да го оправя, обаче другите неща които си изброял не ми изглеждат реални, тъй че кажи отново дали наистина има проблем с другите предмети.

Като цяло не ти препоръчвам да ползваш този плъгин, тъй като е доста зле написан. Препоръчвам ти да ползваш моя магазин.

Аватар
hds-forever
Извън линия
Потребител
Потребител
Мнения: 52
Регистриран на: 05 Яну 2017, 21:51

Едит на /shop плъгин (смяна на оръжията)

Мнение от hds-forever » 04 Яну 2018, 02:15

Очаквах да споменеш за твоя шоп, но нямам нужда от толкова много предмети и опции. Ако може да ми оправиш това със спийда ще съм доволен. :)
[18+] Zombie BaseBuilder
IP: 93.123.18.49:27017

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Едит на /shop плъгин (смяна на оръжията)

Мнение от OciXCrom » 04 Яну 2018, 16:12

Всички предмети и опции може да се изключат по категорично лесен начин. Оправих speed-а, обаче при други проблеми не очаквай да си играя с този бъгав код. Ако искаш да експериментираш, ползвай го, в противен случай смени го с моя плъгин - има всичко, което има и този.

Код за потвърждение: Избери целия код

#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fakemeta >
#include < fun >
#include < engine >

// Some globals
new shop
new sw_cost
new health_cost
new armour_cost
new awp_cost
new speed_cost
new gravity_cost
new norecoil_cost
new chameleon_cost
new invisibility_cost
new gSpeedCvar
new gGravityCvar
new g_CZ
new p_iHealth
new p_iMaxHealth
new p_iAdd_Health
new gInvisPercent

// Item variables
new HasSW[ 33 ];
new HasHealth[ 33 ];
new HasArmour[ 33 ];
new HasAWP[ 33 ];
new HasSpeed[ 33 ];
new HasGravity[ 33 ];
new HasNoRecoil[ 33 ];
new HasChameleon[ 33 ];
new HasInvisibility[ 33 ];

// Those models are for the chameleon effect
new const t_models[][] =
{
	"arctic",
	"guerilla",
	"leet",
	"terror",
	"militia"
}

new const ct_models[][] =
{
	"gign",
	"gsg9",
	"sas",
	"urban",
	"spetsnaz"
}

public plugin_init()
{
	// Some events right here
	register_event( "DeathMsg", "event_death", "a")
	register_event( "DeathMsg", "Hook_Deathmessage", "a" );
	register_logevent( "logevent_round_start", 2, "1=Round_Start" );
	register_event( "CurWeapon", "OnWeaponChange", "be", "1=1" );
	
	register_plugin("Shop Menu", "1.0", "Obada");
	register_clcmd("say /shop", "ShowMenu", _, "Brings up shop menu");
	
	// Price of each item in the shop, except for the first one ofcourse
	shop = register_cvar ( "amx_shop", "1" ); // 1 = On , 2 = Off
	sw_cost = register_cvar ( "amx_silentwalk_price", "2500" );
	health_cost = register_cvar ( "amx_health_price", "4000" );
	armour_cost = register_cvar ( "amx_armour_price", "3500" );
	awp_cost = register_cvar ( "amx_awp_price", "5000" );
	speed_cost = register_cvar ( "amx_speed_price", "3500" );
	gravity_cost = register_cvar ( "amx_gravity_price", "3500" );
	norecoil_cost = register_cvar ( "amx_norecoil_price", "12000" );
	chameleon_cost = register_cvar ( "amx_chameleon_price", " 14000" );
	invisibility_cost = register_cvar ( "amx_invisibility_price", "16000" );
	
	// The power of some effects on players
	gSpeedCvar = register_cvar( "amx_speed_power", "400.0" );
	gGravityCvar = register_cvar( "amx_gravity_power", "0.7" );
	g_CZ        = is_running("czero")
	p_iHealth     = register_cvar("chameleon_health", "1")
	p_iMaxHealth    = register_cvar("cham_killer_max_health", "120")
	p_iAdd_Health     = register_cvar("cham_killer_health", "20")
	gInvisPercent    = register_cvar("invisibility_percent", "111")
}

// When client is connecting, let's reset stuff
public client_connect( id )
{
	HasSW[ id ] = false;
	HasHealth[ id ] = false;
	HasArmour[ id ] = false;
	HasAWP[ id ] = false;
	HasSpeed[ id] = false;
	HasGravity[ id ] = false;
	HasNoRecoil[ id ] = false;
	HasChameleon[ id ] = false;
	HasInvisibility[ id ] = false;
}

// When client has disconnected let's reset stuff
public client_disconnect( id )
{
	HasSW[ id ] = false;
	HasHealth[ id ] = false;
	HasArmour[ id ] = false;
	HasAWP[ id ] = false;
	HasSpeed[ id] = false;
	HasGravity[ id ] = false;
	HasNoRecoil[ id ] = false;
	HasChameleon[ id ] = false;
	HasInvisibility[ id ] = false;
}

public ShowMenu(id)
{
	// If cvar is set to 0, player can't open the shop
	if( get_pcvar_num( shop ) != 1 )
	{
		client_print( id, print_chat, "[Shop] Sorry, the shop is currently disabled" );
		return PLUGIN_HANDLED;
	}
	
	// If player is dead, he/she cant buy items
	if( !is_user_alive( id ) )
	{
		client_print( id, print_chat, "[Shop] You must be alive to buy from the shop" );
		return PLUGIN_HANDLED;
	}
	
	new menu = menu_create("Shop Menu", "Shop_Menu");
	
	menu_additem(menu, "Silent Walk - \y2500$", "", 0); // case 0
	menu_additem(menu, "200 hp - \y4000$", "", 0); // case 1
	menu_additem(menu, "200 armor - \y3500$", "", 0); // case 2
	menu_additem(menu, "AWP - \y5000$", "",  0); // case 3
	menu_additem(menu, "Speed - \y3500$", "",  0); // case 4
	menu_additem(menu, "Gravity - \y3500$", "", 0); // case 5
	menu_additem(menu, "No recoil - \y12000$", "",  0); // case 6
	menu_additem(menu, "Chameleon (change skin) - \y14000$", "", 0); // case 7
	menu_additem(menu, "Invisibility - \y16000$", "", 0); // case 8
	
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
	
	menu_display(id, menu, 0);
	
	return PLUGIN_HANDLED;
}

public Shop_Menu(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_cancel(id);
		return PLUGIN_HANDLED;
	}
	
	new command[6], name[64], access, callback;
	
	menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);
	
	switch(item)
	{
		case 0: // ---------- Silent Walk ----------
		{
			if( HasSW[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num( sw_cost ) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id)- get_pcvar_num(sw_cost))
			
			// Gives the player silent walk 
			set_user_footsteps( id, 1 );
				
			client_print(id, print_chat, "*** You have bought Silent Walk");
			HasSW[ id ] = true;
		}
		
		case 1: // ---------- Health Points ----------
		{
			if( HasHealth[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num( health_cost) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id) - health_cost) 

			// Gives the player 200 Health Points
			set_user_health( id, 200 )
				
			client_print(id, print_chat, "*** You have bought 200 HP");
			HasHealth[ id ] = true;
			
		}
		case 2: // ---------- Armour Points ----------
		{
			if( HasArmour[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num(armour_cost) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(armour_cost) ) 

			// Gives the player 200 Armour Points
			set_user_armor( id, 200 )
				
			client_print(id, print_chat, "*** You have bought 200 armor");
			HasArmour[ id ] = true;
		}
		
		case 3: // ---------- AWP ----------
		{
			if( HasAWP[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num( awp_cost) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(awp_cost) )

			// Give the player AWP
			give_item ( id, "weapon_awp" );
				
			client_print(id, print_chat, "*** You have bought AWP");
			HasAWP[ id ] = true;

		}
		
		case 4: // ---------- Speed ----------
		{
			if( HasSpeed[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num( speed_cost) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(speed_cost) )
			
			// Gives the player speed
			set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
				
			client_print(id, print_chat, "*** You have bought Speed");
			HasSpeed[ id ] = true;
		}
		
		case 5: // ---------- Gravity ----------
		{
			if( HasGravity[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num( gravity_cost) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(gravity_cost) )

			// Gives the player some lower gravity
			set_user_gravity( id, get_pcvar_float( gGravityCvar ) );
				
			client_print(id, print_chat, "*** You have bought Gravity");
			HasGravity[ id ] = true;
		}
		
		case 6: // ---------- No Recoil ----------
		{
			if( HasNoRecoil[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num( norecoil_cost) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(norecoil_cost) )

			// Gives the player no recoil
			if(get_user_button(id) & IN_ATTACK)
				entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0});

				
			client_print(id, print_chat, "*** You have bought No recoil");
			HasNoRecoil[ id ] = true;
		}
		
		case 7: // ---------- Chameleon --------------------
		{
			if( HasChameleon[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num( chameleon_cost) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(chameleon_cost) )

			//Gives the player some chameleon effect
			new name [32]
			get_user_name(id, name, 31)
				
			switch(cs_get_user_team(id))
			{
				case CS_TEAM_T:
				{
					cs_set_user_model(id, ct_models[random(g_CZ ? 5 : 4 )])
					client_print(id, print_chat, "*** You have bought the Chameleon effect");
					client_print(id, print_chat, "*** Make sure that cl_minmodels is set to 0, else it won't work.");
					HasChameleon[id] = true
				}
				case CS_TEAM_CT:
				{
					cs_set_user_model(id, t_models[random(g_CZ ? 5 : 4 )])
					client_print(id, print_chat, "*** You have bought the Chameleon effect");
					client_print(id, print_chat, "*** Make sure that cl_minmodels is set to 0, else it won't work.");
					HasChameleon[ id ] = true;
				}
			}
		}
		
		case 8: // ---------- Invisibility ----------
		{    
			if( HasInvisibility[ id ] )
			{
				client_print( id, print_chat, "[Shop] You already have this item." );
				return PLUGIN_HANDLED;
			}
			
			if( cs_get_user_money(id) < get_pcvar_num( invisibility_cost) )
			{
				client_print( id, print_chat, "[Shop] Sorry, but you don't have enough money." );
				return PLUGIN_HANDLED;
			}
			
			cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(invisibility_cost) )
			
			// Gives the player invisibility
			set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, get_pcvar_num( gInvisPercent ) );
			
			client_print(id, print_chat, "*** You have bought Invisibility");
			HasInvisibility[ id ] = true;
			
		}
		
	}
	
	menu_display(id, menu, 0);
	
	return PLUGIN_HANDLED;
}

public event_death()
{
	new iKiller = read_data(1)
	new iVictim = read_data(2)
	
	if(iKiller != iVictim && is_user_connected(iKiller) )
	{
		if(HasChameleon[iVictim])
		{
			if(get_pcvar_num(p_iHealth))
			{
				new szKillerName[32]
				get_user_name(iKiller, szKillerName, charsmax(szKillerName))
				client_print(0, print_chat, "*** %s Receives an additional health for killing chameleon!", szKillerName)
				
				set_user_health(iKiller, get_user_health(iKiller) + get_pcvar_num(p_iAdd_Health))
				
				if(get_user_health(iKiller) >= get_pcvar_num(p_iMaxHealth))
				{
					set_user_health(iKiller, get_pcvar_num(p_iMaxHealth))
				}
			}
			
		}
	}
}

// ------------------------------------- Stock(s) -------------------------------------

// Event for round start

public logevent_round_start()
{
	// If plugin is on
	if( get_pcvar_num( shop ) == 1 )
	{
		// I used this native because with get_maxplayers will recieve an error with invalid player id
		// This is good because we can skip bots
		new iPlayers[ 32 ], iNum, i, id;
		get_players( iPlayers, iNum, "c" );
		
		for( i = 0; i < iNum; i++ )
		{
			// Find the index
			id = iPlayers[ i ];
			
			// Reseting items
			HasSW[ id ] = false;
			HasHealth[ id ] = false;
			HasArmour[ id ] = false;
			HasAWP[ id ] = false;
			HasSpeed[ id] = false;
			HasGravity[ id ] = false;
			HasNoRecoil[ id ] = false;
			HasChameleon[ id ] = false;
			HasInvisibility[ id ] = false;
			
			set_user_footsteps( id, 0 );
			set_user_health( id, 100 );
			set_user_armor( id, 100 );
			set_user_maxspeed( id, 0.0 );
			set_user_gravity( id, 1.0 );    
			
			cs_reset_user_model(id)
			set_user_rendering( id );
			
			remove_task( id );
		}
	}
}

// Event when player died
public Hook_Deathmessage(id)
{
	// If plugin is on
	if( get_pcvar_num( shop ) == 1 )
	{
		// Get the killer and attacker
		new killer = read_data( 1 );
		new victim = read_data( 2 );

		// If player has died with world
		if( killer == victim )
		{
			return PLUGIN_HANDLED;
		}
		
	
		// Reseting items
		HasSW[ id ] = false;
		HasHealth[ id ] = false;
		HasArmour[ id ] = false;
		HasAWP[ id ] = false;
		HasSpeed[ id] = false;
		HasGravity[ id ] = false;
		HasNoRecoil[ id ] = false;
		HasChameleon[ id ] = false;
		HasInvisibility[ id ] = false;
			
		set_user_footsteps( id, 0 );
		set_user_health( id, 100 );
		set_user_armor( id, 100 );
		set_user_maxspeed( id, 0.0 );
		set_user_gravity( id, 1.0 );    
			
		cs_reset_user_model(id)
		set_user_rendering( id );
	}
	
	return PLUGIN_CONTINUE;
}

// By OciXCrom - you forgot something, Mr. Author
public OnWeaponChange(id)
{
	if( HasSpeed[ id ] )
		set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
}

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 15 госта