Quote:
Originally Posted by reid123455
Wow, thanks a lot.
I really appreciate it, it's working perfectly.
But I still don't understand why I get errors if using my compiler.
impossible_cc's version can be compiled in this website, but plugin still failed to work
without any errors.
But thank you guys. I've learned a lot from these threads.
|
oops, my version doesnt work because you need a short timer after player_spawn event (I think so).
I'm not sure, but I think that in Cruze's plugin if someone joins server when warmup is already started, or he dies somehow and then respawns again (for example joins spectator then switchs back to team), he won't be freezed. Tell me if I'm wrong.
Still not tested, sorry if it doesnt work.
PHP Code:
#include <sourcemod>
#include <sdktools>
public Plugin myinfo =
{
name = "Warmup Waiting",
author = "Reid",
description = "Simple plugin for waiting other player's connecting by restricting movement",
version = "0.0.1",
url = ""
};
public void OnMapStart()
{
float GetWarmUpTime = (FindConVar("mp_warmuptime")).FloatValue;
if(GetWarmUpTime > 0.0)
{
HookEvent("player_spawn", OnPlayerSpawn, EventHookMode_Post);
CreateTimer(GetWarmUpTime, WarmUpOver);
}
}
public void OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
CreateTimer(0.0, PlayerSpawnDelayed, event.GetInt("userid"));
}
public Action PlayerSpawnDelayed(Handle timer, int userid)
{
int client = GetClientOfUserId(userid);
if(IsClientInGame(client) && IsPlayerAlive(client))
{
SetEntityMoveType(client, MOVETYPE_NONE);
}
PrintCenterText(client, "Please wait for other players connect");
PrintToChat(client, "Please wait for other players connect.");
}
public Action WarmUpOver(Handle timer)
{
UnhookEvent("player_spawn", OnPlayerSpawn, EventHookMode_Post); //We don't need it anymore, so unhook.
for(int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i))
{
SetEntityMoveType(i, MOVETYPE_WALK);
}
}
PrintCenterTextAll("Game is going to start!");
PrintToChatAll("Game is going to start!");
}