图 1.
new gun_lv[33][14];
new gun_exp[33][14];
new g_gunhud_show;
new g_gunlevel_dmg;
new g_gunxp_kill;
new Float:g_gun_re;
new g_maxgunlv;
new g_czbot;
new g_savein;
new gunhud_name[33][33];
new bool:gunhud_show[33];
new weapon_id[31] =
{
-1, -1, -1, 9, -1, 1, -1, -1, 7, -1, -1, -1, -1, 11, 6, 5, -1, -1, 10, -1, 13, 2, 4, -1, 12, -1, -1, 8, 3, -1, -1
}
new hudsync;
new vault;
public plugin_init()
{
register_plugin(8844, "V1.7", "suen");
RegisterHam(Ham_TakeDamage, "player", "TakeDamage", 0);
register_event("DeathMsg", "event_deathmsg", "a", "");
register_event("HLTV", "event_newround", "a", "1=0", "2=0");
hudsync = CreateHudSyncObj(0);
vault = nvault_open("gunlevel");
return 0;
}
public plugin_precache()
{
load_ini();
return 0;
}
load_ini()
{
new path[64];
get_configsdir(path, 63);
format(path, 63, "%s/gun_level_cvar.ini", path);
if (!file_exists(path))
{
new error[100];
formatex(error, 99, "Cannot load gun_level_cvar.ini");
set_fail_state(error);
return 0;
}
new linedata[1024];
new key[64];
new value[960];
new section = 0;
new file = fopen(path, "rt");
while (file && !feof(file))
{
if (!linedata[0] || linedata[0] == 59)
{
}
}
if (file)
{
fclose(file);
}
return 0;
}
public show_info(id)
{
if (!g_gunhud_show || !is_user_alive(id))
{
return 1;
}
if (weapon_id[get_user_weapon(id, 0, 0)][0][0] != -1)
{
if (g_maxgunlv <= gun_lv[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]])
{
gun_lv[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]] = g_maxgunlv;
gun_exp[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]] = 0;
}
}
set_hudmessage(0, 255, 0, 0.60, 0.85, 0, 1.00, 1.50, 0.00, 0.00, -1);
gunhud_show[id] = 1;
if (get_user_weapon(id, 0, 0) == 13)
{
new var3 = gunhud_name[id][0][0];
var3[0] = 9792;
}
else
{
if (get_user_weapon(id, 0, 0) == 24)
{
new var4 = gunhud_name[id][0][0];
var4[0] = 9816;
}
if (get_user_weapon(id, 0, 0) == 20)
{
new var5 = gunhud_name[id][0][0];
var5[0] = 9840;
}
if (get_user_weapon(id, 0, 0) == 18)
{
new var6 = gunhud_name[id][0][0];
var6[0] = 9860;
}
if (get_user_weapon(id, 0, 0) == 3)
{
new var7 = gunhud_name[id][0][0];
var7[0] = 9876;
}
if (get_user_weapon(id, 0, 0) == 28)
{
new var8 = gunhud_name[id][0][0];
var8[0] = 9900;
}
if (get_user_weapon(id, 0, 0) == 22)
{
new var9 = gunhud_name[id][0][0];
var9[0] = 9920;
}
if (get_user_weapon(id, 0, 0) == 27)
{
new var10 = gunhud_name[id][0][0];
var10[0] = 9940;
}
if (get_user_weapon(id, 0, 0) == 8)
{
new var11 = gunhud_name[id][0][0];
var11[0] = 9964;
}
if (get_user_weapon(id, 0, 0) == 21)
{
new var12 = gunhud_name[id][0][0];
var12[0] = 9980;
}
if (get_user_weapon(id, 0, 0) == 5)
{
new var13 = gunhud_name[id][0][0];
var13[0] = 9992;
}
if (get_user_weapon(id, 0, 0) == 14)
{
new var14 = gunhud_name[id][0][0];
var14[0] = 10020;
}
if (get_user_weapon(id, 0, 0) == 15)
{
new var15 = gunhud_name[id][0][0];
var15[0] = 10044;
}
gunhud_show[id] = 0;
}
if (weapon_id[get_user_weapon(id, 0, 0)][0][0] != -1)
{
while (gun_exp[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]] >= 100 && gun_lv[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]] < g_maxgunlv)
{
new name[32];
get_user_name(id, name, 31);
gun_lv[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]]++;
gun_exp[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]] -= 100;
colorprint(0, "/g[枪械等级]%s的%s升到%d级了", name, gunhud_name[id][0][0], gun_lv[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]]);
}
}
if (gunhud_show[id][0][0])
{
ShowSyncHudMsg(id, hudsync, "%s Level:%d | %s Exp:%d/100", gunhud_name[id][0][0], gun_lv[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]], gunhud_name[id][0][0], gun_exp[id][0][0][weapon_id[get_user_weapon(id, 0, 0)][0][0]]);
}
return 1;
}
public TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if (victim != attacker && !is_user_connected(attacker))
{
return 1;
}
if (weapon_id[get_user_weapon(attacker, 0, 0)][0][0] != -1 && gun_lv[attacker][0][0][weapon_id[get_user_weapon(attacker, 0, 0)][0][0]] > 0)
{
damage *= 1.00 * g_gunlevel_dmg * gun_lv[attacker][0][0][weapon_id[get_user_weapon(attacker, 0, 0)][0][0]] / 100.00 + 1;
}
SetHamParamFloat(4, damage);
return 1;
}
public event_deathmsg()
{
if (weapon_id[get_user_weapon(attacker, 0, 0)][0][0] != -1 && gun_lv[attacker][0][0][weapon_id[get_user_weapon(attacker, 0, 0)][0][0]] < g_maxgunlv)
{
new var2 = gun_exp[attacker][0][0][weapon_id[get_user_weapon(attacker, 0, 0)][0][0]];
var2 = g_gunxp_kill + var2;
}
return 1;
}
public client_putinserver(id)
{
if (!equal(classname, "player", 0) && !g_czbot)
{
set_task(0.10, "registerham_from_czbot", id, "", 0, "", 0);
g_czbot = 1;
}
return 0;
}
public client_disconnect(id)
{
SaveData(id);
return 0;
}
public registerham_from_czbot(id)
{
RegisterHamFromEntity(Ham_TakeDamage, id, "TakeDamage", 0);
return 0;
}
public SaveData(id)
{
if (!g_savein)
{
return 1;
}
new vaultkey[64];
new vaultdata[256];
if (g_savein == 1)
{
new name[32];
get_user_name(id, name, 31);
format(vaultkey, 63, "%s-GL", name);
}
else
{
if (g_savein == 2)
{
new player_ip[33];
get_user_ip(id, player_ip, 32, 0);
format(vaultkey, 63, "%s-GL", player_ip);
}
}
format(vaultdata, 255, "%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#", gun_lv[id][0][0][3], gun_lv[id][0][0][4], gun_lv[id][0][0][8], gun_lv[id][0][0][7], gun_lv[id][0][0][1], gun_lv[id][0][0][2], gun_lv[id][0][0][9], gun_lv[id][0][0][10], gun_lv[id][0][0][11], gun_lv[id][0][0][12], gun_lv[id][0][0][13], gun_lv[id][0][0][5], gun_lv[id][0][0][6], gun_exp[id][0][0][3], gun_exp[id][0][0][4], gun_exp[id][0][0][8], gun_exp[id][0][0][7], gun_exp[id][0][0][1], gun_exp[id][0][0][2], gun_exp[id][0][0][9], gun_exp[id][0][0][10], gun_exp[id][0][0][11], gun_exp[id][0][0][12], gun_exp[id][0][0][13], gun_exp[id][0][0][5], gun_exp[id][0][0][6]);
nvault_set(vault, vaultkey, vaultdata);
return 0;
}
public LoadData(id)
{
if (!g_savein)
{
return 1;
}
new vaultkey[64];
new vaultdata[256];
if (g_savein == 1)
{
new name[32];
get_user_name(id, name, 31);
format(vaultkey, 63, "%s-GL", name);
}
else
{
if (g_savein == 2)
{
new player_ip[33];
get_user_ip(id, player_ip, 32, 0);
format(vaultkey, 63, "%s-GL", player_ip);
}
}
format(vaultdata, 255, "%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#%i#", gun_lv[id][0][0][3], gun_lv[id][0][0][4], gun_lv[id][0][0][8], gun_lv[id][0][0][7], gun_lv[id][0][0][1], gun_lv[id][0][0][2], gun_lv[id][0][0][9], gun_lv[id][0][0][10], gun_lv[id][0][0][11], gun_lv[id][0][0][12], gun_lv[id][0][0][13], gun_lv[id][0][0][5], gun_lv[id][0][0][6], gun_exp[id][0][0][3], gun_exp[id][0][0][4], gun_exp[id][0][0][8], gun_exp[id][0][0][7], gun_exp[id][0][0][1], gun_exp[id][0][0][2], gun_exp[id][0][0][9], gun_exp[id][0][0][10], gun_exp[id][0][0][11], gun_exp[id][0][0][12], gun_exp[id][0][0][13], gun_exp[id][0][0][5], gun_exp[id][0][0][6]);
nvault_get(vault, vaultkey, vaultdata, 255);
replace_all(vaultdata, 255, "#", " ");
new akl[32];
new m4l[32];
new sg552l[32];
new augl[32];
new xml[32];
new m3l[32];
new scoutl[32];
new awpl[32];
new sg550l[32];
new g3sg1l[32];
new m249l[32];
new famasl[32];
new galill[32];
new ake[32];
new m4e[32];
new sg552e[32];
new auge[32];
new xme[32];
new m3e[32];
new scoute[32];
new awpe[32];
new sg550e[32];
new g3sg1e[32];
new m249e[32];
new famase[32];
new galile[32];
parse(vaultdata, akl, 31, m4l, 31, sg552l, 31, augl, 31, xml, 31, m3l, 31, scoutl, 31, awpl, 31, sg550l, 31, g3sg1l, 31, m249l, 31, famasl, 31, galill, 31, ake, 31, m4e, 31, sg552e, 31, auge, 31, xme, 31, m3e, 31, scoute, 31, awpe, 31, sg550e, 31, g3sg1e, 31, m249e, 31, famase, 31, galile, 31);
gun_lv[id][0][0][3] = str_to_num(akl);
gun_lv[id][0][0][4] = str_to_num(m4l);
gun_lv[id][0][0][8] = str_to_num(sg552l);
gun_lv[id][0][0][7] = str_to_num(augl);
gun_lv[id][0][0][1] = str_to_num(xml);
gun_lv[id][0][0][2] = str_to_num(m3l);
gun_lv[id][0][0][9] = str_to_num(scoutl);
gun_lv[id][0][0][10] = str_to_num(awpl);
gun_lv[id][0][0][11] = str_to_num(sg550l);
gun_lv[id][0][0][12] = str_to_num(g3sg1l);
gun_lv[id][0][0][13] = str_to_num(m249l);
gun_lv[id][0][0][5] = str_to_num(famasl);
gun_lv[id][0][0][6] = str_to_num(galill);
gun_exp[id][0][0][3] = str_to_num(ake);
gun_exp[id][0][0][4] = str_to_num(m4e);
gun_exp[id][0][0][8] = str_to_num(sg552e);
gun_exp[id][0][0][7] = str_to_num(auge);
gun_exp[id][0][0][1] = str_to_num(xme);
gun_exp[id][0][0][2] = str_to_num(m3e);
gun_exp[id][0][0][9] = str_to_num(scoute);
gun_exp[id][0][0][10] = str_to_num(awpe);
gun_exp[id][0][0][11] = str_to_num(sg550e);
gun_exp[id][0][0][12] = str_to_num(g3sg1e);
gun_exp[id][0][0][13] = str_to_num(m249e);
gun_exp[id][0][0][5] = str_to_num(famase);
gun_exp[id][0][0][6] = str_to_num(galile);
return 0;
}
public event_newround()
{
colorprint(0, "/g[枪械等级]/y你正在使用suen的枪械升级v1.7插件");
return 0;
}
colorprint(id, String:input[])
{
new count = 1;
new players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "/g", "\4");
replace_all(msg, 190, "/y", "\1");
replace_all(msg, 190, "/ctr", "\3");
replace_all(msg, 190, "/w", "");
if (id)
{
players[0] = id;
}
else
{
get_players(players, count, "ch", "");
}
new i = 0;
while (i < count)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), 12448, players[i]);
write_byte(players[i]);
write_string("");
message_end();
i++;
}
i++;
}
return 0;
}