Skip to content

Instantly share code, notes, and snippets.

@nagadomi
Last active September 26, 2021 02:00
Show Gist options
  • Save nagadomi/8395743 to your computer and use it in GitHub Desktop.
Save nagadomi/8395743 to your computer and use it in GitHub Desktop.
/* Left 4 Dead 2 Panic Events */
#include <sourcemod>
public OnPluginStart()
{
/* Hook Panic Create event after it has happened */
HookEvent("create_panic_event", OnPanicCreate);
/* Hook Left Player event after it has happened */
HookEvent("player_left_start_area", OnPlayerLeftStartArea);
}
public Action:OnPanicCreate(Handle:event, const String:name[], bool:dontBroadcast)
{
/* Copy the UserID from the event over */
new uId = GetEventInt(event, "userid");
/* Now get the person's name */
new client = GetClientOfUserId(uId);
if (client > 0 && IsClientInGame(client)) {
new String:cName[MAX_NAME_LENGTH];
GetClientName(client, cName, sizeof(cName));
/* Now tell everyone who created the event */
PrintToChatAll("\x03[Panic Event]\x01 %s created a panic event!", cName);
}
}
public Action:OnPlayerLeftStartArea(Handle:event, const String:name[], bool:dontBroadcast)
{
/* Copy the UserID from the event over */
new uId = GetEventInt(event, "userid");
/* Now get the person's name */
new client = GetClientOfUserId(uId);
if (client > 0 && IsClientInGame(client)) {
new String:cName[MAX_NAME_LENGTH];
GetClientName(client, cName, sizeof(cName));
/* Now tell everyone who created the event */
PrintToChatAll("\x03[Panic Event]\x01 %s was the first one out of the safe area!", cName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment