Post: [Script] Shoot Exploding Barrels...
01-03-2013, 05:16 AM #1
The_Urban_Ninja
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({}); Whats up NGU, today I'm releasing a script i made this week since I was bored and there was really nothing else to do during this holiday.Basically this code allows you to shoot barrels that explode after 5 secs. Also, I coded it so you can't spam the gun, other wise it becomes buggy. So anyway here's the code.

Works on all maps, besides rust and invasion. You can script it to work on those maps but im done working on this code.
NEW VIDEO



Add these to init()

    precacheModel("com_barrel_blue_rust");
precacheModel("com_barrel_benzin");
precacheModel("com_barrel_green_dirt");
precacheModel("com_barrel_white_rust");



    BarrelGun() 
{
if(getDvar("mapname") == "mp_invasion" || getDvar("mapname") == "mp_rust")
{
self iPrintln("^8Map Not Supported!");
}
else
{
self endon("death");
self endon("disconnect");
self iPrintln("^8Explosion Gun");
self iPrintln("^8Created By: The_Urban_NinjaX");
self giveWeapon("fal_silencer_mp",1,false);
self switchToWeapon("fal_silencer_mp");
level._effect["explosion"]=loadfx( "explosions/propane_large_exp" );
level._effect["explosioni"]=loadfx( "explosions/small_vehicle_explosion" );
level._effect["explosionz"]=loadfx( "explosions/wall_explosion_pm_a" );
level._effect["explosionf"]=loadfx( "explosions/artilleryexp_dirt_brown" );
level._effect["explosionc"]=loadfx( "explosions/aerial_explosion_large" );
if(getDvar("mapname") == "mp_terminal" || getDvar("mapname") == "mp_highrise" || getDvar("mapname") == "mp_quarry" )
{
for(;Winky Winky
{
self waittill("weapon_fired");
if(self getCurrentWeapon() == "fal_silencer_mp")
{
vec = (anglestoforward(self getplayerangles())*180000); //feel free to change value but make sure its the same as PhysicsLaunchServer
crate = spawn("script_model", (self.origin+(0,0,25)));
crate setModel( "com_barrel_benzin" );
crate.angles=self getplayerangles();
crate PhysicsLaunchClient( "crate.origin", vec );
crate PhysicsLaunchServer((0,0,0),anglestoforward(self getplayerangles())*180000); //feel free to change value but make sure its the same as PhysicsLaunchClient
wait 4;
playfx(level._effect["explosion"], crate.origin);
self PlaySound("propanetank02_explode");
crate RadiusDamage(crate.origin,550,500,500,self);
crate delete();
}
}
}
if(getDvar("mapname") == "mp_boneyard" || getDvar("mapname") == "mp_afghan" || getDvar("mapname") == "mp_derail" || getDvar("mapname")== "mp_favela" || getDvar("mapname")== "mp_underpass" || getDvar("mapname")== "mp_nightshift" || getDvar("mapname")== "mp_subbase")
{
for(;Winky Winky
{
self waittill("weapon_fired");
if(self getCurrentWeapon() == "fal_silencer_mp")
{
vec = (anglestoforward(self getplayerangles())*180000); //feel free to change value but make sure its the same as PhysicsLaunchServer
crate = spawn("script_model", (self.origin+(0,0,25)));
crate setModel( "com_barrel_blue_rust" );
crate.angles=self getplayerangles();
crate PhysicsLaunchClient( "crate.origin", vec );
crate PhysicsLaunchServer((0,0,0),anglestoforward(self getplayerangles())*180000); //feel free to change value but make sure its the same as PhysicsLaunchClient
wait 4;
playfx(level._effect["explosioni"], crate.origin);
playfx(level._effect["explosionc"], crate.origin);
playfx(level._effect["explosionz"], crate.origin);
playfx(level._effect["explosionf"], crate.origin);
playfx(level._effect["explosionf"], crate.origin+(0,0,30));
self PlaySound( "detpack_explo_default" );
crate RadiusDamage(crate.origin,550,500,500,self);
crate delete();
}
}
}
if(getDvar("mapname") == "mp_estate" || getDvar("mapname") == "mp_invasion" || getDvar("mapname") == "mp_checkpoint" || getDvar("mapname") == "mp_rundown" || getDvar("mapname") == "mp_brecourt")
{
for(;Winky Winky
{
self waittill("weapon_fired");
if(self getCurrentWeapon() == "fal_silencer_mp")
{
vec = (anglestoforward(self getplayerangles())*180000); //feel free to change value but make sure its the same as PhysicsLaunchServer
crate = spawn("script_model", (self.origin+(0,0,25)));
if(getDvar("mapname") == "mp_estate" || getDvar("mapname") == "mp_rundown")
{
crate setModel( "com_barrel_white_rust" );
}
crate.angles=self getplayerangles();
if(getDvar("mapname") == "mp_checkpoint" || getDvar("mapname") == "mp_brecourt")
{
crate setModel( "com_barrel_green_dirt" );
}
crate PhysicsLaunchClient( "crate.origin", vec );
crate PhysicsLaunchServer((0,0,0),anglestoforward(self getplayerangles())*180000); //feel free to change value but make sure its the same as PhysicsLaunchClient
wait 4;
playfx(level._effect["explosioni"], crate.origin);
playfx(level._effect["explosionc"], crate.origin);
playfx(level._effect["explosionz"], crate.origin);
playfx(level._effect["explosionf"], crate.origin);
playfx(level._effect["explosionf"], crate.origin+(0,0,30));
self PlaySound( "detpack_explo_default" );
crate RadiusDamage(crate.origin,550,500,500,self);
crate delete();
}
}
}
}
}


Also I might release another script I made sometime later this week. I think it's a lot better then this one.

Credits
247Yamato for helping me a little with launch physics
(adsbygoogle = window.adsbygoogle || []).push({});

The following 7 users say thank you to The_Urban_Ninja for this useful post:

*xActionMods*, 247Yamato, DarK x, ImGsus, Kitty=^.^=, silentcobra22, Vanz
01-03-2013, 08:37 AM #2
Looks like it will be great by the script, Cant wait for vid :love:
01-03-2013, 11:43 AM #3
*xActionMods*
I’m too L33T
Originally posted by Ninja View Post
Whats up NGU, today I'm releasing a script i made this week since I was bored and there was really nothing else to do during this holiday.Basically this code allows you to shoot barrels that explode after 5 secs. Also, I coded it so you can't spam the gun, other wise it becomes buggy. So anyway here's the code.

    BarrelGun() 
{
self endon("death");
self endon("disconnect");
self iPrintln("^8Explosion Gun");
self iPrintln("^8Created By: The_Urban_NinjaX");
self giveWeapon("fal_silencer_mp",1,false);
self switchToWeapon("fal_silencer_mp");
level._effect["explosion"]=loadfx( "explosions/oxygen_tank_explosion" );
for(;Winky Winky
{
self waittill("weapon_fired");
if(self getCurrentWeapon() == "fal_silencer_mp")
{
vec = (anglestoforward(self getplayerangles())*180000); //feel free to change value but make sure its the same as PhysicsLaunchServer
crate = spawn("script_model", (self.origin+(0,0,20))); //feel free to change vale
crate setModel( "com_barrel_benzin" );
crate.angles=self getplayerangles();
crate PhysicsLaunchClient( "crate.origin", vec );
crate PhysicsLaunchServer((0,0,0),anglestoforward(self getplayerangles())*180000); //feel free to change value but make sure its the same as PhysicsLaunchClient
crate Solid(); //optional feel free to delete
crate CloneBrushmodelToScriptmodel(level.airDropCrateCollision); //optional feel free to delete
wait 5;
level._effect["explosion"]=loadfx( "explosions/oxygen_tank_explosion" );
playfx(level._effect["explosion"], crate.origin);
self PlaySound("explo_metal_rand");
crate RadiusDamage(crate.origin,300,500,500,self);
wait 0.1;
crate delete();
}
}
}


Hopefully I can have a video out by tomorrowSmile

Also I might release another script I made sometime later this week. I think it's a lot better then this one.

Credits
247Yamato for helping me a little with launch physics


Recorded it but all it does it blow your self up...
01-03-2013, 11:52 AM #4
The_Urban_Ninja
Do a barrel roll!
Originally posted by ChiefKeef View Post
Recorded it but all it does it blow your self up...


No, it should shoot the barrel out then explode.

Actually I just realized why it's probably killing you when you shoot, delete the crate clonebrushmodeltoscripmodel. Just delete that and then it should work.
01-04-2013, 12:10 AM #5
The_Urban_Ninja
Do a barrel roll!
Originally posted by ChiefKeef View Post
Recorded it but all it does it blow your self up...


Well I have made a video now for it + added a new code...and thanks for recording it though. It was my fault for adding the carepackage collision without testing it out properly.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo