Make CMD into timer - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Make CMD into timer (
/showthread.php?tid=555503)
Make CMD into timer -
Alex_T - 08.01.2015
Hello I want to convert CopFix into a timer. So it will automaticaly set to one after 15 seconds or so.
pawn Код:
CMD:copfix(playerid, params[])
{
new string[256], playerb;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params,"u",playerb)) return SendClientMessage(playerid, USAGE, "[Usage]: /copfix [playerid]");
if(CopFix[playerb] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "You have removed the players ability to acess his locker.");
SendClientMessage(playerb, COLOR_GREY, "You are no longer able to /copfix");
CopFix[playerb] = 0;
return 1;
}
else if(CopFix[playerb] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "Remeber to /copfix again.");
SendClientMessage(playerb, COLOR_GREY, "You have been copfixed by an administrator.");
format(string, sizeof(string), "AdmWarn: %s has copfixed %s.", RPN(playerid), RPN(playerb));
SendAdminMessage(COLOR_DARKRED, 1, string);
CopFix[playerb] = 1;
return 1;
}
return 1;
}
Re: Make CMD into timer -
SickAttack - 08.01.2015
"Hello I want to convert CopFix into a timer." - Totally irrelevant of what you want.
pawn Код:
new bool:CopFix[MAX_PLAYERS] = false,
tmCopFix[MAX_PLAYERS];
CMD:copfix(playerid, params[])
{
new string[256], lookupid;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "u", lookupid)) return SendClientMessage(playerid, USAGE, "[Usage]: /copfix [playerid]");
if(CopFix[lookupid] == true)
{
SendClientMessage(playerid, COLOR_GREY, "You have removed the players ability to acess his locker.");
SendClientMessage(lookupid, COLOR_GREY, "You are no longer able to /copfix");
CopFix[lookupid] = false;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Remeber to /copfix again.");
SendClientMessage(lookupid, COLOR_GREY, "You have been copfixed by an administrator.");
format(string, sizeof(string), "AdmWarn: %s has copfixed %s.", RPN(playerid), RPN(lookupid));
SendAdminMessage(COLOR_DARKRED, 1, string);
CopFix[lookupid] = true;
KillTimer(tmCopFix[lookupid]);
tmCopFix[lookupid] = SetTimerEx("PerformCopFix", 1000 * 15, false, "i", lookupid);
}
return 1;
}
forward PerformCopFix(playerid);
public PerformCopFix(playerid)
{
CopFix[lookupid] = false;
}
Re: Make CMD into timer -
Mic_H - 08.01.2015
PHP код:
#include <YSI\y_timers>
//You need YSI to make this work.
//Refer: https://sampforum.blast.hk/showthread.php?tid=182948
//This will loop whenever a players joins ig and stop when he quits. Tada..
ptask copfix[15000](playerid)
{
if(CopFix[playerid] == true)
{
CopFix[playerid] = false;
//SendClientMessage(playerid, color, "Message");
}
else
{
CopFix[playerid] = true;
//SendClientMessage(playerid, color, "Message");
}
}