Русское сообщество по скриптингу

Request for "Time Shop"

Scripting help for english speaking users. While not very active, you still have a chance to get help here.
Правила форума
We cannot maintain english version version of our forum rules, but shortly (it's simple) - Don't be a dick. If you really want to know our rules you should check appropriate thread.

Request for "Time Shop"

Сообщение VenomIvanof » 15 июн 2016, 22:46

Hi all i need shop with every item to have some seconds to use like:

1. AWP - (for 60 sec) cost 6000$
2. SG550 - (for 60 sec) cost 7000$
2. Godmode - (for 20 sec) cost 12000$
3. Fast speed (330) - (for 60 sec) cost 5000$
4. Chameleon - (for 60 sec) cost 10000$
5. Full Invisible - (for 30 sec) cost 15000$
Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: Request for "Time Shop"

Сообщение Leonidddd » 16 июн 2016, 15:47

Okey, let's try. The steps for making your task:

1. Вы должны зарегистрироваться, чтобы видеть ссылки.

2. Вы должны зарегистрироваться, чтобы видеть ссылки.

3. Вы должны зарегистрироваться, чтобы видеть ссылки.
// Weapons:
weapon_usp
weapon_glock18
weapon_deagle
weapon_p228
weapon_elite
weapon_fiveseven
weapon_m3
weapon_xm1014
weapon_mp5navy
weapon_tmp
weapon_p90
weapon_mac10
weapon_ump45
weapon_famas
weapon_sg552
weapon_ak47
weapon_m4a1
weapon_aug
weapon_scout
weapon_awp
weapon_g3sg1
weapon_sg550
weapon_galil
weapon_m249

// Ammo:
ammo_45acp
ammo_9mm
ammo_50ae
ammo_357sig
ammo_57mm
ammo_buckshot
ammo_556nato
ammo_762nato
ammo_338magnum
ammo_308
ammo_556natobox

// Items:
item_kevlar
item_assaultsuit
weapon_flashbang
weapon_hegrenade
weapon_smokegrenade
item_thighpack
item_nvgs
weapon_shield


4. Вы должны зарегистрироваться, чтобы видеть ссылки.

5. For fast speed u need hook HAM event Ham_Item_PreFrame(or Ham_Player_ResetMaxSpeed from the latest versions of amxmodx) cause without this, it'll be reset an amount of speed:
Код: Выделить всё
RegisterHam(Ham_Item_PreFrame, "player", "PlayerResetMaxSpeed", 0);

Then Supercede it, if there aren't our amount:

Код: Выделить всё
public PlayerResetMaxSpeed(pPlayer)
{

        if (!is_user_connected(pPlayer))

                return HAM_IGNORED;

        if (get_user_maxspeed(pPlayer) != 400.0)

                return HAM_IGNORED;

       

        return HAM_SUPERCEDE
;


To assign the amount of the speed u need function called set_user_maxspeed

6. For chameleon u have to use fm_cs_set_user_model, but u have to add in your code the next:
in plugin_init():

Код: Выделить всё
register_forward( FM_SetClientKeyValue, "fw_SetClientKeyValue" 


Somewhere in the end of the code:
Код: Выделить всё
public fw_SetClientKeyValue( id, const infobuffer[], const key[] )

{

    if ( g_has_custom_model[id] && equal( key, "model" ) )

    {

        new currentmodel[32]

        fm_cs_get_user_model( id, currentmodel, charsmax( currentmodel ) )

       

        if 
( !equal( currentmodel, g_player_model[id] ) )

            fm_cs_set_user_model( id, g_player_model[id] )

       

        return FMRES_SUPERCEDE
;

    }

   

    return FMRES_IGNORED
;


Код: Выделить всё
stock fm_cs_set_user_model( player, const modelname[] )

{

    engfunc( EngFunc_SetClientKeyValue, player, engfunc( EngFunc_GetInfoKeyBuffer, player ), "model", modelname )

   

    copy
(g_player_model[id], charsmax(g_player_model[]), modelname);

    g_has_custom_model[player] = true


//Other functions for the work with model(get model name and resetting model )
Код: Выделить всё
stock fm_cs_get_user_model( player, model[], len )

{

    engfunc( EngFunc_InfoKeyValue, engfunc( EngFunc_GetInfoKeyBuffer, player ), "model", model, len )


Код: Выделить всё
stock fm_cs_reset_user_model( player )

{

    g_has_custom_model[player] = false

   

    dllfunc
( DLLFunc_ClientUserInfoChanged, player, engfunc( EngFunc_GetInfoKeyBuffer, player ) )



7.
Invisible:

Код: Выделить всё
set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,0)

Visible:
Код: Выделить всё
set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255)

That's all

P.S. Gl

Аватара пользователя
Leonidddd
Модератор
 
Сообщения: 2160
Зарегистрирован: 08 апр 2012, 18:13
Откуда: г. Запорожье
Благодарил (а): 176 раз.
Поблагодарили: 602 раз.
Языки программирования: Counter-Strike 1.6

Re: Request for "Time Shop"

Сообщение VenomIvanof » 13 июл 2016, 11:48

okey .. here what i try to do but ... i hope someone will help me. Thanks!

Код: Выделить всё
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>

#define PLUGIN "time shop"
#define VERSION "1.0"
#define AUTHOR "123123"

new const PlayerModels[ ] [ ] =
{
    
"arctic""leet""guerilla""terror""gign""urban""sas""gsg9"
}

const 
Float:g_flFastSpeed 330.0

#pragma semicolon 1

new g_iMenugmsgBlinkAcctg_iMaxPlayers;

enum _:playerTasks ( += 33 )
{
    
TASK_PLAYER_REMOVE_AWP,
    
TASK_PLAYER_REMOVE_SG550,
    
TASK_PLAYER_REMOVE_GODMODE,
    
TASK_PLAYER_REMOVE_CHAMELEON,
    
TASK_PLAYER_REMOVE_SPEED,
    
TASK_PLAYER_REMOVE_INVIS
}

enum Datas
{
    
m_szName[32],
    
m_iCost
}

new const 
g_mItems[][Datas] = 
{
    {
"\wAWP \d(\rSniper\d) \w - "4000},
    {
"\wSG550 \d(\rSniper\d) \w - "4000},
    {
"\wGodmode \r35 Seconds\w - "3500},
    {
"\wChameleon \r30 Seconds\w - "5000},
    {
"\wSpeed \r60 Seconds\w - "5000},
    {
"\wInvis\d100% \r60 Seconds\w - "6000}
};

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_clcmd("say /shop""TimeShop");
    
register_clcmd("say_team /shop""TimeShop");
    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0");
    
CreateMenu();
    
    
RegisterHamHam_Spawn"player""fwdPlayerSpawn");

    
gmsgBlinkAcct get_user_msgid("BlinkAcct");
}

public 
Event_HLTV_New_Round()
{
    for(new 
id 1id<=g_iMaxPlayersid++)
    {
        
remove_taskid TASK_PLAYER_REMOVE_GODMODE );
        
remove_taskid TASK_PLAYER_REMOVE_INVIS );
    
remove_taskid TASK_PLAYER_REMOVE_AWP );
    
remove_taskid TASK_PLAYER_REMOVE_SG550 );
    
remove_taskid TASK_PLAYER_REMOVE_SPEED );
    
remove_taskid TASK_PLAYER_REMOVE_CHAMELEON );
        
Task_Remove_GodModeid );
        
Task_Remove_Invisid );
    
Task_Remove_Awpid );
    
Task_Remove_SG550id );
    
Task_Remove_Speedid );
    
Task_Remove_Chameleonid );
    }
}

CreateMenu()
{
    
g_iMenu menu_create"\rShop Menu""DonateMenuHandler" );

    new 
szItem[64];
    for(new 
ii<sizeof(g_mItems); i++)
    {
        
formatex(szItemcharsmax(szItem), "%s\w%d$"g_mItems[i][m_szName], g_mItems[i][m_iCost]);
        
menu_additem(g_iMenuszItem);
    }
}

public 
TimeShop(id)
{
    if(
is_user_alive(id))
    {
        
menu_display(idg_iMenu);
    }
}

public 
DonateMenuHandler(idmenuitem )
{
    if(
item >=&& is_user_alive(id) )
    {
        new 
newMoney cs_get_user_money(id) - g_mItems[item][m_iCost];
        if( 
newMoney <= )
        {
            
ColorChat(idGREY"You dont have enoght MONEY!");
            
            
message_begin(MSG_ONEgmsgBlinkAcct_id);
            {
                
write_byte(2);
            }
            
message_end();
            return;
        }
        
cs_set_user_money(idnewMoney);

        switch(
item)
        {
            case 
0:
            {
            
give_item(id"weapon_awp");
        
cs_set_user_bpammo(idCSW_AWP50);
        
set_task(35.0"Task_Remove_Awp"id TASK_PLAYER_REMOVE_AWP);
                
ColorChat(idGREY"^4[^3Maina City^4] ^3You Have Bought ^4AWP");
            }
            case 
1:
            {
                
give_item(id"weapon_sg550");
        
cs_set_user_bpammo(idCSW_SG550100);
                
set_task(35.0"Task_Remove_SG550"id TASK_PLAYER_REMOVE_SG550);
                
ColorChat(idGREY"^4[^3Maina City^4] ^3You Have Bought SG550");
            }
       case 
2:
            {
                
set_user_godmode(id1);
        
set_task(35.0"Task_Remove_GodMode"id TASK_PLAYER_REMOVE_GODMODE);
                
ColorChat(idGREY"^4[^3Maina City^4] ^3You Have Bought Godmode for 35 Seconds");
            }
        case 
3:
            {
                
cs_set_user_modelidPlayerModelscs_get_user_teamid ) == CS_TEAM_CT random_num0) : random_num4,) ] );
        
set_task(35.0"Task_Remove_Chameleon"id TASK_PLAYER_REMOVE_CHAMELEON);
                
ColorChat(idGREY"^4[^3Maina City^4] ^3You Have Bought Chameleon);
            }
        case 4:
            {
                set_user_maxspeed(id, g_flFastSpeed)
        set_task(35.0, "
Task_Remove_Speed", id + TASK_PLAYER_REMOVE_SPEED);
                ColorChat(id, GREY, "
^4[^3Maina City^4] ^3You Have Bought Speed");
            }
            case 5:
            {
                set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha);
                set_task(60.0, "
Task_Remove_Invis", id + TASK_PLAYER_REMOVE_INVIS);
                ColorChat(id, GREY, "
^4[^3Maina City^4] ^3You Have Bought Invisibilty for 60 Seconds");
            }
        }
    }
}


public fw_SetClientKeyValue( id, const infobuffer[], const key[] )

{

    if ( g_has_custom_model[id] && equal( key, "
model" ) )

    {

        new currentmodel[32]

        fm_cs_get_user_model( id, currentmodel, charsmax( currentmodel ) )

       

        if ( !equal( currentmodel, g_player_model[id] ) )

            fm_cs_set_user_model( id, g_player_model[id] )

       

        return FMRES_SUPERCEDE;

    }

   

    return FMRES_IGNORED;



public Task_Remove_GodMode( id )
{
    id %= 33;
    if( is_user_connected(id) )
    {
        set_user_godmode(id, 0);
        ColorChat(id, GREY, "
^4[^3Maina City^4] ^3Your God Mode has expired");
    }
}

public Task_Remove_Invis( id )
{
    id %= 33;
    if( is_user_connected(id) )
    {
        set_user_godmode(id, 0);
        ColorChat(id, GREY, "
^4[^3Maina City^4] ^3Your Invisible has expired");
    }
}

public Task_Remove_Awp( id )
{
    id %= 33;
    if( is_user_connected(id) )
    {
        give_item(id, "
weapon_knife");
    give_item(id, "
weapon_ak47");
    cs_set_user_bpammo( id, CSW_AK47, 80);
    give_item(id, "
weapon_deagle");
    cs_set_user_bpammo( id, CSW_DEAGLE, 80);
        ColorChat(id, GREY, "
^4[^3Maina City^4] ^3Your Awp has expired");
    }
}

public Task_Remove_SG550( id )
{
    id %= 33;
    if( is_user_connected(id) )
    {
        give_item(id, "
weapon_knife");
    give_item(id, "
weapon_ak47");
    cs_set_user_bpammo( id, CSW_AK47, 80);
    give_item(id, "
weapon_deagle");
    cs_set_user_bpammo( id, CSW_DEAGLE, 80);
        ColorChat(id, GREY, "
^4[^3Maina City^4] ^3Your SG550 has expired");
    }
}

public Task_Remove_Chameleon( id )
{
    id %= 33;
    if( is_user_connected(id) )
    {
        fm_cs_set_user_model( id, g_player_model[id] )
        ColorChat(id, GREY, "
^4[^3Maina City^4] ^3Your Chameleon has expired");
    }
}

public Task_Remove_Speed( id )
{
    id %= 33;
    if( is_user_connected(id) )
    {
        for the speed i dont know how to turn it off
        ColorChat(id, GREY, "
^4[^3Maina City^4] ^3Your Speed has expired");
    }
}
 

stock fm_cs_reset_user_model( player )

{

    g_has_custom_model[player] = false

   

    dllfunc( DLLFunc_ClientUserInfoChanged, player, engfunc( EngFunc_GetInfoKeyBuffer, player ) )


Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: Request for "Time Shop"

Сообщение Leonidddd » 13 июл 2016, 16:34

First of all, u have to read about tabulation of the code.

Read about #pragma semicolon 1

Get acquainted with fakemeta module

And I still can't undestand, what the role of this code?
Код: Выделить всё
id %= 33


Compilated plugin without errors while compiling:

Код: Выделить всё
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>

#define PLUGIN "time shop"
#define VERSION "1.0"
#define AUTHOR "123123"

new const PlayerModels[ ] [ ] =
{
    "arctic", "leet", "guerilla", "terror", "gign", "urban", "sas", "gsg9"
}

const Float:g_flFastSpeed = 330.0

#pragma semicolon 1

new g_iMenu, gmsgBlinkAcct, g_iMaxPlayers;

new bool:g_has_custom_model[33];
new g_player_model[33][32];

enum _:playerTasks ( += 33 )
{
    TASK_PLAYER_REMOVE_AWP,
    TASK_PLAYER_REMOVE_SG550,
    TASK_PLAYER_REMOVE_GODMODE,
    TASK_PLAYER_REMOVE_CHAMELEON,
    TASK_PLAYER_REMOVE_SPEED,
    TASK_PLAYER_REMOVE_INVIS
}

enum Datas
{
    m_szName[32],
    m_iCost
}

new const g_mItems[][Datas] = 
{
    {"\wAWP \d(\rSniper\d) \w - ", 4000},
    {"\wSG550 \d(\rSniper\d) \w - ", 4000},
    {"\wGodmode \r35 Seconds\w - ", 3500},
    {"\wChameleon \r30 Seconds\w - ", 5000},
    {"\wSpeed \r60 Seconds\w - ", 5000},
    {"\wInvis\d100% \r60 Seconds\w - ", 6000}
};

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    register_clcmd("say /shop", "TimeShop");
    register_clcmd("say_team /shop", "TimeShop");
    register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0");
    CreateMenu();
    
    RegisterHam
( Ham_Spawn, "player", "fwdPlayerSpawn", 1 );
    
    register_forward
( FM_SetClientKeyValue, "fw_SetClientKeyValue" );
    
    gmsgBlinkAcct 
= get_user_msgid("BlinkAcct");
}

public Event_HLTV_New_Round()
{
    for(new id = 1; id<=g_iMaxPlayers; id++)
    {
        remove_task( id + TASK_PLAYER_REMOVE_GODMODE );
        remove_task( id + TASK_PLAYER_REMOVE_INVIS );
        remove_task( id + TASK_PLAYER_REMOVE_AWP );
        remove_task( id + TASK_PLAYER_REMOVE_SG550 );
        remove_task( id + TASK_PLAYER_REMOVE_SPEED );
        remove_task( id + TASK_PLAYER_REMOVE_CHAMELEON );
        Task_Remove_GodMode( id );
        Task_Remove_Invis( id );
        Task_Remove_Awp( id );
        Task_Remove_SG550( id );
        Task_Remove_Speed( id );
        Task_Remove_Chameleon( id );
    }
}

CreateMenu()
{
    g_iMenu = menu_create( "\rShop Menu", "DonateMenuHandler" );

    new szItem[64];
    for(new i; i<sizeof(g_mItems); i++)
    {
        formatex(szItem, charsmax(szItem), "%s\w%d$", g_mItems[i][m_szName], g_mItems[i][m_iCost]);
        menu_additem(g_iMenu, szItem);
    }
}

public TimeShop(id)
{
    if(is_user_alive(id))
    {
        menu_display(id, g_iMenu);
    }
}

public DonateMenuHandler(id, menu, item )
{
    if(item >=&& is_user_alive(id) )
    {
        new newMoney = cs_get_user_money(id) - g_mItems[item][m_iCost];
        if( newMoney <= 0 )
        {
            ColorChat(id, GREY, "You dont have enoght MONEY!");
            
            message_begin
(MSG_ONE, gmsgBlinkAcct, _, id);
            write_byte(2);
            message_end();
            return;
        }
        cs_set_user_money(id, newMoney);

        switch(item)
        {
            case 0:
            {
                give_item(id, "weapon_awp");
                cs_set_user_bpammo(id, CSW_AWP, 50);
                set_task(35.0, "Task_Remove_Awp", id + TASK_PLAYER_REMOVE_AWP);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought ^4AWP");
            }
            case 1:
            {
                give_item(id, "weapon_sg550");
                cs_set_user_bpammo(id, CSW_SG550, 100);
                set_task(35.0, "Task_Remove_SG550", id + TASK_PLAYER_REMOVE_SG550);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought SG550");
            }
            case 2:
            {
                set_user_godmode(id, 1);
                set_task(35.0, "Task_Remove_GodMode", id + TASK_PLAYER_REMOVE_GODMODE);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought Godmode for 35 Seconds");
            }
            case 3:
            {
                cs_set_user_model( id, PlayerModels[ cs_get_user_team( id ) == CS_TEAM_CT ? random_num( 0, 3 ) : random_num( 4,) ] );
                set_task(35.0, "Task_Remove_Chameleon", id + TASK_PLAYER_REMOVE_CHAMELEON);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought Chameleon");
            }
            case 4:
            {
                set_user_maxspeed(id, g_flFastSpeed);
                set_task(35.0, "Task_Remove_Speed", id + TASK_PLAYER_REMOVE_SPEED);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought Speed");
            }
            case 5:
            {
                set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha);
                set_task(60.0, "Task_Remove_Invis", id + TASK_PLAYER_REMOVE_INVIS);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought Invisibilty for 60 Seconds");
            }
        }
    }
}


public fw_SetClientKeyValue( id, const infobuffer[], const key[] )
{

    if( g_has_custom_model[id] && equal( key, "model" ) )
    {
        new currentmodel[32];

        fm_cs_get_user_model( id, currentmodel, charsmax( currentmodel ) );

        if(!equal( currentmodel, g_player_model[id] ) )
            fm_cs_set_user_model( id, g_player_model[id] );

        return FMRES_SUPERCEDE;

    }
    return FMRES_IGNORED;
}
 

public Task_Remove_GodMode
( id )
{
    id = id - TASK_PLAYER_REMOVE_GODMODE;
    if( is_user_connected(id) )
    {
        set_user_godmode(id, 0);
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your God Mode has expired");
    }
}

public Task_Remove_Invis( id )
{
    id = id - TASK_PLAYER_REMOVE_INVIS;
    if( is_user_connected(id) )
    {
        set_user_godmode(id, 0);
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your Invisible has expired");
    }
}

public Task_Remove_Awp( id )
{
    id = id - TASK_PLAYER_REMOVE_AWP;
    if( is_user_connected(id) )
    {
        give_item(id, "weapon_knife");
        give_item(id, "weapon_ak47");
        cs_set_user_bpammo( id, CSW_AK47, 80);
        give_item(id, "weapon_deagle");
        cs_set_user_bpammo( id, CSW_DEAGLE, 80);
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your Awp has expired");
    }
}

public Task_Remove_SG550( id )
{
    id = id - TASK_PLAYER_REMOVE_SG550;
    if( is_user_connected(id) )
    {
        give_item(id, "weapon_knife");
        give_item(id, "weapon_ak47");
        cs_set_user_bpammo( id, CSW_AK47, 80);
        give_item(id, "weapon_deagle");
        cs_set_user_bpammo( id, CSW_DEAGLE, 80);
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your SG550 has expired");
    }
}

public Task_Remove_Chameleon( id )
{
    id = id - TASK_PLAYER_REMOVE_CHAMELEON;
    if( is_user_connected(id) )
    {
        fm_cs_set_user_model( id, g_player_model[id] );
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your Chameleon has expired");
    }
}

public Task_Remove_Speed( id )
{
    id = id - TASK_PLAYER_REMOVE_SPEED;
    if( is_user_connected(id) )
    {
    
        ColorChat
(id, GREY, "^4[^3Maina City^4] ^3Your Speed has expired");
    }
}


stock fm_cs_set_user_model( player, const modelname[] )
{
    engfunc( EngFunc_SetClientKeyValue, player, engfunc( EngFunc_GetInfoKeyBuffer, player ), "model", modelname );
    copy(g_player_model[player], charsmax(g_player_model[]), modelname);
    g_has_custom_model[player] = true;
}

stock fm_cs_reset_user_model( player )
{
    g_has_custom_model[player] = false
    dllfunc
( DLLFunc_ClientUserInfoChanged, player, engfunc( EngFunc_GetInfoKeyBuffer, player ) )

}
 

stock fm_cs_get_user_model
( player, model[], len )
{
    engfunc( EngFunc_InfoKeyValue, engfunc( EngFunc_GetInfoKeyBuffer, player ), "model", model, len );
}
 
Аватара пользователя
Leonidddd
Модератор
 
Сообщения: 2160
Зарегистрирован: 08 апр 2012, 18:13
Откуда: г. Запорожье
Благодарил (а): 176 раз.
Поблагодарили: 602 раз.
Языки программирования: Counter-Strike 1.6

Re: Request for "Time Shop"

Сообщение VenomIvanof » 13 июл 2016, 16:52

Leonidddd писал(а):First of all, u have to read about tabulation of the code.

Read about #pragma semicolon 1

Get acquainted with fakemeta module

And I still can't undestand, what the role of this code?
Код: Выделить всё
id %= 33;


Compilated plugin without errors while compiling:

Код: Выделить всё
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>

#define PLUGIN "time shop"
#define VERSION "1.0"
#define AUTHOR "123123"

new const PlayerModels[ ] [ ] =
{
    "arctic", "leet", "guerilla", "terror", "gign", "urban", "sas", "gsg9"
}

const Float:g_flFastSpeed = 330.0

#pragma semicolon 1

new g_iMenu, gmsgBlinkAcct, g_iMaxPlayers;

new bool:g_has_custom_model[33];
new g_player_model[33][32];

enum _:playerTasks ( += 33 )
{
    TASK_PLAYER_REMOVE_AWP,
    TASK_PLAYER_REMOVE_SG550,
    TASK_PLAYER_REMOVE_GODMODE,
    TASK_PLAYER_REMOVE_CHAMELEON,
    TASK_PLAYER_REMOVE_SPEED,
    TASK_PLAYER_REMOVE_INVIS
}

enum Datas
{
    m_szName[32],
    m_iCost
}

new const g_mItems[][Datas] = 
{
    {"\wAWP \d(\rSniper\d) \w - ", 4000},
    {"\wSG550 \d(\rSniper\d) \w - ", 4000},
    {"\wGodmode \r35 Seconds\w - ", 3500},
    {"\wChameleon \r30 Seconds\w - ", 5000},
    {"\wSpeed \r60 Seconds\w - ", 5000},
    {"\wInvis\d100% \r60 Seconds\w - ", 6000}
};

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    register_clcmd("say /shop", "TimeShop");
    register_clcmd("say_team /shop", "TimeShop");
    register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0");
    CreateMenu();
    
    RegisterHam
( Ham_Spawn, "player", "fwdPlayerSpawn", 1 );
    
    register_forward
( FM_SetClientKeyValue, "fw_SetClientKeyValue" );
    
    gmsgBlinkAcct 
= get_user_msgid("BlinkAcct");
}

public Event_HLTV_New_Round()
{
    for(new id = 1; id<=g_iMaxPlayers; id++)
    {
        remove_task( id + TASK_PLAYER_REMOVE_GODMODE );
        remove_task( id + TASK_PLAYER_REMOVE_INVIS );
        remove_task( id + TASK_PLAYER_REMOVE_AWP );
        remove_task( id + TASK_PLAYER_REMOVE_SG550 );
        remove_task( id + TASK_PLAYER_REMOVE_SPEED );
        remove_task( id + TASK_PLAYER_REMOVE_CHAMELEON );
        Task_Remove_GodMode( id );
        Task_Remove_Invis( id );
        Task_Remove_Awp( id );
        Task_Remove_SG550( id );
        Task_Remove_Speed( id );
        Task_Remove_Chameleon( id );
    }
}

CreateMenu()
{
    g_iMenu = menu_create( "\rShop Menu", "DonateMenuHandler" );

    new szItem[64];
    for(new i; i<sizeof(g_mItems); i++)
    {
        formatex(szItem, charsmax(szItem), "%s\w%d$", g_mItems[i][m_szName], g_mItems[i][m_iCost]);
        menu_additem(g_iMenu, szItem);
    }
}

public TimeShop(id)
{
    if(is_user_alive(id))
    {
        menu_display(id, g_iMenu);
    }
}

public DonateMenuHandler(id, menu, item )
{
    if(item >=&& is_user_alive(id) )
    {
        new newMoney = cs_get_user_money(id) - g_mItems[item][m_iCost];
        if( newMoney <= 0 )
        {
            ColorChat(id, GREY, "You dont have enoght MONEY!");
            
            message_begin
(MSG_ONE, gmsgBlinkAcct, _, id);
            write_byte(2);
            message_end();
            return;
        }
        cs_set_user_money(id, newMoney);

        switch(item)
        {
            case 0:
            {
                give_item(id, "weapon_awp");
                cs_set_user_bpammo(id, CSW_AWP, 50);
                set_task(35.0, "Task_Remove_Awp", id + TASK_PLAYER_REMOVE_AWP);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought ^4AWP");
            }
            case 1:
            {
                give_item(id, "weapon_sg550");
                cs_set_user_bpammo(id, CSW_SG550, 100);
                set_task(35.0, "Task_Remove_SG550", id + TASK_PLAYER_REMOVE_SG550);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought SG550");
            }
            case 2:
            {
                set_user_godmode(id, 1);
                set_task(35.0, "Task_Remove_GodMode", id + TASK_PLAYER_REMOVE_GODMODE);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought Godmode for 35 Seconds");
            }
            case 3:
            {
                cs_set_user_model( id, PlayerModels[ cs_get_user_team( id ) == CS_TEAM_CT ? random_num( 0, 3 ) : random_num( 4,) ] );
                set_task(35.0, "Task_Remove_Chameleon", id + TASK_PLAYER_REMOVE_CHAMELEON);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought Chameleon");
            }
            case 4:
            {
                set_user_maxspeed(id, g_flFastSpeed);
                set_task(35.0, "Task_Remove_Speed", id + TASK_PLAYER_REMOVE_SPEED);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought Speed");
            }
            case 5:
            {
                set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha);
                set_task(60.0, "Task_Remove_Invis", id + TASK_PLAYER_REMOVE_INVIS);
                ColorChat(id, GREY, "^4[^3Maina City^4] ^3You Have Bought Invisibilty for 60 Seconds");
            }
        }
    }
}


public fw_SetClientKeyValue( id, const infobuffer[], const key[] )
{

    if( g_has_custom_model[id] && equal( key, "model" ) )
    {
        new currentmodel[32];

        fm_cs_get_user_model( id, currentmodel, charsmax( currentmodel ) );

        if(!equal( currentmodel, g_player_model[id] ) )
            fm_cs_set_user_model( id, g_player_model[id] );

        return FMRES_SUPERCEDE;

    }
    return FMRES_IGNORED;
}
 

public Task_Remove_GodMode
( id )
{
    id = id - TASK_PLAYER_REMOVE_GODMODE;
    if( is_user_connected(id) )
    {
        set_user_godmode(id, 0);
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your God Mode has expired");
    }
}

public Task_Remove_Invis( id )
{
    id = id - TASK_PLAYER_REMOVE_INVIS;
    if( is_user_connected(id) )
    {
        set_user_godmode(id, 0);
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your Invisible has expired");
    }
}

public Task_Remove_Awp( id )
{
    id = id - TASK_PLAYER_REMOVE_AWP;
    if( is_user_connected(id) )
    {
        give_item(id, "weapon_knife");
        give_item(id, "weapon_ak47");
        cs_set_user_bpammo( id, CSW_AK47, 80);
        give_item(id, "weapon_deagle");
        cs_set_user_bpammo( id, CSW_DEAGLE, 80);
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your Awp has expired");
    }
}

public Task_Remove_SG550( id )
{
    id = id - TASK_PLAYER_REMOVE_SG550;
    if( is_user_connected(id) )
    {
        give_item(id, "weapon_knife");
        give_item(id, "weapon_ak47");
        cs_set_user_bpammo( id, CSW_AK47, 80);
        give_item(id, "weapon_deagle");
        cs_set_user_bpammo( id, CSW_DEAGLE, 80);
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your SG550 has expired");
    }
}

public Task_Remove_Chameleon( id )
{
    id = id - TASK_PLAYER_REMOVE_CHAMELEON;
    if( is_user_connected(id) )
    {
        fm_cs_set_user_model( id, g_player_model[id] );
        ColorChat(id, GREY, "^4[^3Maina City^4] ^3Your Chameleon has expired");
    }
}

public Task_Remove_Speed( id )
{
    id = id - TASK_PLAYER_REMOVE_SPEED;
    if( is_user_connected(id) )
    {
    
        ColorChat
(id, GREY, "^4[^3Maina City^4] ^3Your Speed has expired");
    }
}


stock fm_cs_set_user_model( player, const modelname[] )
{
    engfunc( EngFunc_SetClientKeyValue, player, engfunc( EngFunc_GetInfoKeyBuffer, player ), "model", modelname );
    copy(g_player_model[player], charsmax(g_player_model[]), modelname);
    g_has_custom_model[player] = true;
}

stock fm_cs_reset_user_model( player )
{
    g_has_custom_model[player] = false
    dllfunc
( DLLFunc_ClientUserInfoChanged, player, engfunc( EngFunc_GetInfoKeyBuffer, player ) )

}
 

stock fm_cs_get_user_model
( player, model[], len )
{
    engfunc( EngFunc_InfoKeyValue, engfunc( EngFunc_GetInfoKeyBuffer, player ), "model", model, len );
}



i don't know really what is this too "id %= 33; " i see it from another plugin .. however thanks for everything ... you are awesome dude!
Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6


Вернуться в Scripting

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3