View Single Post
spancer35
Senior Member
Join Date: Dec 2014
Location: City 17
Old 01-24-2016 , 08:13   Re: [REQ] sm_delayed like on ES
Reply With Quote #3

Quote:
Originally Posted by Grey83 View Post
PHP Code:
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.2.0_sec"


public Plugin:myinfo 
{
    
name "Command Time-Traveler",
    
author "DarthNinja",
    
description "Run commands in future... NOW!",
    
version PLUGIN_VERSION,
    
url "DarthNinja.com"
}
Much thanks m8I'll try it
public OnPluginStart()
{
        RegAdminCmd("sm_future", CmdFuture, ADMFLAG_ROOT);
        CreateConVar("sm_futureexe_version", PLUGIN_VERSION, "Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
}

public Action:CmdFuture(client, args)
{
    if (args != 2)
    {
        ReplyToCommand(client, "[SM] Usage: sm_future <Time in seconds> \"Command +Args\"");
        return Plugin_Handled;    
    }
    decl String:Fcmd[255];
    decl String:time_S[25];
    GetCmdArg(1, time_S, sizeof(time_S));
    GetCmdArg(2, Fcmd, sizeof(Fcmd));
    ShowActivity2(client, "[SM] ","Executing \"%s\" in %s seconds", Fcmd, time_S);
    new Float:time_float;
    time_float = StringToFloat(time_S);
    
    decl String:name[255]
    decl String:steamid[255]
    if (client != 0)
    {
        GetClientName(client, name, sizeof(name));
        GetClientAuthString(client, steamid, sizeof(steamid));
    }
    else if (client == 0)
    {
        strcopy(name, sizeof(name), "CONSOLE");
        strcopy(steamid, sizeof(steamid), "CONSOLE");
    }
    LogAction(client, -1, "%L used Future-Execute to execute command %s in %s seconds.", client, Fcmd, time_S); //log
    //Fix quotes
    ReplaceString(Fcmd, sizeof(Fcmd), "'","
\"")
    
    new 
Handle:pack
    CreateDataTimer
(time_floatTimer_FUExecpack)
    
WritePackString(packname); //Client's name
    
WritePackString(packsteamid); //Client's steamid
    
WritePackString(pack,Fcmd); //command + args
    
WritePackString(pack,time_S); //time as string
    
return Plugin_Handled;
}


public 
Action:Timer_FUExec(Handle:timerHandle:pack)
{
    
decl String:cmd[255]
    
decl String:time[25]
    
decl String:name[255]
    
decl String:steamid[255]
    
    
ResetPack(pack)
    
ReadPackString(packnamesizeof(name))
    
ReadPackString(packsteamidsizeof(steamid))
    
ReadPackString(packcmdsizeof(cmd))
    
ReadPackString(packtimesizeof(time))
    
    
LogAction(-1,-1,"\"%s\"(%s) used Future-Execute to execute command %s: Called %s seconds ago."namesteamidcmdtime); //log
    
ServerCommand("%s"cmd)
    
    return 
Plugin_Stop;

spancer35 is offline