AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weapon Chance (https://forums.alliedmods.net/showthread.php?t=133003)

ZombieFreak 07-20-2010 19:58

Weapon Chance
 
Hello i am working on the HNS Xp Mod Ability: Weapon Chance by NiQu.

And i am trying to add SCOUT and i am a very noob at coding so this is what i have done so far.


PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <hnsxp>
#include <fun>
#include <engine>

// =================================================
// BEGIN EDITING HERE
// =================================================

// The xp amount required to buy the first level

#define FIRST_XP_FIVESEVEN        400
#define FIRST_XP_DEAGLE            600
#define FIRST_XP_AWP            1200
#define FIRST_XP_SCOUT          2000

// The xp interval between levels
// Use a positive value for your own interval.
// Use XP_INTERVAL_NONE for the "first_xp" value as each interval.
// Use XP_INTERVAL_EXPONENTIAL for the xp to double for each level. (default)

#define INTERVAL_FIVESEVEN        XP_INTERVAL_EXPONENTIAL
#define INTERVAL_DEAGLE        XP_INTERVAL_EXPONENTIAL
#define INTERVAL_AWP        XP_INTERVAL_EXPONENTIAL
#define INTERVAL_SCOUT      XP_INTERVAL_EXPONENTIAL

// The maximum level for each item

#define MAX_LEVEL_FIVESEVEN        5
#define MAX_LEVEL_DEAGLE        5
#define MAX_LEVEL_AWP        4
#define MAX_LEVEL_SCOUT 2

// The maximum ammo for each item
#define MAX_AMMO_FIVESEVEN        3
#define MAX_AMMO_DEAGLE        3
#define MAX_AMMO_AWP    2
#define MAX_AMMO_SCOUT 0

// The maximum value possible for this item (happens when player has maximum level)

#define MAX_VALUE_FIVESEVEN        50
#define MAX_VALUE_DEAGLE        50
#define MAX_VALUE_AWP        25
#define MAX_VALUE_SCOUT     20

// =================================================
// STOP EDITING HERE
// =================================================

new const g_ability_descs[][] =
{
    
"The Weapon Chance ability for the XP Mod is for Terrorists and Counter-Terrorists.",
    
"The Weapon Chance ability contains the Fiveseven, Deagle, and the AWP.",
    
"These are the weapons you are given at the end of hide timer.",
    
"The values for each weapon are chances that you are given each time you spawn."
};

enum _:Items
{
    
ITEM_FIVESEVEN,
    
ITEM_DEAGLE,
    
ITEM_AWP,
    
ITEM_SCOUT,
};

new const 
g_item_name[Items][] =
{
    
"Fiveseven",
    
"Deagle",
    
"AWP"
    "Scout"
,
};

new const 
g_item_save_name[Items][] =
{
    
"wep_fiveseven",
    
"wep_deagle",
    
"wep_awp"
    "wep_scout"
};

new const 
g_item_value_type[Items][] =
{
    
"%",
    
"%",
    
"%"
    "%"
};

new const 
g_item_first_xp[Items] =
{
    
FIRST_XP_FIVESEVEN,
    
FIRST_XP_DEAGLE,
    
FIRST_XP_AWP
    FIRST_XP_SCOUT
};

new const 
g_item_xp_interval[Items] =
{
    
INTERVAL_FIVESEVEN,
    
INTERVAL_DEAGLE,
    
INTERVAL_AWP
    INTERVAL_SCOUT
};

new const 
g_item_max_level[Items] =
{
    
MAX_LEVEL_FIVESEVEN,
    
MAX_LEVEL_DEAGLE,
    
MAX_LEVEL_AWP
    MAX_LEVEL_SCOUT
};

new const 
g_item_max_value[Items] =
{
    
MAX_VALUE_FIVESEVEN,
    
MAX_VALUE_DEAGLE,
    
MAX_VALUE_AWP
    MAX_VALUE_SCOUT
};

new const 
g_weapon_classnames[Items][] =
{
    
"weapon_fiveseven",
    
"weapon_deagle",
    
"weapon_awp"
    "weapon_scout"
};

new const 
g_weapon_classnames2[Items] =
{
    
CSW_FIVESEVEN,
    
CSW_DEAGLE,
    
CSW_AWP
    CSW_SCOUT
};

new 
g_ability_pointer;
new 
g_item_pointer[Items];

new 
g_level[33][Items];

new 
cvar_spawn_weapon_delay;

new 
Float:g_weapon_give_time;

new 
g_first_client;
new 
g_max_clients;

public 
plugin_init()
{
    
register_plugin("HNSXP Ability - Weapon Chance"HNSXP_VERSION"ReCon");
    
    
g_ability_pointer hnsxp_register_ability("Weapon Chance");
    
    for( new 
0Itemsi++ )
    {
        
g_item_pointer[i] = hnsxp_register_item(g_ability_pointer,\
            
g_item_name[i],\
            
g_item_save_name[i],\
            
g_item_value_type[i],\
            
g_item_first_xp[i],\
            
g_item_xp_interval[i],\
            
g_item_max_level[i],\
            
g_item_max_value[i]
        );
    }
    
    for( new 
0sizeof(g_ability_descs); i++ )
    {
        
hnsxp_describe_ability(g_ability_pointerg_ability_descs[i]);
    }
    
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawn"1);
    
    
register_event("HLTV""EventNewRound""a""1=0""2=0");
    
register_logevent("EventRoundStart"2"1=Round_Start");
    
register_event("TextMsg""EventRoundRestart""a""2&#Game_C""2&#Game_w");
    
    
cvar_spawn_weapon_delay register_cvar("hnsxp_spawn_weapon_delay""10");
    
    
g_first_client 1;
    
g_max_clients get_maxplayers();
}

public 
hnsxp_update_user_level(const ability, const item, const client, const level)
{
    if( 
ability == g_ability_pointer )
    {
        for( new 
0Itemsi++ )
        {
            if( 
g_item_pointer[i] == item )
            {
                
g_level[client][i] = level;
                break;
            }
        }
    }
}

public 
FwdPlayerSpawn(client)
{
    if( 
is_user_alive(client) )
    {
        if( 
get_gametime() >= g_weapon_give_time )
        {
            
GiveWeapons(client);
        }
    }
}

public 
EventNewRound()
{
    
g_weapon_give_time 9999999.9;
}

public 
EventRoundStart()
{
    
g_weapon_give_time get_pcvar_float(cvar_spawn_weapon_delay);
    
    
set_task(g_weapon_give_time"TaskGiveWeapons"1234);
    
    
g_weapon_give_time += get_gametime();
}

public 
EventRoundRestart()
{
    
remove_task(1234);
    
    
g_weapon_give_time 9999999.9;
}

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_T )
    {
        static 
percent;
        for( new 
0Itemsi++ )
        {
            
percent g_item_max_value[i] * g_level[client][i] / g_item_max_level[i];
            if( 
percent && (percent == 100 || random_num(1100) <= percent) )
            {
                
give_item(clientg_weapon_classnames[i]);
                
cs_set_weapon_ammo(find_ent_by_owner (1g_weapon_classnames[i], client), 1);
                
cs_set_user_bpammo(clientg_weapon_classnames2[i], 0);
                
                
                if( 
percent 100 )
                {
                    
hnsxp_print(client"^1 You received your^3 %s^1! (%i%s)"g_item_name[i], percentg_item_value_type[i]);
                }
            }
        }
    }


Can someone do so i get SCOUT. If you fix it please tell me how you added it and show me the part of the scout code so i can learn me more :)

Lulu the hero 07-20-2010 20:03

Re: Weapon Chance
 
I don't want to off, but isn't hns all about knife and grenades?

ZombieFreak 07-20-2010 20:04

Re: Weapon Chance
 
Nope.

suffer 07-20-2010 23:33

Re: Weapon Chance
 
It is, LuLu, but now people want to hurry things up by winning, thats why we now have:
Nademodes (Instant Impact) - I remember when that wasn't around.
New HNS Shops (Guns, such as Awp/Deagle/More HP/More AP/Revive/XP)
XP Mod (To raise your levels percentage change)
New Blocks (Deagle/Awp/Usp/Any of the guns)
NoSlowDown (Because we all failed at slowdown)
Man... I remember when jukeNrun was out and the most popular hns slowdown server. It never had any of this and when Exolent added a gun block or something cool it was like the best thing for everybody lol. Then slowdown came around with the first clan out, .Es^| (Elite Soldiers) owned by Raz0r. That started up the Hide'N'Seek Revolution and new things were coded. Now theres so many hide'n'seek servers its not even funny so it's pretty worthless now. Only to think theres probably 50 and only one is actually full almost all the time, iGz.
Anyways I have no idea why I'm creating this paragraph, I'm just bored and felt like explaining the HnS history of what it came about. Pretty interesting, still.


All times are GMT -4. The time now is 07:12.

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