View Single Post
Junior Member
Join Date: May 2019
Old 10-19-2020 , 15:45   Re: [L4D2] Get Ghost Spawntime
Reply With Quote #5

I went ahead and actually tested it and found another issue. onPluginStart needs to be OnPluginStart or else it won't fire.

Also, as Marttt mentioned, the event only fires once when you become a ghost. So if you spawn in and your spawntime isn't less than 4s it won't work. Testing alone worked for me, because I was getting a 3s respawn time but I know with more people the respawn time will be higher.

This is the full code I tested and it worked:
#include <sourcemod>

#define TEAM_INFECTED    3

public OnPluginStart()
    HookEvent("ghost_spawn_time",event_ghost_spawn_time, EventHookMode_Post); 

public event_ghost_spawn_time(Handle:event, const String:name[], bool:dontBroadcast)
    new client = GetClientOfUserId(GetEventInt(event,"userid"));
    new Float:spawntime = GetEventFloat(event,"spawntime");
    if (client > 0 && client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client) && GetClientTeam(client) == 3 && spawntime < 4.0)
        PrintToChatAll("%i spawned. spawntime %f", client, spawntime);
devilesk is offline