I'm trying to make a screenshot plugin. I did all I wanted the plugin to do but I have a problem: I don't know how to make the plugin to wait for a function to be completed and the go on. Below is the code, and I wrote the function that i'm having problems with like this:
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
new ip[32], authid2[32];
new bool:a_poze = false;
new help, screens, increment;
new timestamp[32], timestampmsg[128], name[32], adminname[32];
public plugin_init()
{
register_plugin("Ultimate SS", "1.0", "SS");
register_concmd("amx_ss", "concmd_screen", ADMIN_LEVEL_A, "<authid, nick or #userid> <screens>");
register_clcmd("say /ip", "show_ip");
}
public concmd_screen(id, level, cid)
{
if(!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED;
new arg1[24], arg2[2], ip2[32]
new authid[32], player;
read_argv(1, arg1, 23);
read_argv(2, arg2, 1);
screens = str_to_num(arg2);
if(screens > 5)
{
console_print(id, "Prea multe poze! Maxim 5!");
return PLUGIN_HANDLED;
}
if(a_poze)
{
console_print(id, "Nu poti face poze cat timp comanda este executata pe alt player.");
return PLUGIN_HANDLED;
}
player = cmd_target(id, arg1, 4);
if (!player)
return PLUGIN_HANDLED;
a_poze = true;
set_user_godmode(player,1);
get_user_name(player, name, 31);
get_user_name(id, adminname, 31);
get_user_ip(player, ip, 31);
get_user_ip(id, ip2, 31);
get_user_authid(player, authid2, 31);
get_user_authid(id, authid, 31);
client_cmd(id, "amx_chat Ii fac %d poze lui ^"%s^"", screens, name);
console_print(id, "IP-ul lui %s este %s!", name, ip);
increment = 0;
help = 5;
****************************************************************************************************
SS_propriuzis(player); -- this is where I want the plugin to hang till it makes the screenshots and then continue below
****************************************************************************************************
client_print(player, print_chat, "Posteaza Pozele pe: <a href="http://www.***.***" target="_blank" rel="nofollow noopener">www.***.***</a> pentru unban!");
client_print(player, print_chat, "Posteaza Pozele pe: <a href="http://www.***.***" target="_blank" rel="nofollow noopener">www.***.***</a> pentru unban!");
log_amx("Screenshot: Admin ^"%s<%d><%s><%s>^" took %d+1 ss on ^"%s<%d><%s><%s>^"", adminname, get_user_userid(id), authid, ip2, screens, name, get_user_userid(player), authid2, ip);
set_user_godmode(player);
a_poze = false;
return PLUGIN_HANDLED;
}
public SS_propriuzis(player)
{
increment++;
get_time("%m/%d/%Y - %H:%M:%S", timestamp, 31);
set_hudmessage(player, 255, 0, -1.0, 0.3, 0, 0.25, 1.0, 0.0, 0.0, 4);
format(timestampmsg, 127, "** PLAYER %s ORA: - %s **",name,timestamp);
show_hudmessage(player, timestampmsg);
client_print(0, print_chat, "** Screenshot taken on player ^"%s^" by admin ^"%s^" (%s) **", name, adminname, timestamp);
client_print(player, print_chat, "IP-ul tau: %s | %s | Screenshot %d", ip, authid2, pula);
client_cmd(player, "wait;snapshot");
if(increment < screens) set_task(2.0, "SS_propriuzis");
else SS_second(player);
}
public SS_second(player)
{
if(help == 4)
do something;
if(help == 3)
{
do something;
}
if(help == 2)
do something;
help--;
if(help == 0)
{
do something;
}
else set_task(0.25, "SS_second");
}
public show_ip(id)
{
console_print(id, "Last Stored IP: %s!",ip);
}