AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CSGO]Entity not spawning (https://forums.alliedmods.net/showthread.php?t=322318)

Halt 03-23-2020 14:50

[CSGO]Entity not spawning
 
I suppose I'm missing something obvious, but the entity doesn't spawn. Any help would be :bacon!:

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;



Balimbanana 03-23-2020 21:30

Re: [CSGO]Entity not spawning
 
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.


All times are GMT -4. The time now is 00:07.

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