Raised This Month: $32 Target: $400
 8% 

Very small request chat message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ericsp
Junior Member
Join Date: Apr 2018
Old 04-13-2018 , 16:22   Very small request chat message
Reply With Quote #1

Hi guys
As you know from my previous posts I am pretty noob and I really need your help (again)

I have this code from the forums. It respawns all the players for the first 30 seconds of the map. When the 30 seconds pass, a chat message is displayed: Warmup is OFF. Players no longer respawn. I'd want you to also create a function with hint message with a timer on how many seconds are left (for example hint message: Warmup: Seconds left - 28, then after one sec: Warmup: Seconds left - 27). Can you please do that for me? I like to believe it's pretty easy but maybe I am wrong. Anyway, your help is greatly appreciated. Feel free to enter my server at any time, I'll help with whatever you need

Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <cstrike>

new roundTime;
new currentTime; 

public OnPluginStart()
{
    HookEvent("round_start", Event_RoundStart);
    HookEvent("player_death", Event_PlayerDeath);
}

public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    roundTime = GetTime();
}

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    currentTime = GetTime();
    
    if (currentTime-roundTime > 30)
{
      PrintToChatAll ("WARMUP is OFF. Players no longer respawn.");
      return;
}
    
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    CreateTimer(1.0, ExecRespawn, client);
}

public Action:ExecRespawn(Handle:timer, any:client)
{
    if ( client && (!IsPlayerAlive(client)))
    {
            CS_RespawnPlayer(client);
    }    
    return Plugin_Stop;
}
ericsp is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 04-14-2018 , 04:54   Re: Very small request chat message
Reply With Quote #2

Untested
Attached Files
File Type: sp Get Plugin or Get Source (warmuprespawn.sp - 155 views - 1.6 KB)
Drixevel is offline
ericsp
Junior Member
Join Date: Apr 2018
Old 04-14-2018 , 07:50   Re: Very small request chat message
Reply With Quote #3

unfortunately it doesn't work
it only activates on game start (during the normal warmup which had respawn anyway)
I'd like it to activate every round start if it's possible

Thank you
ericsp is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 04-14-2018 , 10:03   Re: Very small request chat message
Reply With Quote #4

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma semicolon 1
#pragma newdecls required

int WarmUpTimerSecs;
bool WarmUp;

public 
void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
CreateTimer(1.0LoopclientTIMER_REPEAT);
    
WarmUpTimerSecs 30;
    
WarmUp true;
}

public 
Action Loop(Handle timerany client)
{
    if (
WarmUpTimerSecs-- > 1)
    {
        
PrintHintTextToAll("Warmup will be disabled in <font color='#008000'>%i seconds</font>."WarmUpTimerSecs);
        return 
Plugin_Continue;
    }

    
PrintHintTextToAll("<font color='#FF5500'>WARMUP IS NOW OFF.</font>");
    
WarmUp false;
    return 
Plugin_Stop;
}

public 
Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if (
WarmUp)
    {
        
CreateTimer(1.0ExecRespawnclient);
    }    
}

public 
Action ExecRespawn(Handle timerany client)
{
    if (
client && (!IsPlayerAlive(client)))
    {
        
CS_RespawnPlayer(client);
    }    
    return 
Plugin_Stop;

Give this a try.
__________________
PinHeaDi is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 04-14-2018 , 10:33   Re: Very small request chat message
Reply With Quote #5

Updated.
Attached Files
File Type: sp Get Plugin or Get Source (warmuprespawn.sp - 180 views - 1.6 KB)
Drixevel is offline
ericsp
Junior Member
Join Date: Apr 2018
Old 04-14-2018 , 16:01   Re: Very small request chat message
Reply With Quote #6

Thank you very much. It works just as expected. Great plugin!
ericsp is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode