Okay, so I'm working on a plugin where I want the commands to be delayed for a set time or until round ends / starts.
I tried a quite dumb approach for the round end / start right now and it doesn't appear to work. If it did work, it'd also just be one command which worked... which isn't what I want either. I figured you'd need 3 dimensional arrays for it so I tried that out but just ended up getting lost. Here's my non-working code.
PHP Code:
#include <amxmodx>
#define VERSION "0.6.7"
#define ROUNDEND_TASKID 2000
#define ROUNDSTART_TASKID 1000
public plugin_init()
{
register_plugin("Vix (Command Delayer)", VERSION, "dg`")
register_concmd("amx_delay", "cmdDelay", 0, "<time in seconds> <^"command^">")
register_logevent( "EvRoundStart", 2, "1=Round_Start")
register_logevent( "EvRoundEnd", 2, "1=Round_End")
}
public cmdDelay(index)
{
new time[5], command[60], len = charsmax(command)
read_argv(1, time, len)
read_argv(2, command, len)
if(!time[0])
{
console_print(index, "Usage: amx_delay <seconds/-1 round end/-2 round start> <^"command^">")
return PLUGIN_HANDLED
}
new delay = str_to_num(time)
switch(delay)
{
case -1:
{
console_print(index, "[Vix] You will perform the command %s on round end.", command)
set_task(1000.0, "ExecCmd", ROUNDEND_TASKID + index, command, len)
}
case -2:
{
console_print(index, "[Vix] You will perform the command %s on round start.", command)
set_task(1000.0, "ExecCmd", ROUNDSTART_TASKID + index, command, len)
}
default:
{
set_task(float(delay), "ExecCmd", index, command, len)
console_print(index, "[Vix] You set a task of %is to perform this command: %s", delay, command)
}
}
return PLUGIN_HANDLED
}
public ExecCmd(command[], index)
{
if(!is_user_connected(index) )
return
trim(command)
remove_quotes(command)
while(replace(command, 60, "\'", "^"")) { } //"
client_cmd(index, command)
}
public EvRoundEnd()
{
new i, players[32], num, index
get_players(players, num)
for(i = 0; i < num; i++)
{
index = players[i]
change_task(ROUNDEND_TASKID + index, 0.1)
}
}
public EvRoundStart()
{
new i, players[32], num, index
get_players(players, num)
for(i = 0; i < num; i++)
{
index = players[i]
change_task(ROUNDSTART_TASKID + index, 0.1)
}
}
__________________