AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation (https://forums.alliedmods.net/showthread.php?t=139850)

McFlurry 10-05-2010 23:02

[SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
I thought I would post some handy snippets for Left 4 Dead 2.

Creating an explosive Barrel:
PHP Code:

        new ent CreateEntityByName("prop_fuel_barrel"); //Special prop type for the barrel
        
DispatchKeyValue(ent"model""models/props_industrial/barrel_fuel.mdl");
        
DispatchKeyValue(ent"BasePiece""models/props_industrial/barrel_fuel_partb.mdl");
        
DispatchKeyValue(ent"FlyingPiece01""models/props_industrial/barrel_fuel_parta.mdl"); //FlyingPiece01 - FlyingPiece04 are supported
        
DispatchKeyValue(ent"DetonateParticles""weapon_pipebomb"); //Particles to use, weapon_vomitjar might work haven't tested
        
DispatchKeyValue(ent"FlyingParticles""barrel_fly"); //Particles to use, I have never successfully gotten a list of L4D2 particle names yet
        
DispatchKeyValue(ent"DetonateSound""BaseGrenade.Explode"); //Scene File name that will be used as sound when barrel explodes
        
DispatchSpawn(ent); 

Now theres also the matter of laser sights which can't be created by the simple CreateEntityByName

Here's how:
PHP Code:

        new Float:pos[3], String:position[64];
        new 
ent CreateEntityByName("upgrade_spawn");      
        
DispatchKeyValue(ent"count""1"
        
DispatchKeyValue(ent"laser_sight""1"); 
        
Format(positionsizeof(position), "%1.1f %1.1f %1.1f"pos[0], pos[1], pos[2]); //Teleporting this entity will not work must use origin key value!
        
DispatchKeyValue(ent"origin"position); 
        
DispatchKeyValue(ent"classname""upgrade_spawn"); 
        
DispatchSpawn(ent); 

After DispatchSpawn you can use TeleportEntity how you like to teleport it somewhere. ALSO HANDY FOR STRIPPER! :mrgreen:

ku5h 10-06-2010 08:51

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
thx!

MarshalZCC 11-05-2010 12:45

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Interesting that the ent stored when creating the laser upgrade box cannot be used later to remove it - its reported as an invalid entity/edict. Anyone know why upgrade spawns behave this way? Anyone know of a way to delete/remove the laser box once spawned?

McFlurry 11-05-2010 17:16

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
The invalid ent problem might have something to do with why teleport entity doesn't work on it.

lucas_7_94 01-13-2011 15:42

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Sorry for revive the thread , but i have a problem with this.

I have made a this simple plugin.

Code:
#include <sourcemod> public Plugin:myinfo = {     name = "New Plugin",     author = "Unknown",     description = "<- Description ->",     version = "1.0",     url = "<- URL ->" } public OnPluginStart()     RegConsoleCmd("say", Get_Sayed) public Action:Get_Sayed( index, args ) {     decl String:Say[50]     GetCmdArgString(Say, sizeof(Say))         if( StrContains( Say , "/barril" , false ) != -1 )     {         new ent = CreateEntityByName("prop_fuel_barrel"); //Special prop type for the barrel         DispatchKeyValue(ent, "model", "models/props_industrial/barrel_fuel.mdl");         DispatchKeyValue(ent, "BasePiece", "models/props_industrial/barrel_fuel_partb.mdl");         DispatchKeyValue(ent, "FlyingPiece01", "models/props_industrial/barrel_fuel_parta.mdl"); //FlyingPiece01 - FlyingPiece04 are supported         DispatchKeyValue(ent, "DetonateParticles", "weapon_pipebomb"); //Particles to use, weapon_vomitjar might work haven't tested         DispatchKeyValue(ent, "FlyingParticles", "barrel_fly"); //Particles to use, I have never successfully gotten a list of L4D2 particle names yet         DispatchKeyValue(ent, "DetonateSound", "BaseGrenade.Explode"); //Scene File name that will be used as sound when barrel explodes         DispatchSpawn(ent);         PrintToChat( index , "[SM] Barril Creado")     } }

But , doens't make the barrel , what is the problem ?

Peace-Maker 01-13-2011 18:47

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Quote:

Originally Posted by McFlurry (Post 1316705)
After DispatchSpawn you can use TeleportEntity how you like to teleport it somewhere. ALSO HANDY FOR STRIPPER! :mrgreen:

I think you need to precache the model either

McFlurry 01-13-2011 21:37

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
PHP Code:

public OnMapStart()
{
    
PrecacheModel("models/props_industrial/barrel_fuel.mdl"true);
    
PrecacheModel("models/props_industrial/barrel_fuel_partb.mdl"true);
    
PrecacheModel("models/props_industrial/barrel_fuel_parta.mdl"true);


Also for lucas, You didn't teleport the barrel anywhere it's most likely at
0 0 0
And it's easier to create a command then to hook say.
Also at the top of the plugin you need
#include <sdktools>

lucas_7_94 01-14-2011 05:14

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Oh , i forgot the include , thanks .

When you say ' You didn't Teleport the barrel anywhere ' , i need put

PHP Code:

Format(positionsizeof(position), "%1.1f %1.1f %1.1f"pos[0], pos[1], pos[2]); 
DispatchKeyValue(ent"origin"position); 

Like that ?

McFlurry 01-14-2011 16:47

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
The code you posted is only to be used on Laser Sight boxes, unless you fee like it. Though What you need to do is this.
After DispatchSpawn(ent);
PHP Code:

new Float:eye[3];
GetClientEyePosition(clienteye);
TeleportEntity(enteyeNULL_VECTORNULL_VECTOR); 

Also your prototype is wrong, it should be
public Action:Get_Sayed( client, args );

lucas_7_94 01-14-2011 17:04

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Oh , yeah , now works perfectly , thanks you very much .

One cuestion , have diference to change between client & index ?

McFlurry 01-15-2011 02:01

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
I'm not sure if it'll break the command, but it never hurts to leave it as client.

lucas_7_94 01-15-2011 08:52

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Ok , i have this error:

Code:

L 01/15/2011 - 09:23:05: [SM] Native "GetClientEyePosition" reported: Invalid client index 0
code :

Code:
RegConsoleCmd("barril", barril) public Action:barril( client, args ) {         decl Float:position[3];         GetClientEyePosition(client, position);             new ent = CreateEntityByName("prop_fuel_barrel"); //Special prop type for the barrel         DispatchKeyValue(ent, "model", "models/props_industrial/barrel_fuel.mdl");         DispatchKeyValue(ent, "BasePiece", "models/props_industrial/barrel_fuel_partb.mdl");         DispatchKeyValue(ent, "FlyingPiece01", "models/props_industrial/barrel_fuel_parta.mdl"); //FlyingPiece01 - FlyingPiece04 are supported         DispatchKeyValue(ent, "DetonateParticles", "weapon_pipebomb"); //Particles to use, weapon_vomitjar might work haven't tested         DispatchKeyValue(ent, "FlyingParticles", "barrel_fly"); //Particles to use, I have never successfully gotten a list of L4D2 particle names yet         DispatchKeyValue(ent, "DetonateSound", "BaseGrenade.Explode"); //Scene File name         //TeleportEntity(ent, position, NULL_VECTOR, NULL_VECTOR);         TeleportEntity(ent, position, NULL_VECTOR, NULL_VECTOR);         DispatchSpawn(ent);                 PrintToChat( client , "[SM] Barril Creado") }

Another cuestion , i should always hook say to get the command example /barril ?

Peace-Maker 01-15-2011 13:10

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
You can't run that command via rcon or serverconsole. Do it ingame!

You should use
PHP Code:

new Float:position[3]; 

instead of decl.

psychonic 01-15-2011 13:16

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Quote:

Originally Posted by Peace-Maker (Post 1394229)
You should use
PHP Code:

new Float:position[3]; 

instead of decl.

Why set them all to 0 first when he's filling with eye position immediately after?

Electr000999 01-24-2012 07:52

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
how save laser sights box in stripper?

tried like this, but to no avail
{
"origin" "1618 76 416"
"angles" "0 39 0"
"model" "models/w_models/Weapons/w_laser_sights.mdl"
"classname" "upgrade_laser_sight"
}
and
{
"origin" "1618 76 416"
"angles" "0 39 0"
"model" "models/w_models/Weapons/w_laser_sights.mdl"
"classname" "upgrade_spawn"
"count" "1"
"laser_sight" "1"
}

McFlurry 01-24-2012 09:00

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Do a stripper_dump command on a map that has laser sights then go to the txt file and find a code block that has upgrade_spawn. Once you do that set the two keys that determine whether it's incendiary/explosive ammo to 0 and make sure the laser_sight key is 1. I don't have a code block available to show you, so you'll have to do this.

Electr000999 01-25-2012 08:28

Re: [SNIPPET][L4D2] Laser Sight & Explosive Barrel Creation
 
Quote:

Originally Posted by McFlurry (Post 1637592)
Do a stripper_dump command on a map that has laser sights then go to the txt file and find a code block that has upgrade_spawn. Once you do that set the two keys that determine whether it's incendiary/explosive ammo to 0 and make sure the laser_sight key is 1. I don't have a code block available to show you, so you'll have to do this.

thanks, works)


All times are GMT -4. The time now is 18:50.

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