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

[SOLVED] CreateTimer how many time are left


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Johnoclock
Member
Join Date: Oct 2014
Location: denmark
Old 07-27-2015 , 11:22   [SOLVED] CreateTimer how many time are left
Reply With Quote #1

is any why to so see how many time are left of a CreateTimer and print the to the player
PHP Code:
 #include <sourcemod> 
#include <sdktools> 
#include <tf2> 
#include <morecolors>

#define PLUGIN_AUTHOR "john" 
#define PLUGIN_VERSION "1.0" 

//Time of the speed boost in seconds 
#define SPEED_BOOTS_TIME 5.0 
#define COOLDOWN_TIME 60.0

hook:canUseSpeedBoost[MAXPLAYERS+1] = {true, ...};

public 
Plugin myinfo =  

    
name "[TF2] call"
    
author PLUGIN_AUTHOR
    
description "medic call for speed"
    
version PLUGIN_VERSION
    
url " http://www.sourcemod.net" 
}; 

public 
void OnPluginStart() 

    
AddCommandListener(MedicCall"voicemenu"); 


public 
Action:MedicCall(clientString:command[], args
{
    if (!
canUseSpeedBoost[client]) {
      
PrintToChat(client"=time=");
    }
    
    
decl String:buffer[2]; 
    
    
GetCmdArg(1buffersizeof(buffer)); 
    if (
StringToInt(buffer) == 0
    { 
        
GetCmdArg(2buffersizeof(buffer)); 
        if (
StringToInt(buffer) == 0
        { 
if(
canUseSpeedBoost[client] == true)
{
TF2_AddCondition(clientTFCond_SpeedBuffAllySPEED_BOOTS_TIME); 
            
//Put this on cooldown for current player
canUseSpeedBoost[client] = false;
CreateTimer(COOLDOWN_TIMEResetCooldownclient);
}
        } 
    } 
}

public 
Action:ResetCooldown(Handle:timerany:client)
{
  
//Reset cooldown
  
canUseSpeedBoost[client] = true;
  {
      
PrintToChat(client,"=time=");
    }

here are the code,
=time= mean where to put the when to tell time left

Last edited by Johnoclock; 07-28-2015 at 07:59. Reason: solved
Johnoclock is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-27-2015 , 11:32   Re: CreateTimer how many time are left
Reply With Quote #2

create an integer form the same ammount of time the timer is, and minus one every time (repeating timer). Ill make this for you when I get home today (few hours)
headline is offline
Johnoclock
Member
Join Date: Oct 2014
Location: denmark
Old 07-27-2015 , 11:36   Re: CreateTimer how many time are left
Reply With Quote #3

Quote:
Originally Posted by Headline22 View Post
create an integer form the same ammount of time the timer is, and minus one every time (repeating timer). Ill make this for you when I get home today (few hours)
thx
Johnoclock is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 07-27-2015 , 15:25   Re: CreateTimer how many time are left
Reply With Quote #4

PHP Code:
#include <sourcemod>  
#include <sdktools>  
#include <tf2>  
#include <morecolors> 
#include <autoexecconfig>

#define PLUGIN_VERSION "1.0"  

new Handle:g_hPluginEnabled INVALID_HANDLE;
new 
bool:g_bPluginEnabled;

new 
Handle:g_hCoolDown INVALID_HANDLE;
new 
g_iCoolDown;

new 
Handle:g_hSpeedBoostTime INVALID_HANDLE;
new 
Float:g_fSpeedBoostTime;

new 
g_iTime;
    
new 
bool:canUseSpeedBoost[MAXPLAYERS+1] = {true, ...}; 

public 
Plugin myinfo =   
{  
    
name "[TF2] Call",  
    
author "John",  
    
description "Medic call for speed",  
    
version PLUGIN_VERSION,  
    
url " http://www.sourcemod.net"  
};

public 
OnPluginStart() 
{
    
AutoExecConfig_SetFile("tf2_call");
    
AutoExecConfig_SetCreateFile(true);
    
    
AutoExecConfig_CreateConVar("tf2_call_version"PLUGIN_VERSION"TF2 Call Plugin Version"FCVAR_PLUGIN|FCVAR_DONTRECORD|FCVAR_NOTIFY);
    
    
g_hPluginEnabled AutoExecConfig_CreateConVar("tf2_call_enable""1""Enables and disables the tf2 call plugin"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hPluginEnabledOnCVarChange);
    
g_bPluginEnabled GetConVarBool(g_hPluginEnabled);
    
    
g_hCoolDown AutoExecConfig_CreateConVar("tf2_call_cooldown_time""60.0""URL to validate"FCVAR_NOTIFY);
    
HookConVarChange(g_hCoolDownOnCVarChange);
    
g_iCoolDown GetConVarInt(g_hCoolDown);
    
    
g_hSpeedBoostTime AutoExecConfig_CreateConVar("tf2_call_speedboost_time""5.0""Ammount of time the speedboost lasts"FCVAR_NOTIFY);
    
HookConVarChange(g_hSpeedBoostTimeOnCVarChange);
    
g_fSpeedBoostTime GetConVarFloat(g_hSpeedBoostTime);
    
    
AddCommandListener(MedicCall"voicemenu"); 
}

public 
OnCVarChange(Handle:hCVar, const String:sOldValue[], const String:sNewValue[])
{
    if(
hCVar == g_hPluginEnabled)
    {
        
g_bPluginEnabled GetConVarBool(g_hPluginEnabled);
    }
    if(
hCVar == g_hCoolDown)
    {
        
g_iCoolDown GetConVarInt(g_hCoolDown);
    }
    if(
hCVar == g_hSpeedBoostTime)
    {
        
g_fSpeedBoostTime GetConVarFloat(g_hSpeedBoostTime);
    }
}

public 
Action:MedicCall(clientString:command[], args)  
{
    if (!
g_bPluginEnabled)
    {
        
ReplyToCommand(client"The TF2 Call plugin is disabled!");
        return 
Plugin_Handled;
    }
    if (!
canUseSpeedBoost[client])
    {
        
PrintToChat(client"You have %i seconds left untill you can use the speed boost again!"g_iTime)
        return 
Plugin_Handled;
    }

    
decl String:sBuffer[2];

    
GetCmdArg(1sBuffersizeof(sBuffer));

    if (
StringToInt(sBuffer) == 0)
    {
        
GetCmdArg(2sBuffersizeof(sBuffer));
        if (
StringToInt(sBuffer) == 0)
        {
            if(
canUseSpeedBoost[client] == true
            {
                
TF2_AddCondition(clientTFCond_SpeedBuffAllyg_fSpeedBoostTime);  
         
                
canUseSpeedBoost[client] = false;
                
                
g_iTime g_iCoolDown;
                
                
CreateTimer(1.0Timer_CoolDownclientTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); 
            }
        } 
    }
    return 
Plugin_Handled;
}

public 
Action:Timer_CoolDown(Handle:hTimerany:client)
{
    if (
g_iTime == 0)
    {
        
canUseSpeedBoost[client] = true;
        return 
Plugin_Stop;
    }
    
g_iTime--;
    return 
Plugin_Continue;

Let me know how this works

Last edited by headline; 07-27-2015 at 16:25.
headline 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 10:51.


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