PHP Code:
#include <sourcemod>
#include <left4dhooks>
#pragma semicolon 1
#pragma newdecls required
bool g_bLeftSafeArea;
Handle g_hTimerMessage[MAXPLAYERS+1];
public Plugin myinfo =
{
name = "[L4D2] Game Start Message",
author = "Drixevel",
description = "Prints a message in chat when the game starts.",
version = "1.0.0",
url = "https://drixevel.dev/"
};
public void OnPluginStart()
{
HookEvent("round_freeze_end", Event_RoundFreezeEnd, EventHookMode_PostNoCopy);
}
public void OnMapStart()
{
g_bLeftSafeArea = false;
}
public void OnClientPutInServer(int client)
{
if(!IsFakeClient(client) && !g_bLeftSafeArea)
g_hTimerMessage[client] = CreateTimer(5.0, Timer_DisplayMessageInSafeArea, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
void Event_RoundFreezeEnd(Event event, const char[] name, bool dontBroadcast)
{
g_bLeftSafeArea = false;
for(int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i) || IsFakeClient(i) || g_hTimerMessage[i] != null) continue;
g_hTimerMessage[i] = CreateTimer(5.0, Timer_DisplayMessageInSafeArea, GetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE);
}
}
Action Timer_DisplayMessageInSafeArea(Handle timer, int userid)
{
int client = GetClientOfUserId(userid);
if (client == 0 || !IsClientInGame(client)) return Plugin_Handled;
if(!g_bLeftSafeArea) PrintToChat(client, "\x04Inside Safe Area Message");
g_hTimerMessage[client] = null;
return Plugin_Handled;
}
public void L4D_OnFirstSurvivorLeftSafeArea_Post(int client)
{
g_bLeftSafeArea = true;
PrintToChatAll("\x04[Oyun Mod-Kontrolü] \x01Oyun başladı. Oyun Mod'u hazır! Bol şanslar! İyi oyunlar...");
}
__________________