Raised This Month: $ Target: $400
 0% 

requesting some help about HNS XP Mod


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AirShot
Veteran Member
Join Date: Sep 2009
Location: Belgium
Old 08-08-2010 , 18:41   requesting some help about HNS XP Mod
Reply With Quote #1

hi everybody
ok, so i'am here because i'am using hns xp mod v0.0.1 (from this page)
and today I tried to add deagle and awp abilities. I guess it's not really hard but I failed ><, when I open the main menu and then go in the weapons menu, it isn't work and player info menu isn't work too so i request your to add it for me

Here you've got the code I found and that I would like add to the xp mod plugin (the attached files below):

Deagle & Awp in HNS XP Mod
PHP Code:
// These determine if these abilities should be enabled or disabled
// 1 = enabled
// 0 = disabled
#define ENABLE_DEAGLE            1
#define ENABLE_AWP                1

// The maximum level for each ability
#define MAXLEVEL_AWP            5
#define MAXLEVEL_DEAGLE            3

// The xp amount required to buy the first level
#define FIRST_XP_AWP            2500
#define FIRST_XP_DEAGLE            7500

// The maximum chance possible for this ability (happens when player has maximum level)
#define CHANCE_MAX_AWP                10
#define CHANCE_MAX_DEAGLE            15

enum _:Weapons
{
    
WEAPON_AWP,
    
WEAPON_DEAGLE
};

new const 
g_weapons_enabled[Weapons] =
{
    
ENABLE_AWP,
    
ENABLE_DEAGLE
};

new const 
g_any_weapons_enabled ENABLE_AWP ENABLE_DEAGLE;

new const 
g_weapons_names[Weapons][] =
{
    
"Awp",
    
"Deagle"
};

#define WEAPON_AMT 2

new const g_weapons[WEAPON_AMT][] =
{
    
"weapon_awp",
    
"weapon_deagle"
};

new const 
g_ammo[WEAPON_AMT] =
{
    
1// awp
    
// deagle
};

new const 
g_weapons_maxlevels[Weapons] =
{
    
MAXLEVEL_AWP,
    
MAXLEVEL_DEAGLE
};

new const 
g_weapons_first_xp[Weapons] =
{
    
FIRST_XP_AWP,
    
FIRST_XP_DEAGLE
};

new const 
g_weapons_max_chance[Weapons] =
{
    
CHANCE_MAX_AWP,
    
CHANCE_MAX_DEAGLE
};

#define ANY_ABILITY_ENABLED (g_any_nade_enabled || g_any_health_enabled || g_any_armor_enabled || g_any_respawn_enabled || g_any_nofall_enabled || g_any_weapons_enabled)

new g_weapons_level[33][Weapons];

new 
cvar_spawn_weapons_delay;

new 
Float:g_weapons_give_time;

cvar_spawn_weapons_delay register_cvar("hnsxp_spawn_weapons_delay""10");

public 
EventNewRound()
{
    
arrayset(g_used_revive0sizeof(g_used_revive));
    
    
g_nade_give_time 9999999.9;
    
g_weapons_give_time 9999999.9;
}

public 
EventRoundStart()
{
    
g_nade_give_time get_pcvar_float(cvar_spawn_nade_delay);
    
g_weapons_give_time get_pcvar_float(cvar_spawn_weapons_delay);
    
    
set_task(g_nade_give_time"TaskGiveNades"1234);
    
set_task(g_weapons_give_time"TaskGiveWeapons"12345);
    
    
g_nade_give_time += get_gametime();
    
g_weapons_give_time += get_gametime();
}

public 
EventRoundRestart()
{
    
remove_task(1234);
    
remove_task(12345);
    
    
g_nade_give_time 9999999.9;
    
g_weapons_give_time 9999999.9;
}

            if( 
get_gametime() >= g_weapons_give_time )
            {
                
GiveWeapons(client);
            } 
// Goes under public FwdPlayerSpawn(client)

public TaskGiveWeapons()
{
    for( new 
client g_first_clientclient <= g_max_clientsclient++ )
    {
        if( 
is_user_alive(client) )
        {
            
GiveWeapons(client);
        }
    }
}

GiveWeapons(client)
{
    new 
CsTeams:team cs_get_user_team(client);
    
    if( 
team != CS_TEAM_SPECTATOR )
    {
        static 
percent;
        for( new 
0Weaponsi++ )
        {
            if( 
g_weapons_enabled[i] )
            {
                
percent g_weapons_max_chance[i] * g_weapons_level[client][i] / g_weapons_maxlevels[i];
                if( 
percent && (percent == 100 || random_num(1100) <= percent) )
                {
                    
cs_set_weapon_ammogive_itemclientg_weapons[i] ), g_ammo[i] );
                    
                    if( 
percent 100 )
                    {
                        new 
szName33 ];
                        
get_user_nameclientszName32 );
                        
ColorChat(0GREEN"%s^x03 '%s' got^x04 %s^x03! (^x04%i%%^x03 chance)"MESSAGE_TAGszNameg_weapons_names[i], percent);
                        
ColorChat(clientGREEN"%s^x03 You received your^x04 %s^x03! (^x04%i%%^x03 chance)"MESSAGE_TAGg_weapons_names[i], percent);
                    }
                }
            }
        }
    }
}

    if (
g_any_weapons_enabled )
    {
        
menu_additem(menu"Weapons Menu""6");
    } 
// Goes under ShowMainMenu(client)

        
case '6':
        {
            
ShowWeaponsMenu(client);
        } 
// Goes under public MenuMain(client, menu, item)

ShowWeaponsMenu(client)
{
    static 
title[128];
    
formatex(titlesizeof(title) - 1"[HNS XP by Exolent]^nWeapons Menu^n^n^nYour XP: \w%i"g_xp[client]);
    new 
menu menu_create(title"MenuWeapons");
    new 
callback menu_makecallback("CallbackWeapons");
    
    
menu_additem(menu"\yHelp""*"_callback);
    
    static 
levelxppercentitem[128], info[4];
    for( new 
0Weaponsi++ )
    {
        if( 
g_weapons_enabled[i] )
        {
            
level g_weapons_level[client][i] + 1;
            
percent g_weapons_max_chance[i] * level g_weapons_maxlevels[i];
            
            if( 
g_weapons_level[client][i] < g_weapons_maxlevels[i] )
            {
                
xp g_weapons_first_xp[i] * (<< (level 1));
                
formatex(itemsizeof(item) - 1"%s: \yLevel %i (%i%%) \r[\w%i XP\r]"g_weapons_names[i], levelpercentxp);
            }
            else
            {
                
formatex(itemsizeof(item) - 1"%s: \yLevel %i (%i%%) \r[\wMaxed Out!\r]"g_weapons_names[i], levelpercent);
            }
            
            
num_to_str(iinfosizeof(info) - 1);
            
            
menu_additem(menuiteminfo_callback);
        }
    }
    
    
menu_display(clientmenu);
}

public 
MenuWeapons(clientmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
ShowMainMenu(client);
        return;
    }
    
    static 
_accessinfo[4], callback;
    
menu_item_getinfo(menuitem_accessinfosizeof(info) - 1__callback);
    
menu_destroy(menu);
    
    if( 
info[0] == '*' )
    {
        static 
motd[2500];
        new 
len formatex(motdsizeof(motd) - 1,    "<body style=^"background-color:#030303; color:#FF8F00^">");
        
len += format(motd[len], sizeof(motd) - len 1,    "<p align=^"center^">");
        
len += format(motd[len], sizeof(motd) - len 1,    "The Weapons ability contains the Awp and Deagle<br>");
        
len += format(motd[len], sizeof(motd) - len 1,    "These are the weapons you are given when you receive your items after the hide timer ends.<br>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<br>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<table>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<tr>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<th></th>");
        for( new 
0Weaponsi++ )
        {
            if( 
g_weapons_enabled[i] )
            {
                
len += format(motd[len], sizeof(motd) - len 1,    "<th>%s</th>"g_weapons_names[i]);
            }
        }
        
len += format(motd[len], sizeof(motd) - len 1,    "</tr>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<tr>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<th>Chance Intervals</th>");
        for( new 
0Weaponsi++ )
        {
            if( 
g_weapons_enabled[i] )
            {
                
len += format(motd[len], sizeof(motd) - len 1,    "<td>%i%%</td>", (g_weapons_max_chance[i] / g_weapons_maxlevels[i]));
            }
        }
        
len += format(motd[len], sizeof(motd) - len 1,    "</tr>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<tr>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<th>Max Level</th>");
        for( new 
0Weaponsi++ )
        {
            if( 
g_weapons_enabled[i] )
            {
                
len += format(motd[len], sizeof(motd) - len 1,    "<td>%i</td>"g_weapons_maxlevels[i]);
            }
        }
        
len += format(motd[len], sizeof(motd) - len 1,    "</tr>");
        
len += format(motd[len], sizeof(motd) - len 1,    "<th>Max Chance</th>");
        for( new 
0Weaponsi++ )
        {
            if( 
g_weapons_enabled[i] )
            {
                
len += format(motd[len], sizeof(motd) - len 1,    "<td>%i%%</td>"g_weapons_max_chance[i]);
            }
        }
        
len += format(motd[len], sizeof(motd) - len 1,    "</tr>");
        
len += format(motd[len], sizeof(motd) - len 1,    "</table>");
        
len += format(motd[len], sizeof(motd) - len 1,    "</p>");
        
len += format(motd[len], sizeof(motd) - len 1,    "</body>");
        
        
show_motd(clientmotd"XP Weapons Info");
    }
    else
    {
        new 
upgrade str_to_num(info);
        
        new 
level g_weapons_level[client][upgrade] + 1;
        new 
xp g_weapons_first_xp[upgrade] * (<< (level 1));
        new 
percent g_weapons_max_chance[upgrade] * level g_weapons_maxlevels[upgrade];
        
        
g_xp[client] -= xp;
        
g_weapons_level[client][upgrade] = level;
        
        
Save(client);
        
        
ColorChat(clientGREEN"%s^x03 You bought^x04 %s^x03 Level %i (^x04%i%%^x03) for^x04 %i XP^x03!"MESSAGE_TAGg_weapons_names[upgrade], levelpercentxp);
    }
    
    
ShowWeaponsMenu(client);
}

public 
CallbackWeapons(clientmenuitem)
{
    static 
_accessinfo[4], callback;
            

    
Smilies           [IMG]http://users.alliedmods.net/%7Esawce/pig.png[/IMG][IMG]http://users.alliedmods.net/%7Esawce/crab.gif[/IMG]:)   :nono::cry:
  
:3:grrr::shock:   :twisted::oops::wink:   :mrgreen::arrow::|                     

    
menu_item_getinfo(menuitem_accessinfosizeof(info) - 1__callback);
    
    if( 
info[0] == '*' ) return ITEM_ENABLED;
    
    new 
upgrade str_to_num(info);
    if( 
g_weapons_level[client][upgrade] == g_weapons_maxlevels[upgrade] )
    {
        return 
ITEM_DISABLED;
    }
    
    new 
xp g_weapons_first_xp[upgrade] * (<< g_weapons_level[client][upgrade]);
    if( 
g_xp[client] < xp )
    {
        return 
ITEM_DISABLED;
    }
    
    return 
ITEM_ENABLED;
}

    if( 
g_any_weapons_enabled )
    {
        
len += format(motd[len], sizeof(motd) - len 1"<br><b><font size=^"4^">Weapon Levels:</font></b><br>");
        for( new 
0Weaponsi++ )
        {
            if( 
g_weapons_enabled[i] )
            {
                
len += format(motd[len], sizeof(motd) - len 1"<b>%s:</b> %i/%i<br>"g_weapons_names[i], g_weapons_level[player][i], g_weapons_maxlevels[i]);
            }
        }
    } 
// Goes under public MenuPlayer(client, menu, item)

    
for( new 0Weaponsi++ )
    {
        
strbreak(datanumsizeof(num) - 1datasizeof(data) - 1);
        
g_weapons_level[client][i] = clamp(str_to_num(num), 0g_weapons_maxlevels[i]);
    } 
// Goes under ParseLoadData(client, data[256])

    
arrayset(g_weapons_level[client], 0sizeof(g_weapons_level[])); // Goes under NewUser(client)

    
for( new 0Weaponsi++ )
    {
        
len += formatex(data[len], sizeof(data) - len 1" %i"g_weapons_level[client][i]);
    } 
// Goes under Save(client) 
And I've got a second request but I think i will wait that someone fix this for me first
Attached Files
File Type: sma Get Plugin or Get Source (hns_xp.sma - 425 views - 54.2 KB)
__________________

Last edited by AirShot; 08-08-2010 at 18:44.
AirShot is offline
Old 08-14-2010, 19:21
AirShot
This message has been deleted by YamiKaitou. Reason: bump
Old 08-14-2010, 19:23
snowyledge
This message has been deleted by YamiKaitou. Reason: bump
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 00:54.


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