| 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 i = 0; i < Items; i++ ) { 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 i = 0; i < sizeof(g_ability_descs); i++ ) { hnsxp_describe_ability(g_ability_pointer, g_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 i = 0; i < Items; i++ ) { 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_client; client <= g_max_clients; client++ ) { 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 i = 0; i < Items; i++ ) { percent = g_item_max_value[i] * g_level[client][i] / g_item_max_level[i]; if( percent > 0 && (percent == 100 || random_num(1, 100) <= percent) ) { give_item(client, g_weapon_classnames[i]); cs_set_weapon_ammo(find_ent_by_owner (1, g_weapon_classnames[i], client), 1); cs_set_user_bpammo(client, g_weapon_classnames2[i], 0); if( percent < 100 ) { hnsxp_print(client, "^1 You received your^3 %s^1! (%i%s)", g_item_name[i], percent, g_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 :)
|