Yaser2007, You can try this code:
PHP Code:
#pragma semicolon 1
#include <sdktools_functions>
public Plugin myinfo =
{
name = "fastspawn",
author = "Alienmario",
description ="fastspawn for players",
version = "1.1.0"
}
bool
bEnable;
float
fTime[MAXPLAYERS+1];
public OnPluginStart()
{
ConVar cvar;
cvar = CreateConVar("sm_fastspawn","1","Enables player respawn [sm_fastspawn_time] seconds after death", _, true, _, true, 1.0);
cvar.AddChangeHook(CVarChange_Enable);
bEnable = cvar.BoolValue;
cvar = CreateConVar("sm_fastspawn_time", "0.5", "Sets how long to wait until player can respawn", _, true, _, true, 5.0);
cvar.AddChangeHook(CVarChange_Time);
fTime[0] = cvar.FloatValue;
AutoExecConfig(true);
HookEvent("player_death", Event_Death);
}
public void CVarChange_Enable(ConVar cvar, const char[] oldValue, const char[] newValue)
{
bEnable = cvar.BoolValue;
}
public void CVarChange_Time(ConVar cvar, const char[] oldValue, const char[] newValue)
{
fTime[0] = cvar.FloatValue;
}
public OnClientPutInServer(client)
{
fTime[client] = 0.0;
}
public void OnPlayerRunCmdPost(int client, int buttons)
{
if(bEnable && buttons & (IN_ATTACK|IN_JUMP|IN_DUCK|IN_FORWARD|IN_BACK|IN_ATTACK2) && !IsPlayerAlive(client)
&& GetClientTeam(client) > 1 && GetGameTime() >= fTime[client])
DispatchSpawn(client);
}
public void Event_Death(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(client && IsPlayerAlive(client)) fTime[client] = GetGameTime() + fTime[0];
}
__________________