Raised This Month: $ Target: $400
 0% 

Good idea? :p


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nkz1337
BANNED
Join Date: Apr 2011
Old 11-26-2011 , 12:09   Good idea? :p
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <nvault>
#include <colorchat>

#define PLUGIN "Experience System" // cs_set_weapon_ammo( give_item(id, "weapon_scout"), 0);
#define VERSION "1.2b"
#define AUTHOR "tvix1337"

new g_szPlayersMaxg_szMenu;
new 
g_szXP[32];
new 
g_szKillg_szDeathg_szSuicideg_szNade// g_szWin, g_szLost;
new c_szHEc_szFrostc_szFlashc_szDeaglec_szAwpc_szHSeekc_szFsc_szUsp;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_szKill    register_cvar"xp_kill",     "5" );
    
g_szDeath   register_cvar"xp_death",    "3" )
    
g_szSuicide register_cvar"xp_suicide",  "5" )
    
g_szNade    register_cvar"xp_nade",     "7" )
//    g_szWin     = register_cvar( "xp_win",      "5" )
//    g_szLost    = register_cvar( "xp_lost",     "3" )
    
    
c_szAwp     register_cvar"xp_awp_cost""120" )
    
c_szDeagle  register_cvar"xp_dgl_cost""100" )
    
c_szFlash   register_cvar"xp_fb_cost""20" )
    
c_szHE      register_cvar"xp_he_cost""30" )
    
c_szFrost   register_cvar"xp_fn_cost""25" )
    
c_szHSeek   register_cvar"xp_hs_cost""40" )
    
c_szFs      register_cvar"xp_fs_cost""70" )
    
c_szUsp     register_cvar"xp_usp_cost""95" )
    
    
register_clcmd"say /xp",   "xp_menu" )
    
register_clcmd"say .xp",   "xp_menu" )
    
register_clcmd"say /exp",  "xp_menu" )
    
register_clcmd"say .exp",  "xp_menu" )
    
    
register_event("DeathMsg""EventDeathMsg""a");
    
    
g_szMenu register_menuid("XP Menu");
    
register_menucmd(g_szMenu1023"xpmenu")
    
    
g_szPlayersMax get_maxplayers();
}

public 
plugin_natives()
{
    
register_library("hns_xp");
    
register_native("hnsxp_get_user_xp""_get_xp");
    
register_native("hnsxp_set_user_xp""_set_xp");
}

public 
_get_xp(pluginparams)
{
    return 
g_szXP[get_param(1)];
}

public 
_set_xp(pluginparams)
{
    new 
client get_param(1);
    
g_szXP[client] = max(0get_param(2));
    
SaveXP(client);
    return 
g_szXP[client];
}

public 
SaveXP(id

    new 
valut nvault_open("exp"
     
    if(
valut == INVALID_HANDLE
        
set_fail_state("nValut returned invalid handle"
     
    new 
key[62], value[10], ip[33
     
    
//get_user_ip(id, ip, 32, 1); 
    
get_user_authid(idip32); 
     
    
format(key61,"%s-exp"ip
    
format(value9,"%d"g_szXP[id] ) 
     
    
nvault_set(valutkeyvalue
    
nvault_close(valut)     
     
    return 
PLUGIN_CONTINUE

public 
LoadXP(id

    new 
valut nvault_open("exp"
     
    if(
valut == INVALID_HANDLE
        
set_fail_state("nValut returned invalid handle"
     
    new 
key[100], ip[33
     
    
//get_user_ip(id, ip, 32, 1); 
    
get_user_authid(idip32); 
     
    
formatex(key99,"%s-exp"ip
     
    
g_szXP[id] = nvault_get(valutkey)     
    
nvault_close(valut
     
    return 
PLUGIN_CONTINUE


public 
client_putinserver(id) {
    
LoadXP(id);
}

public 
client_disconnect(id) {
    
SaveXP(id);
}

public 
EventDeathMsg() {
    
    new 
rKill get_pcvar_num(g_szKill)
    new 
rDeath get_pcvar_num(g_szDeath)
    new 
rSuicide get_pcvar_num(g_szSuicide)
    new 
rNade get_pcvar_num(g_szNade)
    
    new 
killer read_data(1)
    new 
victim read_data(2)
//    new rWin = get_pcvar_num(g_szWin)
//    new rLost = get_pcvar_num(g_szLost)
    
    
g_szXP[killer] += rKill 
    g_szXP
[victim] -= rDeath
    
    ColorChat
(killerNORMAL"^x04*^x01 XP: You got^x04 %d^x01 XP! [^x04 Kill^x01 ]"rKill )
    
ColorChat(victimNORMAL"^x04*^x01 XP: You lost^x04 %d^x01 XP! [^x04 Death^x01 ]"rDeath )
    
    if((
killer == victim) || (!killer))
    {
        
g_szXP[victim] -= rSuicide
        ColorChat
(victimNORMAL"^x04*^x01 XP: You lost^x04 %d^x01 XP! [^x04 Suicide^x01 ]"rSuicide )
    }
    static 
weapon[20];
    
read_data(4weaponsizeof(weapon) - 1);
                
    if( 
contain(weapon"grenade") >= )
    {
        
g_szXP[killer] += rNade
        ColorChat
(killerNORMAL"^x04*^x01 XP: You got^x04 %d^x01 XP! [^x04 HE-Kill^x01 ]"rNade )
    }
}
public 
xp_menuid ) {
    new 
szBuffer[512], iLen;

    
iLen formatex(szBuffersizeof szBuffer 1"\yXP System by tvix1337^n\yYou'r XP:\r %d"g_szXP[id] ) 
    
iLen += formatex(szBuffer[iLen], (sizeof szBuffer 1) - iLen"\r1. \wHE-Grenade -\y %d XP!"get_pcvar_num(c_szHE) )
    
iLen += formatex(szBuffer[iLen], (sizeof szBuffer 1) - iLen"\r2. \wFlashBang -\y %d XP!"get_pcvar_num(c_szFlash) )
        
iLen += formatex(szBuffer[iLen], (sizeof szBuffer 1) - iLen"\r3. \wFrostNade -\y %d XP!"get_pcvar_num(c_szFrostnade) )
        
    
iLen += formatex(szBuffer[iLen], (sizeof szBuffer 1) - iLen"\r0. \yClose Menu"); 

    new 
iKeys = ( 1<<1<<1<<1<<1<<);
    
show_menu(idiKeysszBuffer, -1"XP Menu");
}

// Shop actions
public hnsshopidkey ) {
    switch( 
key ) {
        case 
0:
        {
            if(
g_szXP[id] >= get_pcvar_num(c_szHE)) {
                
g_szXP[id] -= get_pcvar_num(c_szHE)
                
give_item(id"weapon_hegrenade" 
                
ColorChat(idNORMAL"^x04*^x01 XP: You bought^x04 HE-Grenade!^x01")
            }
            else
            {
                
ColorChat(idNORMAL"^x04*^x01 XP: You have insufficient XP!" )
            }
        }
        case 
1:
        {
            if(
g_szXP[id] >= get_pcvar_num(c_szFlash)) {
                
g_szXP[id] -= get_pcvar_num(c_szFlash)
                
give_item(id"weapon_flashbang" )
                
ColorChat(idNORMAL"^x04*^x01 XP: You bought^x04 Flashbang!")
            }
            else
            {
                
ColorChat(idNORMAL"^x04*^x01 XP: You have insufficient XP!")
            }
        }
        case 
2:
        {
            if(
g_szXP[id] >= get_pcvar_num(c_szFrost)) {
                
g_szXP[id] -= get_pcvar_num(c_szFrost)
                
give_item(id"weapon_smokegrenade" )
                
ColorChat(idNORMAL"^x04*^x01 XP: You bought^x04 FrostNade!")
            }
            else
            {
                
ColorChat(idNORMAL"^x04*^x01 XP: You have insufficient XP!")
            }
        }
    }

Continue....

Last edited by nkz1337; 11-26-2011 at 12:10.
nkz1337 is offline
Send a message via Skype™ to nkz1337
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 20:52.


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