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.01",
url = ""
};
public OnPluginStart()
{
HookEvent("warmup_wating", OnWarmUp);
}
public OnWarmUp(Handle:event, const String:name[], bool:dontBroadcast)
{
new userid = GetEventInt(event, "userid"); // Get player #userid from event
new client = GetClientOfUserId(userid); // Get client index by #userid
new team = GetClientTeam(client);
//MaxClient may needn't to get , this value has define by sm and is 64
//new MaxClients = GetConVarInt(FindConVar("maxplayers"));
//Try not to repeat the definition
new getWarmUpTime = GetConVarInt(FindConVar("mp_warmuptime")); //new GetWarmUpTime = GetConVarInt(FindConVar("mp_warmuptime"));
if(team == 2 || team == 3)
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i))
{
SetEntityMoveType(i, MOVETYPE_NONE);
}
}
//stock PrintToChatAll(const String:format[], any:...)
PrintToChatAll("Please wait for other players connect."); //PrintToChatAll(client, "Please wait for other players connect.");
}
//don‘t use 'while' simplly , may cause server crash,use timer
/*while(GetWarmUpTime != 0) //keep checking if wamrup time == 0
{
new GetWarmUpTime = CreateTimer(GetWarmUpTime); //Sorry. I really don't understand CreateTimer().
} */
//create a timer that several seconds later will carry out the callback, parameter 1 is the second , callback method for 2 , Refer to official documentation for other details
CreateTimer(getWarmUpTime*1.0,WarmupTimeOver);
/*if(GetWarmUpTime == 0)
{
for(new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i))
{
SetEntityMoveType(i, MOVETYPE_WALK);
}
}
PrintToChatAll(client, "Game is going to start!");
} */
}
//the callback method for CreateTimer
public Action:WarmupTimeOver(Handle:timer)
{
for(new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i))
{
SetEntityMoveType(i, MOVETYPE_WALK);
}
}
PrintToChatAll("Game is going to start!");
}
Hei , though I fix some code , I'm not sure it can work well.
I just help fix code that some methods on using , I never wrote plugin for csgo ,just for l4d2 and with my now knowledge.
so hope my fix can work or give you little help.
Sorry for my poor English.