Quote:
Originally Posted by Silvers
|
Thanks
Edit: It works but testing it I saw if I die twice (at least) and I buy one respawn and I use the defib function of Admin System I respawn where I'm dead the first time, is it normal?
Broadcast part not tested
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <ps_natives>
static Handle:hRoundRespawn = INVALID_HANDLE;
static Handle:hGameConf = INVALID_HANDLE;
new pointstimer;
new pointsremindtimer;
public Plugin myinfo =
{
name = "Player Utils",
author = "Cris16228",
description = "Utils for all and Admins",
version = "1.0",
url = "N/A"
};
public void OnPluginStart()
{
CreateConVar("cost_respawn","120","How many points the respawn cost.", _,true,0.0);
CreateConVar("points_advertising_ticks","60","How many seconds before the reminder is displayed.", _,true,5.0);
CreateConVar("respawn_advertising_ticks","60","How many seconds before the reminder is displayed.", _,true,5.0);
pointsremindtimer = 1;
RegConsoleCmd("sm_buyrespawn", BuyRespawn);
hGameConf = LoadGameConfigFile("l4drespawn");
if (hGameConf != INVALID_HANDLE)
{
StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "RoundRespawn");
hRoundRespawn = EndPrepSDKCall();
if (hRoundRespawn == INVALID_HANDLE) SetFailState("L4D_SM_Respawn: RoundRespawn Signature broken");
}
else
{
SetFailState("could not find gamedata file at addons/sourcemod/gamedata/l4drespawn.txt , you FAILED AT INSTALLING");
}
LogMessage("Plugin Loaded");
}
public Action:BuyRespawn(client, args)
{
if(IsPlayerAlive(client))
{
ReplyToCommand(client, "[PU] You must be dead to buy the respawn!");
return Plugin_Continue;
}
int icost = GetConVarInt(FindConVar("cost_respawn"));
if(!IsPlayerAlive(client) && PS_GetPoints(client) >= icost && IsClientInGame(client))
{
ReplyToCommand(client, "[PU] You currently have %d points",PS_GetPoints(client));
ReplyToCommand(client, "[PU] The respawn cost is %d points",icost);
SDKCall(hRoundRespawn, client);
PS_SetBought(client, "revive");
PS_SetPoints(client, PS_GetPoints(client) - icost);
}
else
{
PrintToChat(client, "[PU] Not Enough Points");
}
return Plugin_Continue;
}
public Action:TimerUpdate(Handle:timer)
{
pointstimer += 1;
if (pointstimer >= GetConVarInt(points_advertising_ticks) * pointsremindtimer)
{
PrintToChatAll("[PU] Type !buy to buy items in shop.");
LogMessage("Broadcast executed with success");
}
else if (pointstimer >= GetConVarInt(respawn_advertising_ticks) * pointsremindtimer)
{
PrintToChatAll("[PU] If you're dead type !buyrespawn to respawn at the beginning of the buy items in shop.");
LogMessage("Broadcast executed with success");
}
}