Is there any way to make a function that will pause the code for a specified amount of time?
For example:
PHP Code:
public plugin_init()
register_clcmd("say /test", "test")
public test(id) {
new name[32]
get_user_name(id, name, 31)
wait(2.0) //wait func
client_print(0, print_chat, "Your name is: %s", name) //This should execute after 2 seconds
}
I tried to make an include that adds this function:
PHP Code:
#if defined _engine_included
#else
#include <engine>
#endif
new created
new Float:ttimer
public TimerThink(iEnt)
{
ttimer+= 0.1
entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 0.1)
}
wait(Float:wtime) {
if(!created) {
register_think("timer","TimerThink")
new iEnt = create_entity("info_target")
entity_set_string(iEnt, EV_SZ_classname, "timer")
entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 0.1)
}
ttimer = 0.0
if(wtime <= 0)
return -1
while(wtime > ttimer) { }
return 1
}
But it crashes the server.
When I put an "infinite" loop in c++ to count it goes on forever so I thought it might work here too

Is there any way to make this? Like, for example, call a function that needs 0.1s to execute 20 times for a 2 second wait?