Raised This Month: $32 Target: $400
 8% 

[CSGO]Entity not spawning


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 03-23-2020 , 14:50   [CSGO]Entity not spawning
Reply With Quote #1

I suppose I'm missing something obvious, but the entity doesn't spawn. Any help would be

All I'm trying to do below is spawn an entity and teleport it to the client who called it. The location is correct so I'm assuming my error has to do with the entity itself spawning. Or my return?

PHP Code:
#include <sourcemod>
#include <sdktools>

int g_iEntityIndex;

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_cfire"Command_CreateFire"sm_cfire - Creates fire @ player orig");
}

public 
Action Command_CreateFire(int iClientint Args)
{
    
float f_vCoords[3];
    
GetClientAbsOrigin(iClientf_vCoords);
    
PrintToChatAll("Origin Stored: %f, %f, %f"f_vCoords[0], f_vCoords[1], f_vCoords[2]);

    
g_iEntityIndex CreateEntityByName("env_fire");
    
DispatchKeyValue(g_iEntityIndex"firesize""72");
    
DispatchKeyValue(g_iEntityIndex"duration""15");
    
DispatchKeyValue(g_iEntityIndex"damagescale""0.0"); //Might not work as intended
    
DispatchKeyValue(g_iEntityIndex"LightRadiusScale""1.5");
    
DispatchSpawn(g_iEntityIndex);
    
TeleportEntity(g_iEntityIndexf_vCoordsNULL_VECTORNULL_VECTOR);
    
PrintToChatAll("%i Has Spawned @ %f, %f, %f"g_iEntityIndexf_vCoords[0], f_vCoords[1], f_vCoords[2]);

    return 
Plugin_Handled;

Halt is offline
Balimbanana
Member
Join Date: Jan 2017
Old 03-23-2020 , 21:30   Re: [CSGO]Entity not spawning
Reply With Quote #2

Try changing the "duration" key to "health" instead,
then add "spawnflags", "4" for Start On or you might have to do an
ActivateEntity(g_iEntityIndex); and an AcceptEntityInput(g_iEntityIndex,"StartFire") ; after DispatchSpawn.
In code block:
Code:
	g_iEntityIndex = CreateEntityByName("env_fire");
	DispatchKeyValue(g_iEntityIndex, "firesize", "72");
	DispatchKeyValue(g_iEntityIndex, "health", "15");
	DispatchKeyValue(g_iEntityIndex, "damagescale", "0.0"); //Might not work as intended
	DispatchKeyValue(g_iEntityIndex, "LightRadiusScale", "1.5");
	DispatchKeyValue(g_iEntityIndex, "spawnflags", "4");
	DispatchSpawn(g_iEntityIndex);
	ActivateEntity(g_iEntityIndex);
	AcceptEntityInput(g_iEntityIndex,"StartFire"); //Might not be needed with spawnflags 4
Edit: Oh, and you might also want spawnflags 128 to remove itself when it goes out, so it doesn't use up more edicts every time it is spawned and goes out. So you would change the spawnflags to 132 instead for that.

Last edited by Balimbanana; 03-23-2020 at 21:34.
Balimbanana is offline
Reply


Thread Tools
Display Modes

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 00:52.


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