Raised This Month: $ Target: $400
 0% 

Life menu giving lifes when killing opposite team


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
dan1t0o0
New Member
Join Date: Jul 2012
Old 07-06-2012 , 10:03   Re: Life menu giving lifes when killing opposite team
Reply With Quote #3

here is the code

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < nvault >

#define PLUGIN_NAME        "Life_Menu"
#define PLUGIN_VERSION    "0.1"
#define PLUGIN_AUTHOR    "Bos93"

#define MAXPLAYERS                 32
#define MAX_STATS_SAVED            64

#if cellbits ==                         32 
    #define OFFSET_CSMONEY         115 
#else 
    #define OFFSET_CSMONEY         140 
#endif 

#define OFFSET_LINUX                 5

#define LIFE_COST                    4000
#define LIFE_SELL                    2000
#define LIFE_LIMIT                    50

new g_LifeMAXPLAYERS ]
new 
gNameMAXPLAYERS ]
new 
vKeyMAX_STATS_SAVED ]
new 
vDataMAX_STATS_SAVED ]

new 
gVault

public plugin_init ( )
{
    
register_plugin PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR )
    
    
register_event"DeathMsg""EV_DeathMsg""a" )

    
register_clcmd("say /life""Life_Shop")
    
register_clcmd("say life""Life_Shop")
    
register_clcmd("say /lmenu""Life_Shop")
    
register_clcmd("say lmenu""Life_Shop")
}

public 
client_connectid )
    
load_client_Lifeid )
    
public 
client_disconnectid )
    
save_client_Lifeid )
    
public 
EV_DeathMsg( )
{
    static 
iVictim;
    
iVictim read_data);
    
    if( !
is_user_connectediVictim ) )
        return;
        
    
Life_ShopiVictim )
}

public 
Life_Shopid 
{
        new 
szText1024 char ];
        
        
formatexszTextcharsmaxszText ), "\yYour Money\w: \r%d\y $^nYour lives\w: \r%d" ,fm_cs_get_user_money(id) , g_Life[id] );
    
        new 
menu menu_createszText"Life_handler" );
            
               
        
formatexszTextcharsmaxszText ), "Use live \y- \r1\w Life" );
        
menu_additemmenuszText"3");

        
menu_setprop(menuMPROP_EXITNAME"Exit")
    
        
menu_display(idmenu0)
 }
    
public 
Life_handler (id menu item ) {
    
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}

    new 
s_Data[6], s_Name[64], i_Accessi_Callback
    
    menu_item_getinfo
(menuitemi_Accesss_Datacharsmax(s_Data), s_Namecharsmax(s_Name), i_Callback)

    new 
i_Key str_to_num(s_Data)

    new 
szName32 ]
    
get_user_nameidszName31 )

    new 
money fm_cs_get_user_money(id)
    
    switch(
i_Key)
    {
            case 
1:
            {
                if (
money LIFE_COST)
                {
                    
Color_Print(id,  "!g[DeathRun] !team%s !ydont have !gmoney." ,  szName )
                    return 
PLUGIN_HANDLED
                
}
                
                if ( 
g_Life[id] >= LIFE_LIMIT )
                {
                    
Color_Print(id,  "!g[DeathRun] !team%s !yyou reached a !glimit." ,  szName )
                    return 
PLUGIN_HANDLED
                
}
                
                
Color_Print(id,  "!g[DeathRun] !team%s !yhas buy a !glive." ,  szName )
                
                
g_Life[id] += 1
            
                fm_cs_set_user_money
(idmoney LIFE_COST)
                
Life_Shopid 
            }
            case 
2:
            {
                if ( 
g_Life[id] == )
                {
                    
Color_Print(id,  "!g[DeathRun] !team%s !yyou dont have !glives." ,  szName )
                    return 
PLUGIN_HANDLED
                
}
                
                
Color_Print(id,  "!g[DeathRun] !team%s !yhas sell !glive." ,  szName )
                
                
g_Life[id] -= 1
                    
                fm_cs_set_user_money
(idmoney LIFE_SELL)
                
Life_Shopid 
            }
            case 
3:
            {
                if ( 
is_user_aliveid ) )
                {
                    
Color_Print(id,  "!g[DeathRun] !team%s !y you need to be !gdead." ,  szName )
                    return 
PLUGIN_HANDLED
                
}
    
                if ( 
g_Life[id] == )
                {
                    
Color_Print(id,  "!g[DeathRun] !team%s !yyou dont have !glives." ,  szName )
                    return 
PLUGIN_HANDLED
                
}
                
                
g_Life[id] -= 1

                Color_Print
(id,  "!g[DeathRun] !team%s !yyou has used a !glive." ,  szName )
                
                
ExecuteHam(Ham_CS_RoundRespawnid)
            }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}
stock save_client_Lifeindex )
{
    
gVault nvault_open"Life_Save" )
    
    if( 
gVault == INVALID_HANDLE )
    {
        
set_fail_state"[Life_Shop] nValut ERROR: =-> Invalid-Handle" )
    }
    
    
get_user_nameindexgNamecharsmaxgName ) )

    
formatexvKeycharsmaxvKey ), "%sLife"gName )
    
formatexvDatacharsmaxvData ), "%d"g_Lifeindex ] )
    
nvault_setgVaultvKeyvData )
    
nvault_closegVault )
}

stock load_client_Lifeindex )
{
    
gVault nvault_open"Life_Save" )
    
    if( 
gVault == INVALID_HANDLE )
    {
        
set_fail_state"[DrShop] nValut ERROR: =-> Invalid-Handle" )
    }
    
    
get_user_nameindexgNamecharsmaxgName ) )
    
    
formatexvKeycharsmaxvKey ), "%sLife"gName )
    
g_Lifeindex ] = nvault_getgVaultvKey )
    
nvault_closegVault )
}

stock fm_cs_set_user_money(idmoneyflash 1

        
set_pdata_int(idOFFSET_CSMONEYmoneyOFFSET_LINUX)

        
message_begin(MSG_ONEget_user_msgid("Money"), {0,0,0}, id)
        
write_long(money)
        
write_byte(flash)
        
message_end()
}

stock fm_cs_get_user_money(id
        return 
get_pdata_int(idOFFSET_CSMONEYOFFSET_LINUX)

stock Color_Print(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch")
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }


Last edited by YamiKaitou; 07-06-2012 at 10:05.
dan1t0o0 is offline
 



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 15:21.


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