View Single Post
_Cri_
New Member
Join Date: May 2019
Old 05-14-2019 , 06:40   Re: [L4D2] Handle Round Respawn requires 3rd argument
Reply With Quote #5

Quote:
Originally Posted by Silvers View Post
I guess a mod will move.

See this plugin for how respawning works: https://forums.alliedmods.net/showthread.php?p=862618
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(hGameConfSDKConf_Signature"RoundRespawn");
        
hRoundRespawn EndPrepSDKCall();
        if (
hRoundRespawn == INVALID_HANDLESetFailState("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(clientargs)
{
    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(hRoundRespawnclient);
        
PS_SetBought(client"revive");
        
PS_SetPoints(clientPS_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");
    }


Last edited by _Cri_; 05-14-2019 at 07:21.
_Cri_ is offline