Quote:
Originally Posted by almcaeobtac
On a game frame, GetClientButtons, then if a certain one is held down, start a very small timer, and keep doing that til it stops, then return the time.
|
Better on cmdstart ;).
PHP Code:
new Float:gametime_when_press[33] = {0.0, ...}
// plugin_init
register_forward(FM_CmdStart, "fw_cmdstart")
public fw_cmdstart(id, uc_handle, seed)
{
if (!is_user_alive(id))
{
gametime_when_press[id] = 0.0
return FMRES_IGNORED
}
if (gametime_when_press[id] != 0.0)
{
if (!(get_uc(uc_handle, UC_Buttons) & IN_USE))
{
gametime_when_press[id] = 0.0
return FMRES_IGNORED
}
if (get_gametime() >= gametime_when_press[id] + 1.0)
{
// WOHOO
}
}
else
{
if (get_uc(uc_handle, UC_Buttons) & IN_USE))
{
gametime_when_press[id] = get_gametime()
}
}
return FMRES_IGNORED
}
I wrote it here so it is not tested!
__________________