#include <amxmodx>
#include <amxmisc>
#include <csdm>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <nvault>
#include <xs>
native get_points(id)
native set_points(id, value)
new g_iMaxPlayers
#define IsPlayer(%0) (1 <= %0 <= g_iMaxPlayers)
#define TASTESHOP (1<<0)|(1<<1)
new const TAG[] = "[Respawn Skills]";
new const owner_name[] = "nume detinator";
// Puteri
new g_permanent_1[33], g_permanent_2[33], g_permanent_3[33], g_permanent_4[33], g_permanent_5[33], g_permanent_6[33], g_permanent_7[33], g_status_sync;
// Spatele puterilor
// No Recoil
new const NONWPN_BITSUM = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
new Float:pl_clpushangle[33][3], pl_wpnnames[32];
// Refill ammo on kill
new const g_weapons[] =
{
CSW_P228,
CSW_SCOUT,
CSW_XM1014,
CSW_MAC10,
CSW_AUG,
CSW_ELITE,
CSW_FIVESEVEN,
CSW_UMP45,
CSW_SG550,
CSW_GALI,
CSW_GALIL,
CSW_FAMAS,
CSW_USP,
CSW_GLOCK18,
CSW_AWP,
CSW_MP5NAVY,
CSW_M249,
CSW_M3,
CSW_M4A1,
CSW_TMP,
CSW_G3SG1,
CSW_DEAGLE,
CSW_SG552,
CSW_AK47,
CSW_P90
}
new const g_max_clip[] =
{
13,
10,
7,
30,
30,
30,
20,
25,
30,
35,
35,
25,
12,
20,
10,
30,
100,
8,
30,
30,
20,
7,
30,
30,
50
}
new const g_other_weapons[] =
{
CSW_KNIFE,
CSW_HEGRENADE,
CSW_C4
}
// Multi Jump
new jumpnum[33] = 0
new bool:dojump[33] = false
// nVault
new save_data, g_msg_saytext;
public plugin_init()
{
register_plugin("Buy Powers", "1.0", "cyby")
register_clcmd("chooseteam", "buy_menu")
new iWpn;
for(iWpn = 1; iWpn <= CSW_P90; iWpn++)
{
if(!(NONWPN_BITSUM & (1 << iWpn)) && get_weaponname(iWpn, pl_wpnnames, charsmax(pl_wpnnames)))
{
RegisterHam(Ham_Weapon_PrimaryAttack, pl_wpnnames, "primary_attack")
RegisterHam(Ham_Weapon_PrimaryAttack, pl_wpnnames, "primary_attack_post",1)
}
}
RegisterHam(Ham_TakeDamage, "player", "take_damage")
register_event("CurWeapon", "events_lot", "be", "1=1")
register_clcmd("give_points", "give_points")
g_status_sync = CreateHudSyncObj()
g_iMaxPlayers = get_maxplayers()
g_msg_saytext = get_user_msgid("SayText")
}
public plugin_cfg()
{
save_data = nvault_open("puteri")
if(save_data == INVALID_HANDLE)
set_fail_state("Eroare la deschiderea bazei de date.")
}
public plugin_end()
nvault_close(save_data)
public buy_menu(id)
{
if(is_user_alive(id))
{
new menu = menu_create("\yPermanent Powers\w" , "butoane_shop")
menu_additem(menu, "Permanent", "")
menu_additem(menu, "Items", "")
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE
}
public give_points(id)
{
new arg[32], name[32];
read_argv(1, arg, 31)
get_user_name(id, name, charsmax(name) - 1)
if(!equali(name, owner_name))
return PLUGIN_HANDLED
new jucator = cmd_target(id, arg, 31)
if(!jucator)
return PLUGIN_HANDLED
if(!is_user_connected(jucator))
return PLUGIN_HANDLED
new cant[7], name2[32];
get_user_name(jucator, name2, 31)
read_argv(2, cant, 6)
new XP_plus = str_to_num(cant)
set_points(jucator, get_points(jucator) + XP_plus)
color(0, ".v%s.g Owner.e %s.g give.e %d.g points to.e %s.g.", TAG, name, XP_plus, name2)
return PLUGIN_HANDLED;
}
public butoane_shop(id, menu, key)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED;
switch(key)
{
case 0: show_permanent(id)
case 1: show_extra(id)
}
return PLUGIN_CONTINUE;
}
public show_permanent(id)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED;
new menu = menu_create("\yPermanent Powers\w" , "permanent_handle")
menu_additem(menu, "NoRecoil--\y 16000 Points\w", "1", 0)
menu_additem(menu, "HP Max 1000\y 14000 Points\w", "2", 0)
menu_additem(menu, "Double Jump\y 20000 Points\w", "3", 0)
menu_additem(menu, "Refill Ammo on Kill\y 24000 Points\w", "4", 0)
menu_additem(menu, "MoveSpeed 280\y 15000 Points\w", "5", 0)
menu_additem(menu, "Invisibility on Knife\y 22000 Points\w", "6", 0)
menu_additem(menu, "Damage +10\y 28000 Points\w", "7", 0)
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
return PLUGIN_CONTINUE;
}
public permanent_handle(id, menu, item)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED;
switch(item)
{
case 0:
{
if(g_permanent_1[id])
{
color(id, ".v%s.g Already have.e NoRecoil--.g.", TAG)
return PLUGIN_HANDLED;
}
if(get_points(id) < 8000)
{
color(id, ".v%s.g You do not have enough points. You need another:.e %d.g points.", TAG, 8000 - get_points(id))
return PLUGIN_HANDLED;
}
set_points(id, get_points(id) - 8000)
g_permanent_1[id] = 1
color(id, ".v%s.g You bought.e NoRecoil--.g permanently, remaining points:.e %d.g.", TAG, get_points(id))
set_data(id)
}
case 1:
{
if(g_permanent_2[id])
{
color(id, ".v%s.g Already have.e HP Max 1000.g.", TAG)
return PLUGIN_HANDLED;
}
if(get_points(id) < 7000)
{
color(id, ".v%s.g You do not have enough points. You need another:.e %d.g points.", TAG, 7000 - get_points(id))
return PLUGIN_HANDLED;
}
set_points(id, get_points(id) - 7000)
g_permanent_2[id] = 1
color(id, ".v%s.g You bought.e Hp Max 1000.g permanently, remaining points:.e %d.g.", TAG, get_points(id))
set_data(id)
}
case 2:
{
if(g_permanent_3[id])
{
color(id, ".v%s.g Already have.e Double Jump.g.", TAG)
return PLUGIN_HANDLED;
}
if(get_points(id) < 10000)
{
color(id, ".v%s.g You do not have enough points. You need another:.e %d.g points.", TAG, 10000 - get_points(id))
return PLUGIN_HANDLED;
}
set_points(id, get_points(id) - 10000)
g_permanent_3[id] = 1
color(id, ".v%s.g You bought.e Double Jump.g permanently, remaining points:.e %d.g.", TAG, get_points(id))
set_data(id)
}
case 3:
{
if(g_permanent_4[id])
{
color(id, ".v%s.g Already have.e Refill Ammo on Kill.g.", TAG)
return PLUGIN_HANDLED;
}
if(get_points(id) < 12000)
{
color(id, ".v%s.g You do not have enough points. You need another:.e %d.g points.", TAG, 12000 - get_points(id))
return PLUGIN_HANDLED;
}
set_points(id, get_points(id) - 12000)
g_permanent_4[id] = 1
color(id, ".v%s.g You bought.e Refill Ammo on Kill.g permanently, remaining points:.e %d.g.", TAG, get_points(id))
set_data(id)
}
case 4:
{
if(g_permanent_5[id])
{
color(id, ".v%s.g Already have.e MoveSpeed 280.g.", TAG)
return PLUGIN_HANDLED;
}
if(get_points(id) < 7500)
{
color(id, ".v%s.g You do not have enough points. You need another:.e %d.g points.", TAG, 7500 - get_points(id))
return PLUGIN_HANDLED;
}
set_points(id, get_points(id) - 7500)
g_permanent_5[id] = 1
color(id, ".v%s.g You bought.e MoveSpeed 280.g permanently, remaining points:.e %d.g.", TAG, get_points(id))
set_data(id)
}
case 5:
{
if(g_permanent_6[id])
{
color(id, ".v%s.g Already have.e Invisibility on Knife.g.", TAG)
return PLUGIN_HANDLED;
}
if(get_points(id) < 11000)
{
color(id, ".v%s.g You do not have enough points. You need another:.e %d.g points.", TAG, 11000 - get_points(id))
return PLUGIN_HANDLED;
}
set_points(id, get_points(id) - 11000)
g_permanent_6[id] = 1
color(id, ".v%s.g You bought.e Invisibility on Knife.g permanently, remaining points:.e %d.g.", TAG, get_points(id))
set_data(id)
}
case 6:
{
if(g_permanent_7[id])
{
color(id, ".v%s.g Already have.e Damage +10.g.", TAG)
return PLUGIN_HANDLED;
}
if(get_points(id) < 14000)
{
color(id, ".v%s.g You do not have enough points. You need another:.e %d.g puncte.", TAG, 14000 - get_points(id))
return PLUGIN_HANDLED;
}
set_points(id, get_points(id) - 14000)
g_permanent_7[id] = 1
color(id, ".v%s.g You bought.e Damage +10.g permanently, remaining points:.e %d.g.", TAG, get_points(id))
set_data(id)
}
case MENU_EXIT:
{
}
}
menu_destroy(menu)
return PLUGIN_HANDLED;
}
public client_putinserver(id)
{
jumpnum[id] = 0
dojump[id] = false
get_data(id)
set_task(1.0, "show_hud", id, _, _, "b")
}
public client_disconnect(id)
{
jumpnum[id] = 0
dojump[id] = false
set_data(id)
remove_task(id)
g_permanent_7[id] = 0
g_permanent_6[id] = 0
g_permanent_5[id] = 0
g_permanent_4[id] = 0
g_permanent_3[id] = 0
g_permanent_2[id] = 0
g_permanent_1[id] = 0
}
public show_hud(id)
{
if(!is_user_connected(id))
{
remove_task(id)
return
}
static menu[1104], len;
len = 0
if(g_permanent_1[id])
len += formatex(menu[len], charsmax(menu) - len, "NoRecoil--^n")
if(g_permanent_2[id])
len += formatex(menu[len], charsmax(menu) - len, "HP Max 1000^n")
if(g_permanent_3[id])
len += formatex(menu[len], charsmax(menu) - len, "Double Jump^n")
if(g_permanent_4[id])
len += formatex(menu[len], charsmax(menu) - len, "Refill Ammo on Kill^n")
if(g_permanent_5[id])
len += formatex(menu[len], charsmax(menu) - len, "MoveSpeed 280^n")
if(g_permanent_6[id])
len += formatex(menu[len], charsmax(menu) - len, "Invisibility on Knife^n")
if(g_permanent_7[id])
len += formatex(menu[len], charsmax(menu) - len, "Damage +10^n")
set_hudmessage(255, 127, 0, 0.0, 0.26, 0, 1.1, 1.0)
ShowSyncHudMsg(id, g_status_sync, menu)
}
public set_data(id)
{
new name[32];
get_user_name(id, name, charsmax(name) - 1)
new cheiasalvarii[64], datelesalvarii[256]
format(cheiasalvarii, 63, "%s_POINTS", name)
format(datelesalvarii ,255, "%i#%i#%i#%i#%i#%i#%i#", g_permanent_1[id], g_permanent_2[id], g_permanent_3[id], g_permanent_4[id], g_permanent_5[id], g_permanent_6[id], g_permanent_7[id])
nvault_set(save_data, cheiasalvarii, datelesalvarii)
}
public get_data(id)
{
new name[32];
get_user_name(id, name, charsmax(name) - 1)
new cheiasalvarii[64], datelesalvarii[256];
format(cheiasalvarii, 63, "%s_POINTS", name)
format(datelesalvarii, 255, "%i#%i#%i#%i#%i#%i#%i#", g_permanent_1[id], g_permanent_2[id], g_permanent_3[id], g_permanent_4[id], g_permanent_5[id], g_permanent_6[id], g_permanent_7[id])
nvault_get(save_data, cheiasalvarii, datelesalvarii, 255)
replace_all(datelesalvarii, 255, "#", " ")
new putere_1[4], putere_2[4], putere_3[4], putere_4[4], putere_5[4], putere_6[4], putere_7[4];
parse(datelesalvarii, putere_1, 3, putere_2, 3, putere_3, 3, putere_4, 3, putere_5, 3, putere_6, 3, putere_7, 3)
g_permanent_1[id] = str_to_num(putere_1)
g_permanent_2[id] = str_to_num(putere_2)
g_permanent_3[id] = str_to_num(putere_3)
g_permanent_4[id] = str_to_num(putere_4)
g_permanent_5[id] = str_to_num(putere_5)
g_permanent_6[id] = str_to_num(putere_6)
g_permanent_7[id] = str_to_num(putere_7)
}
public show_extra(id)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED;
color(id, ".v%s.g Currently working on this part.", TAG)
return PLUGIN_CONTINUE;
}
public primary_attack(ent)
{
new iPlayer = pev(ent,pev_owner)
pev(iPlayer, pev_punchangle, pl_clpushangle[iPlayer])
return HAM_IGNORED
}
public primary_attack_post(ent)
{
new iPlayer = pev(ent, pev_owner)
if(g_permanent_1[iPlayer])
{
new Float:recoil = 0.5
new Float:push[3]
pev(iPlayer, pev_punchangle, push)
xs_vec_sub(push, pl_clpushangle[iPlayer], push)
xs_vec_mul_scalar(push, recoil, push)
xs_vec_add(push, pl_clpushangle[iPlayer], push)
set_pev(iPlayer, pev_punchangle, push)
}
return HAM_IGNORED
}
public take_damage(iVictim, iInflictor, iAttacker, Float:iDamage, iDamage_Type)
{
if(iVictim == iAttacker || !is_user_connected(iAttacker))
return HAM_IGNORED;
if(IsPlayer(iAttacker) && g_permanent_7[iAttacker])
{
SetHamParamFloat(4, iDamage + 10.0)
}
return HAM_IGNORED;
}
public events_lot(id)
{
if(get_user_weapon(id) == CSW_KNIFE && g_permanent_6[id])
fm_set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 75)
else
fm_set_user_rendering(id)
if(g_permanent_5[id])
set_pev(id, pev_maxspeed, 280.0)
}
public client_death(killer, victim, wpnindex, hitplace, TK)
{
if(!csdm_get_ffa() && TK)
return
if(!is_user_alive(killer))
return
if(!g_permanent_4[killer])
return
for(new a = 0; a < sizeof (g_other_weapons); a++)
if (wpnindex == g_other_weapons[a])
return
new weapon = fm_get_weapon_ent(killer, wpnindex)
for(new a = 0; a < sizeof (g_weapons); a++)
if(wpnindex == g_weapons[a])
{
new ammo = get_weapon_maxclip(wpnindex)
if(ammo)
{
client_cmd(killer, "spk ^"items/9mmclip1.wav^"")
cs_set_weapon_ammo(weapon, ammo)
}
return
}
}
public client_PreThink(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE
if(!g_permanent_3[id]) return PLUGIN_CONTINUE
new nbut = get_user_button(id)
new obut = get_user_oldbutton(id)
if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))
{
if(jumpnum[id] < 2)
{
dojump[id] = true
jumpnum[id]++
return PLUGIN_CONTINUE
}
}
if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
{
jumpnum[id] = 0
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public client_PostThink(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE
if(!g_permanent_3[id]) return PLUGIN_CONTINUE
if(dojump[id] == true)
{
new Float:velocity[3]
entity_get_vector(id,EV_VEC_velocity,velocity)
velocity[2] = random_float(265.0,285.0)
entity_set_vector(id,EV_VEC_velocity,velocity)
dojump[id] = false
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public plugin_natives()
{
register_native("cyby_get_pw_hp", "native_get_hp", 1)
}
public native_get_hp(id)
{
return g_permanent_2[id]
}
get_weapon_maxclip(wpnid = 0)
{
for(new a = 0; a < sizeof (g_weapons); a++)
if(wpnid == g_weapons[a])
return g_max_clip[a]
return false
}
fm_get_weapon_ent(id, wpnid = 0)
{
new name[32]
if(wpnid)
get_weaponname(wpnid, name, 31)
if(!equal(name, "weapon_", 7))
format(name, sizeof (name) - 1, "weapon_%s", name)
return fm_find_ent_by_owner(get_maxplayers(), name, id)
}
fm_find_ent_by_owner(id, const classname[], owner, jghgtype = 0)
{
new strtype[16] = "classname"
new ent = id
switch(jghgtype)
{
case 1: strtype = "target"
case 2: strtype = "targetname"
}
while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner)
{
}
return ent
}
fm_set_user_rendering(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
{
set_pev(index, pev_renderfx, fx)
new Float:RenderColor[3]
RenderColor[0] = float(r)
RenderColor[1] = float(g)
RenderColor[2] = float(b)
set_pev(index, pev_rendercolor, RenderColor)
set_pev(index, pev_rendermode, render)
set_pev(index, pev_renderamt, float(amount))
return 1;
}
stock color(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, ".v", "^4")
replace_all(msg, 190, ".g", "^1")
replace_all(msg, 190, ".e", "^3")
if(id) players[0] = id;
else get_players(players, count, "ch")
{
for(new i = 0; i < count; i++)
{
if(is_user_connected(players))
{
message_begin(MSG_ONE_UNRELIABLE, g_msg_saytext, _, players)
write_byte(players);
write_string(msg);
message_end();
}
}
}
}