Raised This Month: $ Target: $400
 0% 

[FIX REQ] Bazooka plugin error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dare.Devil
Member
Join Date: May 2014
Old 08-15-2014 , 10:30   [FIX REQ] Bazooka plugin error
Reply With Quote #1

hi all,

I get this error written in my logs.txt file when I play the server with bazooka plugin:
L 08/14/2014 - 18:21:04: [AMXX] Displaying debug trace (plugin "bazooka_fixed.amxx")
L 08/14/2014 - 18:21:04: [AMXX] Run time error 4: index out of bounds
L 08/14/2014 - 18:21:04: [AMXX] [0] bazooka_fixed.sma::player_bazooka (line 1283)

below is the PHP code ..line 1283 starts at the first line u see below..
hmm error: index out of bounds .. I can compile the plugin successfully as it is with no error..
but when I start playing it logs errors that can go over 20 MB in size
please help!!

PHP Code:
if (user_controll[id] > 0) { 
        new 
RocketEnt user_controll[id
        if (
is_valid_ent(RocketEnt)) { 
            new 
Float:Velocity[3
            
VelocityByAim(id500Velocity
            
entity_set_vector(RocketEntEV_VEC_velocityVelocity
            new 
Float:NewAngle[3
            
entity_get_vector(idEV_VEC_v_angleNewAngle
            
entity_set_vector(RocketEntEV_VEC_anglesNewAngle
        } 
        else { 
            
attach_view(idid
        } 
    } 
    return 
FMRES_IGNORED 


Last edited by Dare.Devil; 08-16-2014 at 09:36.
Dare.Devil is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 08-15-2014 , 11:23   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #2

Looks like bazooka_fixed it's not too fixed

PHP Code:
if (id || id >= sizeof user_control)
    return 
FMRES_IGNORED  

if (user_controll[id] > 0) {  
        new 
RocketEnt user_controll[id]  
        if (
is_valid_ent(RocketEnt)) {  
            new 
Float:Velocity[3]  
            
VelocityByAim(id500Velocity)  
            
entity_set_vector(RocketEntEV_VEC_velocityVelocity)  
            new 
Float:NewAngle[3]  
            
entity_get_vector(idEV_VEC_v_angleNewAngle)  
            
entity_set_vector(RocketEntEV_VEC_anglesNewAngle)  
        }  
        else {  
            
attach_view(idid)  
        }  
    }  
    return 
FMRES_IGNORED  

__________________
Hey ^_^
NikKOo31 is offline
Dare.Devil
Member
Join Date: May 2014
Old 08-16-2014 , 09:38   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #3

Quote:
Originally Posted by NikKOo31 View Post
Looks like bazooka_fixed it's not too fixed
thanks that's very helpful

someone please advise how to fix

Last edited by Dare.Devil; 08-16-2014 at 09:42.
Dare.Devil is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 08-16-2014 , 11:20   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #4

Quote:
Originally Posted by Dare.Devil View Post
thanks that's very helpful

someone please advise how to fix
Read the code I posted -.- I added

PHP Code:
if (id || id >= sizeof user_control
    return 
FMRES_IGNORED 
It's not the better way, but will stop the index out of bounds
__________________
Hey ^_^
NikKOo31 is offline
Dare.Devil
Member
Join Date: May 2014
Old 08-16-2014 , 15:43   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #5

Quote:
Originally Posted by NikKOo31 View Post
Read the code I posted -.- I added

PHP Code:
if (id || id >= sizeof user_control
    return 
FMRES_IGNORED 
It's not the better way, but will stop the index out of bounds
yes at first it didn't work and gave error & fails to compile.. says unknown symbol user_control..

Then I thought for some reason the amx studio wants another l in the word "control" so now in it's spelled "controll"

it looks like below now and compiled successfully

PHP Code:
if (id || id >= sizeof user_controll
    return 
FMRES_IGNORED 
thx nikko hope it works.. I've attached the full .sma file for u guys to have a look at if u want
Attached Files
File Type: sma Get Plugin or Get Source (bazooka_fixed.sma - 602 views - 58.2 KB)
Dare.Devil is offline
Dare.Devil
Member
Join Date: May 2014
Old 08-16-2014 , 16:29   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #6

now here's another error that comes up

L 08/16/2014 - 221:01: [AMXX] Displaying debug trace (plugin "bazooka_fixed.amxx")
L 08/16/2014 - 221:01: [AMXX] Run time error 10: native error (native "cs_get_user_plant")
L 08/16/2014 - 221:01: [AMXX] [0] bazooka_fixed.sma::client_disconnect (line 395)

anyone help please?!
PHP Code:
public client_disconnect(id) {
/* Notes:
i now think that using switch_hands() here is too late to
put the player's cl_righthand cvar back to normal

I think i need to find an event that happens just before the player dc's
*/
    
ammo_hud(id0)
    if (
get_cvar_num("amx_bazooka_autohands") == 1) {
        
switch_hands(id,0)
    }
    
Munni[id] = 0
    user_controll
[id] = 0
    hasBazooka
[id] = false
    
if ((cs_get_user_plant(id) == 1) || cantswitch) {
        
cs_set_user_plant(id,0,0)
        
cantswitch  false
        
//if this person had the bomb out and dc'ed then the other players can now access the bomb
    
}

Dare.Devil is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 08-16-2014 , 12:13   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #7

could you please show me where user_controll is declared?
new user_controll or whatever
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-16-2014 , 12:44   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #8

It just has to have 33 cells and the id couldn't outbound it if id is a connected user (which is also important check).
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-17-2014 , 18:11   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #9

What about posting the whole plugin?
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Dare.Devil
Member
Join Date: May 2014
Old 08-18-2014 , 01:31   Re: [FIX REQ] Bazooka plugin error
Reply With Quote #10

Quote:
Originally Posted by claudiuhks View Post
What about posting the whole plugin?
I already did in one of my posts before..
I'll post it in attachments again and here's the full PHP below

PHP Code:
/* AMX Mod X script

:: Bazooka ::

Commands:

amx_bazooka | spawn a bazooka in front of you (works in spectator mode too, admin only)

amx_bazooka_give <@all or name/id> <amount> | give someone a bazooka (admin only)

amx_bazooka_startarena <mode restrictions> <round restart 1|0> | start the bazooka arena (admin only)

amx_bazooka_endarena <set ammo> | specify new ammo for everyone and end bazooka arena (set to -1 to leave everyone's ammo alone, admin only)

Say buybazooka in chat to open a buy menu. (everyone)

Say bazookahelp in chat to open the help file. (everyone)

Cvars:

amx_bazooka_dropping :: can a player drop his bazooka?? (default: 1)

amx_bazooka_ammo :: how much ammo has the bazooka?? (default: 3)

amx_bazooka_arena :: If set to 1 every player will recieve a bazooka with unlimited ammo
at the start of the next round. While this mode is activated it requires
a direct hit to kill someone. It is also advisable to restrict the other modes.

amx_bazooka_cost :: how much does the bazooka cost to buy it? (default: 8000)

amx_bazooka_buyable :: is it possible to buy the bazooka? (default: 1)

amx_bazooka_damageradius :: How big the damage radius is (default: 250)

amx_bazooka_maxdamage :: when you are in the center, how much HP do you lose? (default: 150)

amx_bazooka_restrict :: resrict certain modes: a = Normal, b = Heat-Seeking, c = User-Guided, d = No restrictions

amx_bazooka_reloadtime :: how much time (in seconds) it takes to reload the bazooka (default: 2.5)

amx_bazooka_trailtime :: How long the bazooka trails stay in the air (best at 30)

amx_bazooka_velocity :: This only affects how fast the heat-seeking and normal rockets go (best at 700)

amx_bazooka_teamcolors :: set to 1 to use team colors (CT = blue, T = red) or set to 2 to have random colors

amx_bazooka_gib :: set to 1 to cause gib explosion if the damage is > 100 and also enough to kill the person

Special thanks to:

-=STN=- MaGe
KaOs
RadidEskimo
Freecode
EJL
JTP10181
PaintLancer
Kaddar
Vexd
twistedeuphoria
XxAvalanchexX
pimp daddy
Ronkkrop
More for making the original bazooka plugin
mike_cao for his awesome gore plugin
BAILOPAN

Notes:
1. From what i've tested on my server people seem to like team colors better than random colors.
2. I've bound some keys to bazooka arena like so:
bind "PGDN" "amx_bazooka_arena 0;amx_bazooka_maxdamage 150;amx_bazooka_damageradius 250;amx_bazooka_restrict 1;sv_gravity 800;amx_say Bazooka Arena OFF"
bind "PGUP" "amx_bazooka_arena 1;amx_bazooka_maxdamage 999999;amx_bazooka_damageradius 40;amx_bazooka_restrict 1;sv_gravity 150;amx_bazooka_give @all 1;amx_say Bazooka Arena ON;amx_say say 'bazookahelp' for more information on Bazookas"
3. When you have Bazooka arena enabled it's fun to change the reload times.
Skill mode: reloadtime is 2.5
Rapid Fire mode: reloadtime is 0
This has gotten good feedback on my test server.
4. people are intrigued by a bazooka in CS 1.6, advertise this in your server name.
*/

// Set this value to 1 if you are using Condition Zero
// I have NOT tested this plugin with CZ so I do not know if it will work
//this switch was part of Mike Cao's Gore plugin
//I believe it makes sure that the correct sprite indexes are used
#define CZERO 0


#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <fun>
#include <cstrike>
#include <amxmisc>
#include <entity_maths> //this has the function for the "heat-seeking" rockets

#define TE_EXPLOSION         3
#define TE_EXPLFLAG_NONE     0
#define TE_SMOKE         5
#define TE_BLOODSPRITE        115
#define    TE_BLOODSTREAM        101
#define TE_MODEL        106
#define TE_WORLDDECAL        116
#define BA_NORMAL         (1<<0) // "a"
#define BA_HEAT             (1<<1) // "b"
#define BA_USER             (1<<2) // "c"
#define SEQ_IDLE         0
#define SEQ_FIDGET         1
#define SEQ_RELOAD         2
#define SEQ_FIRE         3
#define BAZOOKA_MENUKEYS (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)



new g_sModelIndexFireballg_sModelIndexSmokerocketsmoke
new bool:CanShoot[32], Munni[32], mode[32], bool:allow_shootinguser_controll[32], bool:hasBazooka[32]
new 
mdl_gib_fleshmdl_gib_headmdl_gib_legbonemdl_gib_lungmdl_gib_meatmdl_gib_spinespr_blood_dropspr_blood_spray
new gHealthIndex[33], bool:cantplantbombbool:cantswitchiFlagsmodetext[32]
new 
hand[33],newhand[33],bazookamenu,seq_animation[32]

public 
plugin_init() {
    
register_plugin("BazookaAdvanced""1.3c""Major Victory")
    
register_concmd("amx_bazooka""drop_rpg"ADMIN_LEVEL_A)
    
register_concmd("amx_bazooka_give""cmdBazooka_give"ADMIN_LEVEL_A"<@all or name/id> <amount>")
    
register_concmd("amx_bazooka_startarena""cmdBazooka_StartArena"ADMIN_LEVEL_A"<mode restrictions> <restart time, 0 = no restart>")

    
register_concmd("amx_bazooka_endarena""cmdBazooka_EndArena"ADMIN_LEVEL_A"<set ammo>")
    
    
register_cvar("amx_bazooka_dropping""1")// can a player drop a bazooka
    
register_cvar("amx_bazooka_ammo""1")// how much ammo per bazooka
    
register_cvar("amx_bazooka_damageradius""250"//NOTE: damagradius is not affected by walls
    
register_cvar("amx_bazooka_maxdamage""150")
    
register_cvar("amx_bazooka_cost""2500")// how much one bazooka costs
    
register_cvar("amx_bazooka_arena""0")// requires direct hit to kill
    
register_cvar("amx_bazooka_buyable""1")//disables/enables the buy menu
    
register_cvar("amx_bazooka_restrict""bc"// a = Normal | b = Heat-Seeking | c = User-Guided | d = None
    
register_cvar("amx_bazooka_reloadtime""3.1")// in seconds
    
register_cvar("amx_bazooka_trailtime""30")// roughly 3 seconds
    
register_cvar("amx_bazooka_velocity""700"//I don't know the units for this, just try numbers
    
register_cvar("amx_bazooka_teamcolors""1")// 0 = white, 1 = team colors, 2 = random
    
register_cvar("amx_bazooka_gib""1")// set to 1 for gib deaths (may cause lag on slower computers)
    
register_cvar("amx_bazooka_autohands""1")// 1 = on, 0 = off
    //autohands is experimental, it makes the bazooka appear in the correct hand by setting the client's cl_righthand cvar
    
    
    //test cvars
    
register_cvar("amx_bazooka_menu4num""7"//set ammo amount for menuitem 4
    
    
    
register_clcmd("say""handle_say")
    
register_clcmd("say_team""handle_say")
    
    
register_event("DeathMsg""player_die""a")
    
register_event("CurWeapon""check_model""be")
    
register_event("TextMsg""bomb_msg""b""2=#C4_Plant_At_Bomb_Spot")
    
register_event("ResetHUD","event_respawn","be","1=1")  
    
register_logevent("round_end"2"1=Round_End")
    
register_logevent("round_start"2"1=Round_Start")
    
register_logevent("bombplant",3,"2=Planted_The_Bomb")
    
    
register_clcmd("drop""handle_drop")
    
    
register_forward(FM_PlayerPreThink"player_bazooka")
    
register_forward(FM_SetModel"forward_setmodel")
    
/***************************************/
    //register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
    /***************************************/

    
bazookamenu menu_create("Bazooka Menu""do_bazookamenu")
    
menu_additem(bazookamenu"Buy Bazooka""1"ADMIN_ALL)
    
menu_additem(bazookamenu"Buy 2 Rockets""2"ADMIN_ALL)
    
menu_additem(bazookamenu"Buy 3 Rockets""3"ADMIN_ALL)
    
menu_additem(bazookamenu"Temp""4"ADMIN_ALL)
    
/*Notes on Menu System:
    bazookamenu is the id of our custom menusystem
    by using menu_additem() I've added 3 entries to start with
    
    later in the Showmenu_Bazooka() function below I use the cvar
    amx_bazooka_menu4num to set the ammunition number in slot four,
    format the slot four text, find slot four's id,
    and then change the text in slot four
    hopefully this can be refined to make a dynamic menu system for admins
    */
}

public 
plugin_precache() {
    
precache_model("models/rpgrocket.mdl")
    
precache_model("models/w_rpg.mdl")
    
precache_model("models/v_rpg.mdl")
    
precache_model("models/p_rpg.mdl")
    
precache_sound("weapons/rocketfire1.wav")
    
precache_sound("items/gunpickup4.wav")
    
precache_sound("weapons/nuke_fly.wav")// <-- this is the only non-game sound file, make sure you have it
    
precache_sound("weapons/dryfire1.wav")
    
spr_blood_drop precache_model("sprites/blood.spr")
    
spr_blood_spray precache_model("sprites/bloodspray.spr")
    
mdl_gib_flesh precache_model("models/Fleshgibs.mdl")
    
mdl_gib_head precache_model("models/GIB_Skull.mdl")
    
mdl_gib_legbone precache_model("models/GIB_Legbone.mdl")
    
mdl_gib_lung precache_model("models/GIB_Lung.mdl")
    
mdl_gib_meat precache_model("models/GIB_B_Gib.mdl")
    
mdl_gib_spine precache_model("models/GIB_B_Bone.mdl")
    
g_sModelIndexFireball precache_model("sprites/zerogxplode.spr")
    
g_sModelIndexSmoke  precache_model("sprites/steam1.spr")
    
rocketsmoke precache_model("sprites/smoke.spr")
}
/*****************************
WIP commands Section
******************************/

//Notes:
//I'm trying to improve on the old menu system by allowing to buy ammo
//maybe in the future I could add sell?

//BCost = bazooka price
//ACost = rocket price, which is half of Bcost, or Bcost/2

//Buy Bazooka
// 1. Bazooka (BCost)
// 2. Buy 1 Rocket (ACost)
// 3. Buy 2 Rockets (ACost*2)
// 4. Buy 4 Rockets (ACost*4)

// 5. Sell 1 Rocket (ACost*0.75) -- prevents money gain
// 6. Sell 2 Rockets ((ACost*0.75)*2) -- same here

// 0. Exit

public Showmenu_Bazooka(id) {
    new 
menu_item4text[51], ammonummenu_item4id
    ammonum 
get_cvar_num("amx_bazooka_menu4num"//get the ammonum for slot 4
    
format(menu_item4text50,"Buy %i Rockets"ammonum//format text
    
menu_item4id menu_find_id(bazookamenu0MENU_KEY_4); //find the id for menuitem 4
    
menu_item_setname(bazookamenumenu_item4idmenu_item4text); //set the text
    
menu_display(id,bazookamenu,0//show the new menu
    //btw using menu_additem() here causes the menu to get bigger everytime the menu is called
    
    /*new MenuBody_b[256]
    new len = format(MenuBody_b, 255, "\yBuy Item^n^n")
    len = len + format(MenuBody_b[len], 255 - len, "\w1. Bazooka\R$%d^n", get_cvar_num("amx_bazooka_cost"))
    len = len + format(MenuBody_b[len], 255 - len, "^n\w0. Exit^n")
    register_menuid("Bazooka_Buymenu")
    show_menu(id, BAZOOKA_MENUKEYS, MenuBody_b, -1, "Bazooka Menu")*/
    
menu_display(id,bazookamenu,0)
    return 
PLUGIN_HANDLED
}

public 
do_bazookamenu(idMenuItem) {
    new 
szCommand[3],  AccesssCallbackBCostACost
    BCost 
get_cvar_num("amx_bazooka_cost"// explained in notes section
    
ACost BCost/2
    menu_item_getinfo
(MenuItemAccesssszCommand2__Callback)
    switch(
szCommand[0]) {
        case 
'-': {
            return 
PLUGIN_HANDLED
        
}
        case 
'1': {
            if (
cs_get_user_money(id) >= BCost && !hasBazooka[id]) {
                
give_item_bazooka(id,(Munni[id] + get_cvar_num("amx_bazooka_ammo")),1)
                
cs_set_user_money(idcs_get_user_money(id) - BCost)
                
client_print(idprint_chat"[Bazooka] You have successfully bought a bazooka!")
                
client_print(idprint_chat"[Bazooka] What are you going to do now!?")
            }
            if (
cs_get_user_money(id) < BCost) {
                
client_print(idprint_center"You need $%i to buy this"BCost)
            }
            if (
hasBazooka[id]) {
                
client_print(idprint_center"You already have a bazooka")
            }
        }
        case 
'2': {
            if (
cs_get_user_money(id) >= ACost*&& hasBazooka[id]) {
                
Munni[id] += 2
                cs_set_user_money
(idcs_get_user_money(id) - ACost*2)
                
client_print(idprint_chat"[Bazooka] You now have %i Rockets"Munni[id])
            }
            if (
cs_get_user_money(id) < ACost*2) {
                
client_print(idprint_center"You need $%i to buy this"ACost*2)
            }
            if (!
hasBazooka[id]) {
                
client_print(idprint_center"You can't buy ammo for a gun you don't have")
            }
        }
        case 
'3': {
            if (
cs_get_user_money(id) >= ACost*&& hasBazooka[id]) {
                
Munni[id] += 4
                cs_set_user_money
(idcs_get_user_money(id) - ACost*4)
                
client_print(idprint_chat"[Bazooka] You now have %i Rockets"Munni[id])
            }
            if (
cs_get_user_money(id) < ACost*4) {
                
client_print(idprint_center"You need %i dollars to buy this"ACost*4)
            }
            if (!
hasBazooka[id]) {
                
client_print(idprint_center"You can't buy ammo for a gun you don't have")
            }
        }
        case 
'4': {
            new 
addnum get_cvar_num("amx_bazooka_menu4num")
            if (
cs_get_user_money(id) >= ACost*addnum && hasBazooka[id]) {
                
Munni[id] += addnum
                cs_set_user_money
(idcs_get_user_money(id) - ACost*addnum)
                
client_print(idprint_chat"[Bazooka] You now have %i Rockets"Munni[id])
            }
            if (
cs_get_user_money(id) < ACost*addnum) {
                
client_print(idprint_center"You need %i dollars to buy this"ACost*4)
            }
            if (!
hasBazooka[id]) {
                
client_print(idprint_center"You can't buy ammo for a gun you don't have")
            }
        }
    }
    return 
PLUGIN_HANDLED
}

/*****************************
End of WIP Commands Section
******************************/

public bomb_msg(id) {
    if (
cs_get_user_plant(id) != 1)
        
client_print(id,print_center,"")
}

public 
bombplant() {    
    
cantplantbomb true //now noone can plant the bomb
}

public 
round_end() {
    
set_task(4.8"round_prestart")
    
set_task(5.0"player_spawn")
    
//set_task(5.2, "bazooka_arena")
    //placing the bazooka_arena task here caused some timing issues
}

public 
round_prestart() {
    
allow_shooting false
    cantplantbomb 
true
    cantswitch 
true
}

public 
round_start() {
    
allow_shooting true
    cantplantbomb 
false
    cantswitch 
false
    
if (get_cvar_num("amx_bazooka_arena") == 1) {
        
set_task(0.1"bazooka_arena")
        
//the bazooka_arena task gets more accurately here
    
}
}

//this gets rid of the backpack model for bomb carriers, i left it in for reference
/*public forward_setmodel(entity, model[]) {
    if (!is_valid_ent(entity)) {
        return FMRES_IGNORED
    }
    if (equal(model, "models/w_backpack.mdl")) {
        client_print(0, print_center, "")
        new ClassName[32]
        entity_get_string(entity, EV_SZ_classname, ClassName, 31)
        
        if (equal(ClassName, "weaponbox")) {
            
            remove_entity(entity)
            
            return FMRES_SUPERCEDE
        }
    }
    return FMRES_IGNORED
}*/

//this replaces the dropped bomb model with the rpg model
public forward_setmodel(entity model[]) { 
    if(!
is_valid_ent(entity)) { 
        return 
FMRES_IGNORED
    } 
    if(
equali(model "models/w_c4.mdl")) { 
        
entity_set_model(entity "models/w_rpg.mdl"); 
        return 
FMRES_SUPERCEDE
    } 
    return 
FMRES_IGNORED


public 
client_disconnect(id) {
/* Notes:
i now think that using switch_hands() here is too late to
put the player's cl_righthand cvar back to normal

I think i need to find an event that happens just before the player dc's
*/
    
ammo_hud(id0)
    if (
get_cvar_num("amx_bazooka_autohands") == 1) {
        
switch_hands(id,0)
    }
    
Munni[id] = 0
    user_controll
[id] = 0
    hasBazooka
[id] = false
    
if (cantswitch) {  
        
cantswitch  false  
    

}

public 
client_connect(id) {
    
CanShoot[id] = true
    Munni
[id] = 0
    mode
[id] = 1
    modetext
[id] = 1
    hasBazooka
[id] = false
    
//required information for the switch_hands() function
    //go see the function for notes on its use
    
hand[id] = get_cvar_num("cl_righthand")
    if (
hand[id]==1) {
            
newhand[id] = 0
    
}
    else if (
hand[id]==0) {
            
newhand[id] = 1
    
}
}

public 
player_die(id) {
    new 
victim
    victim 
read_data(2)
    
ammo_hud(victim0)
    if (
get_cvar_num("amx_bazooka_autohands") == 1) {
        
switch_hands(victim,0)
        
//set their "hands" back to normal
    
}
    
Munni[victim] = 0
    user_controll
[victim] = 0
    hasBazooka
[victim] = false
    
if ((cs_get_user_plant(victim) == 1) || cantswitch) {
        
cs_set_user_plant(victim,0,0)
        
cantswitch  false
        
//if they had c4 out and died, reenable c4 for other players
    
}
}

public 
player_spawn() {
    new 
players[32], count
    get_players
(playerscount)
    for (new 
0counti++) {
        if (
is_user_alive(players[i])) {
            new 
v_oldmodel[64], p_oldmodel[64]
            
entity_get_string(players[i], EV_SZ_viewmodelv_oldmodel63)
            
entity_get_string(players[i], EV_SZ_weaponmodelp_oldmodel63)
            if (
equal(v_oldmodel"models/v_rpg.mdl") || equal(p_oldmodel"models/p_rpg.mdl")) {
                if (!
hasBazooka[players[i]]) {
                    new 
weaponidclipammo
                    weaponid 
get_user_weapon(players[i], clipammo)
                    
                    new 
weaponname[64]
                    
get_weaponname(weaponidweaponname63)
                    
                    new 
v_model[64], p_model[64]
                    
format(v_model63"%s"weaponname)
                    
format(p_model63"%s"weaponname)
                    
                    
replace(v_model63"weapon_""v_")
                    
format(v_model63"models/%s.mdl"v_model)
                    
entity_set_string(players[i], EV_SZ_viewmodelv_model)
                    
                    
replace(p_model63"weapon_""p_")
                    
format(p_model63"models/%s.mdl"p_model)
                    
entity_set_string(players[i], EV_SZ_weaponmodelp_model)
                }
            }
        }
    }
    
    new 
TempRocket find_ent_by_class(-1"rpgrocket")
    while (
TempRocket 0) {
        
remove_entity(TempRocket)
        
TempRocket find_ent_by_class(TempRocket"rpgrocket")
    }
    
    new 
TempRPG find_ent_by_class(-1"rpg_temp")
    while (
TempRPG 0) {
        
remove_entity(TempRPG)
        
TempRPG find_ent_by_class(TempRPG"rpg_temp")
    }
    return 
PLUGIN_CONTINUE    
}

public 
cmdBazooka_StartArena(id,level,cid) {
    
/*Notes:
    client_print() functions with "//DEBUG INFO" directly before them
    are just that, debug info, they can be removed or commented when testing is done
    
    also this function could prolly stand to be cleaned up a bit
    a bit meaning alot :P
    */
    
if (!cmd_access(idlevelcid3)) {
        return 
PLUGIN_HANDLED
    
}
    
//DEBUG INFO
    //client_print(id, print_chat, "[Bazooka] cmdBazooka_StartArena has been called")
    
new arg[6],arg2[2],argument2,players[32], count
    read_argv
(1,arg,5)
    
read_argv(2,arg2,1)
    
argument2 str_to_num(arg2)
    
set_cvar_string("amx_bazooka_arena""1")
    
console_cmd(id"amx_bazooka_arena 1")
    
console_cmd(id"amx_bazooka_restrict %s",arg)
    
set_task(0.1"bazooka_arena")
    
get_players(playerscount)
    for (new 
0counti++) {
        
//nice little warning to the players
        
console_cmd(players[i],"spk ^"attention.explosion system activated^"")
    }
    if (
argument2 0) {
        
console_cmd(id"sv_restartround %s",argument2)
    }
    return 
PLUGIN_HANDLED
}

public 
cmdBazooka_EndArena(id,level,cid) {
    if (!
cmd_access(idlevelcid2)) {
        return 
PLUGIN_HANDLED
    
}
    
//DEBUG INFO
    //client_print(id, print_chat, "[Bazooka] cmdBazooka_EndArena has been called")
    
new arg[5],argument1,players[32], count
    read_argv
(1,arg,4)
    
argument1 str_to_num(arg)
    
console_cmd(id"amx_bazooka_arena 0")
    if (
argument1 >= 0) {
        
get_players(playerscount)
        for (new 
0counti++) {
            
Munni[players[i]] = argument1
            ammo_hud
(players[i], 0)
            
ammo_hud(players[i], 1)
            
//a double notice that Bazooka Arena is OFF
            //it's real easy to miss a text announcement in the heat of battle
            
client_print(players[i], print_chat"[Bazooka] Bazooka Arena has been turned OFF")
            
console_cmd(players[i],"spk ^"attention.explosion system deactivated^"")
        }
    }
    return 
PLUGIN_HANDLED
}

/*Notes:
Around here i was trying to make the rpg animations work
seq_animation[id] sets the animation sequence for a specific id
the animation numbers for the bazooka are listed as constants at
the top and are as follows:
SEQ_IDLE         0
SEQ_FIDGET         1
SEQ_RELOAD         2
SEQ_FIRE         3

i don't remember how well i got animations to work,
but i remember that at best, you had to be holding the
fire button for the fire animation to work
*/
public rpg_reloaddone(data[]) {
    
CanShoot[data[0]] = true
    seq_animation
[data[0]] = SEQ_IDLE
}

public 
rpg_reloadstart(data[]) {
    
seq_animation[data[0]] = SEQ_RELOAD
}

public 
fire_rocket(id) {
    
ammo_hud(id0)
    
ammo_hud(id1)
    
//those two functions above effectively refresh the custom hud info for the bazooka
    
CanShoot[id] = false
    seq_animation
[id] = SEQ_FIRE
    
new data[1]
    
data[0] = id
    
new rtime get_cvar_num("amx_bazooka_reloadtime")
    
//Note: since rtime must be a float i made the cvar a whole number for convienence
    //but then i added 0.0 to make it a float for later
    
if (cs_get_user_plant(id) != 1){ //if they DON'T have the bomb out
        
set_task((rtime+0.0), "rpg_reloaddone"id+9477data1//when can i shoot again?
        //set_task(0.0, "rpg_reloadstart", id+9478, data, 1) //start reload animation
        
if ((Munni[id] <= 0) && (get_cvar_num("amx_bazooka_arena") != 1)) {
            
//no ammo, do empty click
            
emit_sound(idCHAN_WEAPON"weapons/dryfire1.wav"VOL_NORMATTN_NORM0PITCH_NORM)
            return 
PLUGIN_HANDLED
        
}
        else {
            
//ammo, start up the math
            //don't touch most of this unless you know your vectors and ents
            
new Float:StartOrigin[3], Float:Angle[3]
            
            new 
PlayerOrigin[3]
            
get_user_origin(idPlayerOrigin1)
            
            
StartOrigin[0] = float(PlayerOrigin[0])
            
StartOrigin[1] = float(PlayerOrigin[1])
            
StartOrigin[2] = float(PlayerOrigin[2])
            
            
entity_get_vector(idEV_VEC_v_angleAngle)
            
Angle[0] = Angle[0] * -1.0
            
new RocketEnt create_entity("info_target")
            
entity_set_string(RocketEntEV_SZ_classname"rpgrocket")
            
entity_set_model(RocketEnt"models/rpgrocket.mdl")
            
entity_set_origin(RocketEntStartOrigin)
            
entity_set_vector(RocketEntEV_VEC_anglesAngle)
            
            new 
Float:MinBox[3] = {-1.0, -1.0, -1.0}
            new 
Float:MaxBox[3] = {1.01.01.0}
            
entity_set_vector(RocketEntEV_VEC_minsMinBox)
            
entity_set_vector(RocketEntEV_VEC_maxsMaxBox)
            
            
entity_set_int(RocketEntEV_INT_solid2)
            
entity_set_int(RocketEntEV_INT_movetype5)
            
entity_set_edict(RocketEntEV_ENT_ownerid)
            
            new 
Float:Velocity[3]
            new 
myvelocity get_cvar_num("amx_bazooka_velocity"//custom velocity
            
VelocityByAim(idmyvelocityVelocity)
            
entity_set_vector(RocketEntEV_VEC_velocityVelocity)
            
            
emit_sound(RocketEntCHAN_WEAPON"weapons/rocketfire1.wav"VOL_NORMATTN_NORM0PITCH_NORM)
            
emit_sound(RocketEntCHAN_VOICE"weapons/nuke_fly.wav"VOL_NORMATTN_NORM0PITCH_NORM)
            
            if (
get_cvar_num("amx_bazooka_arena") != 1) {
                
//if bazooka_arena is off then subtract from ammo
                //and refresh the custom hud
                
ammo_hud(id0)
                
Munni[id]--
                
ammo_hud(id1)
            }
            
//here we do the trail colors
            
new CsTeams:iTeam =cs_get_user_team(id)
            new 
trailtime =get_cvar_num("amx_bazooka_trailtime")
            new 
colorr =random_num(0,255)
            new 
colorg =random_num(0,255)
            new 
colorb =random_num(0,255)
            new 
colora =100+random_num(0,155)
            
//i've never seen a black smoke trail in CS, are they possible?...
            
if (get_cvar_num("amx_bazooka_teamcolors") == 0){ // white
                
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
                
write_byte(22)
                
write_short(RocketEnt)
                
write_short(rocketsmoke)
                
write_byte(trailtime)
                
write_byte(3)
                
write_byte(255)
                
write_byte(255)
                
write_byte(255)
                
write_byte(255)
                
message_end()
            }
            else if (
get_cvar_num("amx_bazooka_teamcolors") == 1) {
                switch(
iTeam) {
                    case 
CS_TEAM_T: { //if team T color=red
                        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
                        
write_byte(22)
                        
write_short(RocketEnt)
                        
write_short(rocketsmoke)
                        
write_byte(trailtime)
                        
write_byte(3)
                        
write_byte(255)
                        
write_byte(0)
                        
write_byte(0)
                        
write_byte(255)
                        
message_end() 
                    }
                    case 
CS_TEAM_CT: { // if team CT color=blue
                        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
                        
write_byte(22)
                        
write_short(RocketEnt)
                        
write_short(rocketsmoke)
                        
write_byte(trailtime)
                        
write_byte(3)
                        
write_byte(0)
                        
write_byte(0)
                        
write_byte(255)
                        
write_byte(255)
                        
message_end()
                    }
                }
            }
            else  if (
get_cvar_num("amx_bazooka_teamcolors") == 2){ // random colors anyone?
                
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
                
write_byte(22)
                
write_short(RocketEnt)
                
write_short(rocketsmoke)
                
write_byte(trailtime)
                
write_byte(3)
                
write_byte(colorr)
                
write_byte(colorg)
                
write_byte(colorb)
                
write_byte(colora)
                
message_end()
            }
            
            if (
mode[id] == 2) {
                
//mmmmm heat-seeking
                
new info[1]
                
info[0] = RocketEnt
                set_task
(1.0"find_and_follow"0info1)
            }
            else if (
mode[id] == 3) {
                
//user-guided
                
entity_set_int(RocketEntEV_INT_rendermode1)
                
attach_view(idRocketEnt)
                
user_controll[id] = RocketEnt
            

            return 
PLUGIN_HANDLED
        
}
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED
}

public 
find_and_follow(info[]) {
    new 
RocketEnt info[0]
    new 
Float:shortestDist 10000.0
    
new nearestPlayer 0
    
    
if (is_valid_ent(RocketEnt)) {
        new 
players[32], count
        get_players
(playerscount)
        for (new 
0counti++) {
            if (
is_user_alive(players[i]) && (entity_get_edict(RocketEntEV_ENT_owner) != players[i]) && (get_user_team(players[i]) != get_user_team(entity_get_edict(RocketEntEV_ENT_owner)))) {
                new 
Float:PlayerOrigin[3], Float:RocketOrigin[3]
                
entity_get_vector(players[i], EV_VEC_originPlayerOrigin)
                
entity_get_vector(RocketEntEV_VEC_originRocketOrigin)
                
                new 
Float:distance vector_distance(PlayerOriginRocketOrigin)
                
                if (
distance <= shortestDist) {
                    
shortestDist distance
                    nearestPlayer 
players[i]
                }
            }
        }
    }
    
    if (
nearestPlayer 0) {
        new 
data[2]
        
data[0] = RocketEnt
        data
[1] = nearestPlayer
        set_task
(0.1"follow_and_catch"RocketEntdata2"b")
    }
    else {
        
pfn_touch(RocketEnt0)
    }
}

public 
follow_and_catch(data[]) {
    new 
RocketEnt data[0]
    new 
target data[1]
    new 
myvelocity get_cvar_num("amx_bazooka_velocity")
    
    if (
is_user_alive(target) && is_valid_ent(RocketEnt)) {
        
entity_set_follow(RocketEnttarget, (myvelocity+0.0))
        
        new 
Float:Velocity[3]
        new 
Float:NewAngle[3]
        
entity_get_vector(RocketEntEV_VEC_velocityVelocity)
        
vector_to_angle(VelocityNewAngle)
        
entity_set_vector(RocketEntEV_VEC_anglesNewAngle)
    }
    else {
        
remove_task(RocketEnt)
        new 
info[1]
        
info[0] = RocketEnt
        set_task
(0.1"find_and_follow"0data1)
    }
}

public 
pfn_touch(ptrptd) {
    new 
ClassName[32]
    new 
ClassNameptd[32]
    
//here i grab the classname of each item for debugging and advanced collisions later
    
if ((ptr 0) && is_valid_ent(ptr)) {
        
entity_get_string(ptrEV_SZ_classnameClassName31)
    }
    if ((
ptd 0) && is_valid_ent(ptd)) {
        
entity_get_string(ptdEV_SZ_classnameClassNameptd31)
    }
    if (
equal(ClassName"rpgrocket")) {
        
remove_task(ptr)
        new 
Float:EndOrigin[3]//x,y,z
        
entity_get_vector(ptrEV_VEC_originEndOrigin)
        
        
message_beginMSG_BROADCASTSVC_TEMPENTITY)  // Explosion
        
write_byte(TE_EXPLOSION)
        
write_coord(floatround(EndOrigin[0]))
        
write_coord(floatround(EndOrigin[1]))
        
write_coord(floatround(EndOrigin[2])+5)
        
write_short(g_sModelIndexFireball)
        
write_byte(random_num(0,20) + 20)
        
write_byte(12// framerate
        
write_byte(TE_EXPLFLAG_NONE)
        
message_end()
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)  // Smoke
        
write_byte(TE_SMOKE)
        
write_coord(floatround(EndOrigin[0]))
        
write_coord(floatround(EndOrigin[1]))
        
write_coord(floatround(EndOrigin[2])+15)
        
write_short(g_sModelIndexSmoke)
        
write_byte(60)
        
write_byte(10)
        
message_end()
        
        
/*message_begin(MSG_BROADCAST,SVC_TEMPENTITY) // Explosion Decal
        write_byte(28) //grenade explotion mark
        write_coord(floatround(EndOrigin[0]))
        write_coord(floatround(EndOrigin[1]))
        write_coord(floatround(EndOrigin[2]))
        write_short(spr_blood_spray)
        write_short(spr_blood_drop)
        write_byte(229) // color index
        write_byte(15) // size
        message_end()*/
        
        
new maxdamage get_cvar_num("amx_bazooka_maxdamage")
        new 
damageradius get_cvar_num("amx_bazooka_damageradius")
        if (
equal(ClassNameptd"func_breakable")) {
            
//new Float:ptrhealth = entity_get_float(ptr,EV_FL_health);
            //new Float:ptdhealth = entity_get_float(ptd,EV_FL_health);
            //DEBUG INFO
            //client_print(0, print_console, "Entity ptr health is: %i",ptrhealth)
            //client_print(0, print_console, "Entity ptd health is: %i",ptdhealth)
            
            //entity_set_float(ptr,EV_FL_health,100.0); //i don't remember why this is here
            //the functions below break ANY breakables and kill the rocket
            //and when i say ANY breakables i mean ANY breakables
            //it will destroy even trigger only breakables, bad for mapmakers
            
force_use(ptr,ptd)
            
remove_task(ptr)
        }
        
/*Notes: Here i tried to make it so that if a breakable entity was within the damage
        radius it would recieve it's share of damage
        this is very experimental as I couldn't get it to work after two or three days of tinkering
        */
        /*if (equal(ClassNameptd, "func_breakable")) {
            client_print(0, print_console, "got classname %s",ClassNameptd)
            new Float:orig1[3], origin1[3],NonFloatEndOrigin[3]
            entity_get_vector(ptd, EV_VEC_origin, orig1)
            for(new a = 0; a < 3; a++) {
                origin1[a] = floatround(orig1[a])
            }
            for(new a = 0; a < 3; a++) {
                NonFloatEndOrigin[a] = floatround(EndOrigin[a])
            }
            new ptddistance = get_distance(origin1, NonFloatEndOrigin)
            client_print(0, print_console, "got distance %i",ptddistance)
            if (ptddistance <= damageradius) {
                client_print(0, print_console, "is in damage radius")
                new damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(ptddistance), float(damageradius))))
                if (damage > 25) {
                    client_print(0, print_console, "damage > 25")
                    force_use(ptr,ptd)
                    remove_task(ptr)
                }
                    else {
                    client_print(0, print_console, "damage < 25")
                    remove_task(ptr)
                }
            }
            return PLUGIN_CONTINUE
        }*/
        
        
new PlayerPos[3], distancedamage
        
for (new 132i++) {
            if (
is_user_alive(i) == 1) {
                
get_user_origin(iPlayerPos)
                
                new 
NonFloatEndOrigin[3]
                for(new 
03a++) {
                        
NonFloatEndOrigin[a] = floatround(EndOrigin[a])
                }
                
distance get_distance(PlayerPosNonFloatEndOrigin)
                if (
distance <= damageradius) {  // Screenshake Radius
                    
message_begin(MSG_ONEget_user_msgid("ScreenShake"), {0,0,0}, i)  // Shake Screen
                    
write_short(1<<14)
                    
write_short(1<<14)
                    
write_short(1<<14)
                    
message_end()
                    
                    
damage maxdamage floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))))
                    new 
attacker entity_get_edict(ptrEV_ENT_owner)
                    
                    if (!
get_user_godmode(i)) {
                        
                        if (
get_user_team(attacker) != get_user_team(i)) {
                            
                            if (
damage get_user_health(i)) {
                                
set_user_health(iget_user_health(i) - damage)
                            }
                            else {
                                
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
                                
user_kill(i1)
                                
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
                                
                                
message_begin(MSG_BROADCASTget_user_msgid("DeathMsg"))  // Kill-Log oben rechts
                                
write_byte(attacker)  // Attacker
                                
write_byte(i)  // Victim
                                
write_byte(0)  // Headshot
                                
write_string("bazooka")
                                
message_end()
                                if (
damage 100 && get_cvar_num("amx_bazooka_gib") == 1) { //begin gibs and effects (made by mike_cao)
                                    
new iOrigin[3]
                                    
get_user_origin(i,iOrigin// Effects
                                    
fx_trans(i,0)
                                    
fx_gib_explode(iOrigin,3)
                                    
fx_blood_large(iOrigin,5)
                                    
fx_blood_small(iOrigin,15)
                                    
iOrigin[2] = iOrigin[2]-20 // Hide body
                                    
set_user_origin(i,iOrigin)
                                } 
//end gibs and effects
                                
set_user_frags(attackerget_user_frags(attacker) + 1)
                                if (
get_cvar_num("amx_bazooka_gib") == 1) {
                                    
client_print(attackerprint_center"LOLERS! You just splattered that guy's guts everywhere!")
                                }
                                
                            }
                        }
                        if (
get_user_team(attacker) == get_user_team(i)) {
                            
                            if (
attacker == i) {
                                
                                if (
damage get_user_health(i)) {
                                    
set_user_health(iget_user_health(i) - damage)
                                }
                                else {
                                    
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
                                    
user_kill(i1)
                                    
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
                                    
                                    
message_begin(MSG_BROADCASTget_user_msgid("DeathMsg")) // Kill-Log oben rechts
                                    
write_byte(attacker)  // Attacker
                                    
write_byte(i)  // Victim
                                    
write_byte(0)  // Headshot
                                    
write_string("bazooka")
                                    
message_end()
                                    if ((
damage 100) && get_cvar_num("amx_bazooka_gib") == 1) { //begin gibs and effects (made by mike_cao)
                                        
new iOrigin[3]
                                        
get_user_origin(i,iOrigin)// Effects
                                        
fx_trans(i,0)
                                        
fx_gib_explode(iOrigin,3)
                                        
fx_blood_large(iOrigin,5)
                                        
fx_blood_small(iOrigin,15)
                                        
iOrigin[2] = iOrigin[2]-20 // Hide body
                                        
set_user_origin(i,iOrigin)
                                    } 
//end gibs and effects
                                    
set_user_frags(attackerget_user_frags(attacker) - 1)
                                    if (
get_cvar_num("amx_bazooka_gib") == 1){
                                        
client_print(attackerprint_center"Great! Now everyone knows what you had for supper!")
                                    }
                                    else {
                                        
client_print(attackerprint_center"You do know this thing explodes right?")
                                    }
                                    
                                }
                            }
                            else {
                                if (
get_cvar_num("mp_friendlyfire")) {
                                    if (
damage get_user_health(i)) {
                                        
set_user_health(iget_user_health(i) - damage)
                                        
client_print(attackerprint_center"You injured a teammate! Watch your aim!")
                                    }
                                    else {
                                        
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
                                        
user_kill(i1)
                                        
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
                                        
                                        
message_begin(MSG_BROADCASTget_user_msgid("DeathMsg"))  // Kill-Log oben rechts
                                        
write_byte(attacker)  // Attacker                                        write_byte(i)  // Victim
                                        
write_byte(0)  // Headshot
                                        
write_string("bazooka")
                                        
message_end()
                                        if (
damage 100 && get_cvar_num("amx_bazooka_gib") == 1) { //begin gibs and effects (made by mike_cao)
                                            
new iOrigin[3]
                                            
get_user_origin(i,iOrigin)// Effects
                                            
fx_trans(i,0)
                                            
fx_gib_explode(iOrigin,3)
                                            
fx_blood_large(iOrigin,5)
                                            
fx_blood_small(iOrigin,15)
                                            
iOrigin[2] = iOrigin[2]-20 // Hide body
                                            
set_user_origin(i,iOrigin)
                                        } 
//end gibs and effects
                                        
set_user_frags(attackerget_user_frags(attacker) - 1)
                                        if (
get_cvar_num("amx_bazooka_gib") == 1){
                                            
client_print(attackerprint_center"OMFG's!! You just splattered a teammate!")
                                        }
                                        else{
                                            
client_print(attackerprint_center"LOL! That teammate is probably not too happy now!")
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        
attach_view(entity_get_edict(ptrEV_ENT_owner), entity_get_edict(ptrEV_ENT_owner))
        
user_controll[entity_get_edict(ptrEV_ENT_owner)] = 0
        remove_entity
(ptr)
    }
    
    
    if (
equal(ClassName"rpg") || equal(ClassName"rpg_temp")) {
        new 
Picker[32]
        if ((
ptd 0) && is_valid_ent(ptd)) {
            
entity_get_string(ptdEV_SZ_classnamePicker31)
        } 
        if (
equal(Picker"player")) {
            
give_item_bazooka(ptd,(Munni[ptd] + entity_get_int(ptrEV_INT_iuser1)),1)
            
client_print(ptdprint_chat"[Bazooka] You have picked up a bazooka!")
            
remove_entity(ptr)
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
drop_rpg(idlevelcid) {
    if (!
cmd_access(idlevelcid1)) {
        return 
PLUGIN_HANDLED
    
}    
    new 
Float:PlayerOrigin[3], Float:End[3], Float:Return[3], Float:TraceDirection[3]
    
entity_get_vector(idEV_VEC_originPlayerOrigin)
    
VelocityByAim(id64TraceDirection)
    
    
End[0] = TraceDirection[0] + PlayerOrigin[0]
    
End[1] = TraceDirection[1] + PlayerOrigin[1]
    
End[2] = TraceDirection[2] + PlayerOrigin[2]
    
    
trace_line(idPlayerOriginEnd, Return)
    Return[
2] = PlayerOrigin[2]
    
    new 
RPG create_entity("info_target")
    
entity_set_string(RPGEV_SZ_classname"rpg")
    
entity_set_model(RPG"models/w_rpg.mdl")
    
entity_set_origin(RPG, Return)
    
    new 
Float:MinBox[3] = {-16.0, -16.00.0}
    new 
Float:MaxBox[3] = {16.016.016.0}
    
entity_set_vector(RPGEV_VEC_minsMinBox)
    
entity_set_vector(RPGEV_VEC_maxsMaxBox)
    
    
entity_set_int(RPGEV_INT_solid1)
    
entity_set_int(RPGEV_INT_movetype6)
    
    
entity_set_int(RPGEV_INT_iuser1get_cvar_num("amx_bazooka_ammo"))
    
    return 
PLUGIN_HANDLED
}
/*Notes:
DON'T SCREW WITH THE MODES. PERIOD!

It took me hours to figure out the logic for each action and make it work.
the modes as they are allow only one player at a time to access the c4
and will also force a player to move to the next mode if the one they are on is restricted
which can happen if the admin changes restrictions during gameplay
*/

public player_bazooka(id) {
    if (
is_user_alive(id)) {
        new 
weaponidclipammo
        weaponid 
get_user_weapon(idclipammo)
        if ((
weaponid == CSW_C4) && hasBazooka[id]) {
            
set_animation(id,seq_animation[id])
            new 
attack get_user_button(id) & IN_ATTACK
            
new oldattack get_user_oldbutton(id) & IN_ATTACK
            
new attack2 get_user_button(id) & IN_ATTACK2
            
new oldattack2 get_user_oldbutton(id) & IN_ATTACK2
            
new CsTeams:iTeam cs_get_user_team(id)
            if (
attack && !oldattack  && (cs_get_user_plant(id) != 1)) {
                
get_restrict_flags()
                if (
mode[id] == && iFlags&BA_NORMAL) {
                    
client_print(idprint_center"You cannot fire a restricted mode")
                    
client_cmd(id,"+attack2;wait;-attack2")
                }
                else if (
mode[id] == && iFlags&BA_HEAT) {
                    
client_print(idprint_center"You cannot fire a restricted mode")
                    
client_cmd(id,"+attack2;wait;-attack2")
                }
                else if (
mode[id] == && iFlags&BA_USER) {
                    
client_print(idprint_center"You cannot fire a restricted mode")
                    
client_cmd(id,"+attack2;wait;-attack2")
                }
                else if (
mode[id] == && iTeam&CS_TEAM_CT) {
                    
client_print(idprint_center"You cannot plant a bomb!")
                    
client_cmd(id,"+attack2;wait;-attack2")
                }
                else {
                    if (
CanShoot[id] && allow_shooting && (user_controll[id] == 0)) {
                        
fire_rocket(id)
                        
                    }
                }
                
            }
            else if (
attack2 && !oldattack2) {
                
check_model(id)
                switch(
mode[id]) {
                    case 
1: {
                        
get_restrict_flags()
                        if ((
iFlags&BA_HEAT) != BA_HEAT) {
                            
mode[id] = 2
                            modetext
[id] = 2
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
emit_sound(idCHAN_WEAPON"items/nvg_on.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"Heat-Seeking Mode")
                        }
                        else if ((
iFlags&BA_USER) != BA_USER) {
                            
mode[id] = 3
                            modetext
[id] = 3                            
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
emit_sound(idCHAN_WEAPON"items/gunpickup4.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"User-Guided Mode")
                        }
                        else {
                            if (!
cantplantbomb && !cantswitch && iTeam&CS_TEAM_T) {
                                
cantswitch true
                                mode
[id] = 4
                                modetext
[id] = 4                            
                                ammo_hud
(id0)
                                
ammo_hud(id1)
                                
cs_set_user_plant(id,1,1)
                                
check_model(id)
                                
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                                
client_print(idprint_center"Switching to C4 Bomb")
                            }
                            else if (
cantplantbomb || cantswitch || iTeam&CS_TEAM_CT){
                                
mode[id] = 1
                                modetext
[id] = 1
                                ammo_hud
(id0)
                                
ammo_hud(id1)
                                
check_model(id)
                                
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                                
client_print(idprint_center"The other modes are restricted")
                            }
                        }
                    }
                    case 
2: {
                        
get_restrict_flags()
                        if ((
iFlags&BA_USER) != BA_USER) {
                            
mode[id] = 3
                            modetext
[id] = 3
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
emit_sound(idCHAN_WEAPON"items/gunpickup4.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"User-Guided Mode")
                        }
                        else if (
iFlags&BA_USER && ((iFlags&BA_NORMAL) != BA_NORMAL)) {
                            if (!
cantplantbomb && !cantswitch && iTeam&CS_TEAM_T) {
                                
cantswitch true
                                mode
[id] = 4
                                modetext
[id] = 4
                                ammo_hud
(id0)
                                
ammo_hud(id1)
                                
cs_set_user_plant(id,1,1)
                                
check_model(id)
                                
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                                
client_print(idprint_center"Switching to C4 Bomb")
                            }
                            else if (
cantplantbomb || cantswitch || iTeam&CS_TEAM_CT){
                                
mode[id] = 1
                                modetext
[id] = 1
                                ammo_hud
(id0)
                                
ammo_hud(id1)
                                
check_model(id)
                                
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                                
client_print(idprint_center"Normal Mode")
                            }
                        }
                        else {
                            
mode[id] = 2
                            modetext
[id] = 2
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"The other modes are restricted")
                        }
                    }
                    case 
3: {
                        
get_restrict_flags()
                        if ((
iFlags&BA_NORMAL) != BA_NORMAL) {
                            if (!
cantplantbomb && !cantswitch && iTeam&CS_TEAM_T) {
                                
cantswitch true
                                mode
[id] = 4
                                modetext
[id] = 4
                                ammo_hud
(id0)
                                
ammo_hud(id1)
                                
cs_set_user_plant(id,1,1)
                                
check_model(id)
                                
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                                
client_print(idprint_center"Switching to C4 Bomb")
                            }
                            else if (
cantplantbomb || cantswitch || iTeam&CS_TEAM_CT){
                                
mode[id] = 1
                                modetext
[id] = 1
                                ammo_hud
(id0)
                                
ammo_hud(id1)
                                
check_model(id)
                                
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                                
client_print(idprint_center"Normal Mode")
                            }
                        }
                        else if ((
iFlags&BA_HEAT) != BA_HEAT){
                            
mode[id] = 2
                            modetext
[id] = 2
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
emit_sound(idCHAN_WEAPON"items/nvg_on.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"Heat-Seeking Mode")
                        }
                        else {
                            
mode[id] = 3
                            modetext
[id] = 3
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"The other modes are restricted")
                        }
                    }
                    case 
4: {
                        
get_restrict_flags()
                        if ((
iFlags&BA_NORMAL) != BA_NORMAL) {
                            
cantswitch false
                            mode
[id] = 1
                            modetext
[id] = 1
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
cs_set_user_plant(id,0,0)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"Switching to Bazooka")    
                        }
                        else if ((
iFlags&BA_HEAT) != BA_HEAT) {
                            
cantswitch false
                            mode
[id] = 2
                            modetext
[id] = 2
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
cs_set_user_plant(id,0,0)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
emit_sound(idCHAN_WEAPON"items/nvg_on.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"Heat-Seeking Mode")
                        }
                        else if ((
iFlags&BA_USER) != BA_USER) {
                            
cantswitch false
                            mode
[id] = 3
                            modetext
[id] = 3
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
cs_set_user_plant(id,0,0)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
emit_sound(idCHAN_WEAPON"items/gunpickup4.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"User-Guided Mode")
                        }
                        else {
                            
cantswitch true
                            mode
[id] = 4
                            modetext
[id] = 4
                            ammo_hud
(id0)
                            
ammo_hud(id1)
                            
cs_set_user_plant(id,1,1)
                            
check_model(id)
                            
emit_sound(idCHAN_ITEM"common/wpn_select.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                            
client_print(idprint_center"The other modes are restricted")
                        }
                    }
                }
            }
        }    
    }    
    if (
id || id >= sizeof user_controll
return 
FMRES_IGNORED 
    
if (user_controll[id] > 0) {
        new 
RocketEnt user_controll[id]
        if (
is_valid_ent(RocketEnt)) {
            new 
Float:Velocity[3]
            
VelocityByAim(id500Velocity)
            
entity_set_vector(RocketEntEV_VEC_velocityVelocity)
            new 
Float:NewAngle[3]
            
entity_get_vector(idEV_VEC_v_angleNewAngle)
            
entity_set_vector(RocketEntEV_VEC_anglesNewAngle)
        }
        else {
            
attach_view(idid)
        }
    }
    return 
FMRES_IGNORED
}
/*Notes
in version 1.3c this function spawned both an rpg and a bomb upon dropping the bazooka,
in version 1.3d i cleaned it up and hopefully fixed this error
...i think i only cleaned it up, will test later...
*/
public handle_drop(id) {
    new 
weaponidclipammo
    weaponid 
get_user_weapon(idclipammo)
    if (
weaponid == CSW_C4 && cs_set_user_plant(id,0,0)) {
        if (
get_cvar_num("amx_bazooka_dropping") == 1) {
            
drop_rpg_temp(id)
            if (
get_cvar_num("amx_bazooka_autohands") == 1) {
                
switch_hands(id,0)
            }
        }
        else {
            
client_print(idprint_center"This weapon cannot be dropped")
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE
}

public 
drop_rpg_temp(id) {
    
    new 
Float:PlayerOrigin[3], Float:End[3], Float:Return[3], Float:TraceDirection[3], Float:Angles[3]
    
entity_get_vector(idEV_VEC_originPlayerOrigin)
    
entity_get_vector(idEV_VEC_anglesAngles)
    
VelocityByAim(id200TraceDirection)
    
    
End[0] = TraceDirection[0] + PlayerOrigin[0]
    
End[1] = TraceDirection[1] + PlayerOrigin[1]
    
End[2] = TraceDirection[2] + PlayerOrigin[2]
    
    
trace_line(idPlayerOriginEnd, Return)
    Return[
2] = PlayerOrigin[2]
    
    new 
RPG create_entity("info_target")
    
entity_set_string(RPGEV_SZ_classname"rpg_temp")
    
entity_set_model(RPG"models/w_rpg.mdl")
    
entity_set_origin(RPG, Return)
    
    
Angles[0] = 0.0
    Angles
[2] = 0.0
    
    entity_set_vector
(RPGEV_VEC_anglesAngles)
    
    new 
Float:MinBox[3] = {-16.0, -16.00.0}
    new 
Float:MaxBox[3] = {16.016.016.0}
    
entity_set_vector(RPGEV_VEC_minsMinBox)
    
entity_set_vector(RPGEV_VEC_maxsMaxBox)
    
    
entity_set_int(RPGEV_INT_solid1)
    
entity_set_int(RPGEV_INT_movetype6)
    
    
entity_set_int(RPGEV_INT_iuser1Munni[id])
    
    
Munni[id] = 0
    hasBazooka
[id] = false
    
    
return PLUGIN_HANDLED
}

public 
handle_say(id) {
    new 
command[32]
    
read_argv(1command31)
    
    if (
equal(command"buybazooka")) {
        if (
is_user_alive(id)) {
            if (
get_cvar_num("amx_bazooka_buyable") == 1) {
                
Showmenu_Bazooka(id)
            }
            else {
                
client_print(idprint_chat"[Bazooka] The buymenu is disabled!")
            }
        }
        else {
            
client_print(idprint_chat"[Bazooka] You cannot buy a Bazooka while you are dead!")
        }
    }
    if (
equal(command"bazookahelp"))
        {
        
// Display Help File from amxx/configs/bazooka_help.htm
        
new szHelpFile[64], szCustomDir[32]
        
//i think get_customdir() has been depreciated, not sure though...
        
get_customdirszCustomDir31 )
        
formatszHelpFile63"%s/bazooka_help.htm"szCustomDir )
        
show_motdidszHelpFile"Bazooka - Help" )
        return 
PLUGIN_CONTINUE
    
}
    
    return 
PLUGIN_HANDLED
}

public 
cmdBazooka_give(idlevelcid) {
    if (!
cmd_access(idlevelcid3)) {
        return 
PLUGIN_HANDLED
    
}
    
    new 
arg[32], arg2[8], name2[32], ammo,argument2
    ammo
=get_cvar_num("amx_bazooka_ammo")
    
read_argv(1,arg,31)
    
read_argv(2,arg2,7)
    
argument2 str_to_num(arg2)
    if ( 
equali(arg,"@all") )
        {
        new 
plist[32],pnum
        get_players
(plist,pnum,"a")
        if (
pnum==0)
            {
            
console_print(id,"[Bazooka] This client is invalid")
            return 
PLUGIN_HANDLED
        
}
        for (new 
i=0i<pnumi++)
            {
            
give_item_bazooka(plist[i],(argument2*ammo),1)
            
client_print(plist[i], print_chat"[Bazooka] The Admin gave you a bazooka with %d rockets!",argument2*ammo)
            
client_print(plist[i], print_chat"[Bazooka] Switch to the bomb weapon or weapon slot 5 to use it")
            
console_print(id,"[Bazooka] Gave all players bazookas with %d rockets",argument2*ammo)
        }
    }
    else
    {
        
get_user_name(id,name2,31)
        new 
player cmd_target(id,arg,7)
        if (!
player)
            {
            
console_print(id,"[Bazooka] Give Bazooka Failed"
            return 
PLUGIN_HANDLED
        
}
        new 
name[32]
        
get_user_name(player,name,31)
        
give_item_bazooka(player,(argument2*ammo),1)
        
console_print(id,"[Bazooka] Gave %s %d Bazookas",name,argument2*ammo)
        
client_print(playerprint_chat"[Bazooka] The Admin gave you a bazooka with %d rockets!",argument2*ammo)
        
client_print(playerprint_chat"[Bazooka] Switch to the bomb weapon or weapon slot 5 to use it.")
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED
}

public 
bazooka_arena(id) {
    if (
get_cvar_num("amx_bazooka_arena") == 1) {
        
//DEBUG INFO
        //client_print(id, print_chat, "[Bazooka] bazooka_arena has been called")
        //console_cmd(id ,"amx_bazooka_give @all 1")
        
console_cmd(id ,"amx_bazooka_damageradius 40")
        
console_cmd(id ,"amx_bazooka_maxdamage 999999")
        new 
players[32], count
        get_players
(playerscount)
        for (new 
0counti++) {
            
give_item_bazooka(players[i],1,1)
            
client_print(players[i], print_chat"[Bazooka] Bazooka Arena is ON! say ^"bazookahelp^" for more info")
            
client_print(players[i], print_center"Time to make things go BOOM!")
        }
    }
    
    return 
PLUGIN_HANDLED
}
//this function is more internal than external, it makes giving a bazooka happen in one line instead of 15
public give_item_bazooka(id,ammo,sound) {
    
give_item(id"weapon_c4"// give actual weapon
    
hasBazooka[id] = true // the plugin now knows they have a bazooka
    
Munni[id] = ammo //set ammunition
    
CanShoot[id] = true // they can shoot now
    
cs_set_user_plant(id,0,0//they can't plant unless they switch to bomb
    
mode[id] = //mode = normal
    
modetext[id] = 1
    check_model
(id// refresh model
    
ammo_hud(id0)
    
ammo_hud(id1// refresh hud info
    
if (sound) {
        
//audio notification
        
emit_sound(idCHAN_ITEM"items/gunpickup2.wav"VOL_NORMATTN_NORM0PITCH_NORM)
    }
}

/*Notes:
This function is highly experimental too
It should allow the use of seq_animation[id] in place of the "anim" parameter
to set the current animation of a specific player.

The trick is getting the animation to cycle through the frames
and not stay on the first one in each animation
*/
set_animation(idanim) {
    
set_pev(idpev_weaponanimanim)
    
message_begin(MSG_ONESVC_WEAPONANIM, {000}, id)
    
write_byte(anim)
    
write_byte(pev(idpev_body))
    
message_end()
}

/*Notes:
This little functions switches the client's cl_righthand cvar
to make the bazooka appear in the correct hand

So far i've implemented it very well except for when a player disconnects
*/
switch_hands(id,mode) {
    if (
mode) {
        
client_cmd(id,"cl_righthand %i",newhand[id])
    }
    else {
        
client_cmd(id,"cl_righthand %i",hand[id])
    }
}

//Yay custom hud!
ammo_hud(idshow) {
    new 
AmmoHud[65],mode[20]
    if (
modetext[id] == 1) {
        
mode "Bazooka"
    
}
    else if (
modetext[id] == 2) {
        
mode "Heat-Seeking"
    
}
    else if (
modetext[id] == 3) {
        
mode "User-Guided"
    
}
    else if (
modetext[id] == 4) {
        
mode "C4"
    
}
    if (
get_cvar_num("amx_bazooka_arena") == 1) {
        
format(AmmoHud64"Rockets: Infinite | Mode: %s",mode)
    }
    else {
        
format(AmmoHud64"Rockets: %i | Mode: %s"Munni[id],mode)
    }
    
    if (
show) {
        
message_begin(MSG_ONEget_user_msgid("StatusText"), {0,0,0}, id)
        
write_byte(0)
        
write_string(AmmoHud)
        
message_end()
    }
    else {
        
message_begin(MSG_ONEget_user_msgid("StatusText"), {0,0,0}, id)
        
write_byte(0)
        
write_string("")
        
message_end()
    }
}

/*Notes:
I've seen this work on my computer 100% of the time,
but i've not been able to test it online or with multiple players

what this funtion does is check to see if the player has the bazooka weapon out
and then it changes the model accordingly, but if that weapon is not out then it
changes back to what it should be

This is also where switch_hands() is used a lot
*/
public check_model(id) {
    new 
weaponidclipammo
    
new CsTeams:iTeam cs_get_user_team(id)
    
weaponid get_user_weapon(idclipammo)
    if ((
weaponid == CSW_C4) && ((cs_get_user_plant(id) != 1) || (mode[id] != 4))) {
        if (
get_cvar_num("amx_bazooka_autohands") == 1) {
            
switch_hands(id,1)
        }
        
ammo_hud(id0)
        
ammo_hud(id1)
        
cs_set_user_plant(id,0,0)
        
entity_set_string(idEV_SZ_viewmodel"models/v_rpg.mdl")
        
entity_set_string(idEV_SZ_weaponmodel"models/p_rpg.mdl")
    }
    else if ((
weaponid == CSW_C4) && ((cs_get_user_plant(id) == 1) || (mode[id] == 4))) {
        if (
get_cvar_num("amx_bazooka_autohands") == 1) {
            
switch_hands(id,0)
        }
        
ammo_hud(id0)
        
ammo_hud(id1)
        if (
iTeam&CS_TEAM_CT) {
            
cs_set_user_plant(id,0,0)
            
mode[id] = 1
            modetext
[id] = 1
            entity_set_string
(idEV_SZ_viewmodel"models/v_rpg.mdl")
            
entity_set_string(idEV_SZ_weaponmodel"models/p_rpg.mdl")
        }
        else if (
iTeam&CS_TEAM_T) {
            
cs_set_user_plant(id,1,1)
            
entity_set_string(idEV_SZ_viewmodel"models/v_c4.mdl")
            
entity_set_string(idEV_SZ_weaponmodel"models/p_c4.mdl")
        }
    }
    else if (
weaponid != CSW_C4) {
        if (
get_cvar_num("amx_bazooka_autohands") == 1) {
            
switch_hands(id,0)
        }
        
cs_set_user_plant(id,0,0)
        
mode[id] = 1
        modetext
[id] = 1
        ammo_hud
(id0)
    }
    return 
PLUGIN_HANDLED
}
//this little guy reads the flags given in the amx_bazooka_restrict cvar
get_restrict_flags() {
    new 
sFlags[24]
    
get_cvar_string("amx_bazooka_restrict",sFlags,24)
    
iFlags read_flags(sFlags)
}


//ok, everything past here is a direct copy/paste from Mike Cao's Gore Plugin
//with a few minor changes
//i had permission to use this code of course
/************************************************************
* GIB FUNCTIONS (made by mike_cao)
************************************************************/

public event_respawn(id) {
    
gHealthIndex[id] = get_user_health(id)
    
fx_trans(id,255)
    return 
PLUGIN_CONTINUE    

}

static 
fx_trans(player,amount)
{
    
set_user_rendering(player,kRenderFxNone,0,0,0,kRenderTransAlpha,amount)
    return 
PLUGIN_CONTINUE
}

static 
fx_blood_small(origin[3],num)
{
    
// Blood decals
    #if CZERO
    
static const blood_small[8] = {202,203,204,205,206,207,208,209}
    
#else
    
static const blood_small[7] = {190,191,192,193,194,195,197}
    
#endif    
    // Small splash
    
for (new 0numj++) {
        
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
        
write_byte(TE_WORLDDECAL)
        
write_coord(origin[0]+random_num(-100,100))
        
write_coord(origin[1]+random_num(-100,100))
        
write_coord(origin[2]-36)
        
write_byte(blood_small[random_num(0,6)]) // index
        
message_end()
    }
}

static 
fx_blood_large(origin[3],num)
{
    
// Blood decals
    #if CZERO
    
static const blood_large[2] = {216,217}
    
#else
    
static const blood_large[2] = {204,205}
    
#endif
    
    // Large splash
    
for (new 0numi++) {
        
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
        
write_byte(TE_WORLDDECAL)
        
write_coord(origin[0]+random_num(-50,50))
        
write_coord(origin[1]+random_num(-50,50))
        
write_coord(origin[2]-36)
        
write_byte(blood_large[random_num(0,1)]) // index
        
message_end()
    }
}

static 
fx_gib_explode(origin[3],num)
{
    new 
flesh[3], xyz
    flesh
[0] = mdl_gib_flesh
    flesh
[1] = mdl_gib_meat
    flesh
[2] = mdl_gib_legbone
    
    
// Gib explosion
    // Head
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_MODEL)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_coord(random_num(-100,100))
    
write_coord(random_num(-100,100))
    
write_coord(random_num(100,200))
    
write_angle(random_num(0,360))
    
write_short(mdl_gib_head)
    
write_byte(0// bounce
    
write_byte(500// life
    
message_end()
    
    
// Spine
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_MODEL)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_coord(random_num(-100,100))
    
write_coord(random_num(-100,100))
    
write_coord(random_num(100,200))
    
write_angle(random_num(0,360))
    
write_short(mdl_gib_spine)
    
write_byte(0// bounce
    
write_byte(500// life
    
message_end()
    
    
// Lung
    
for(new 0random_num(1,2); i++) {
        
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
        
write_byte(TE_MODEL)
        
write_coord(origin[0])
        
write_coord(origin[1])
        
write_coord(origin[2])
        
write_coord(random_num(-100,100))
        
write_coord(random_num(-100,100))
        
write_coord(random_num(100,200))
        
write_angle(random_num(0,360))
        
write_short(mdl_gib_lung)
        
write_byte(0// bounce
        
write_byte(500// life
        
message_end()
    }
    
    
// Parts, 10 times
    
for(new 010i++) {
        
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
        
write_byte(TE_MODEL)
        
write_coord(origin[0])
        
write_coord(origin[1])
        
write_coord(origin[2])
        
write_coord(random_num(-100,100))
        
write_coord(random_num(-100,100))
        
write_coord(random_num(100,200))
        
write_angle(random_num(0,360))
        
write_short(flesh[random_num(0,2)])
        
write_byte(0// bounce
        
write_byte(500// life
        
message_end()
    }
    
    
// Blood
    
for(new 0numi++) {
        
random_num(-100,100)
        
random_num(-100,100)
        
random_num(0,100)
        for(new 
03j++) {
            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
            
write_byte(TE_BLOODSPRITE)
            
write_coord(origin[0]+(x*j))
            
write_coord(origin[1]+(y*j))
            
write_coord(origin[2]+(z*j))
            
write_short(spr_blood_spray)
            
write_short(spr_blood_drop)
            
write_byte(229// color index
            
write_byte(15// size
            
message_end()
        }
    }
}

/**********************************
Function Testing Section
***********************************/


/**********************************
End of Function Testing Sectionn
***********************************/ 
Attached Files
File Type: sma Get Plugin or Get Source (bazooka_fixed.sma - 191 views - 58.0 KB)
Dare.Devil is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:16.


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