| Despardus |
08-06-2014 14:09 |
[SOLVED] Bazooka for ctf mod
I was modifying bazooka plugin for jctf mod. Everything is working fine. Just 1 bug.
Like when you have less money than bazooka cost you cant buy bazooka.. the same way when you have insufficient adrenaline(jctf feature) you shouldnt be able to buy it.
Bug : You can still buy the bazooka even if you have 0 adrenaline.
If you have 100 adrenaline and bazooka costs 75 adrenaline then 75 adrenaline is reduced and and changing players adrenaline to 25 but player can still buy another adrenaline.
What exactly do i need to change ?
PS : I'm newbie in this programming.
Code:
new iMoney = cs_get_user_money(id)
new iCost = get_pcvar_num(cvar_bazooka_cost)
new iAdre1 = jctf_get_adrenaline(id)
new iAdre2 = get_pcvar_num(cvar_bazooka_adre)
if(!is_user_alive(id))
client_print(id, print_center, "You cant buy when your dead!")
else if(Has_Bazooka[id])
client_print(id, print_center, "You already own that weapon.")
else if(iMoney < iCost)
client_print(id, print_center, "Insufficient funds! ($%d)", iCost)
else if(iAdre1 < iAdre2 ){
client_print(id, print_center, "Insufficient Adrenaline ! ($%d)",iAdre2)
}
else {
give_item(id, "weapon_c4")
Has_Bazooka[id] = true
Allow_Shooting[id] = true
Bazooka_Ammo1[id] = get_pcvar_num(cvar_bazooka_ammo1)
Bazooka_Ammo2[id] = get_pcvar_num(cvar_bazooka_ammo2)
Bazooka_Ammo3[id] = get_pcvar_num(cvar_bazooka_ammo3)
jctf_add_adrenaline(id ,get_pcvar_num(cvar_bazooka_adre))
client_print(id, print_chat," Adrenaline reduced !!")
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(cvar_bazooka_cost))
client_print(id, print_chat, "[Bazooka] You have successfully bought a bazooka!")
client_print(id, print_chat, "[Bazooka] What are you going to do now!?")
new temp[2], weaponID = get_user_weapon(id, temp[0], temp[1])
if(weaponID == CSW_C4) {
Bazooka_Active[id] = true
Event_CurWeapon(id)
entity_set_int(id, EV_INT_weaponanim, SEQ_FIDGET)
}
else {
Bazooka_Active[id] = true
client_cmd(id, "weapon_c4")
}
Edit : Bug resolved :D
It was a cvar problem -.-
|