One Timer for all. - 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: One Timer for all. (
/showthread.php?tid=649702)
One Timer for all. -
Hunud - 13.02.2018
Hi,
I just want to be sure is it possible to use 1 timer for everything and if possible, how to do that (SetTimer / SetTimerEx )
Re: One Timer for all. -
RxErT - 13.02.2018
hopefully i get what you want..
for example:
PHP код:
forward Banned(id); //forward the callback ur gonna use
public Banned(id)
{
SendClientMessage(id,0xf8f8f8fff,"You have been banned from the server! Bye!");//this gonna display when the timer is used.
return 1;
}
CMD:fakeban(playerid,params[])
{
new
string[128],
name[MAX_PLAYER_NAME],
targetid;
if(IsPlayerAdmin(playerid))
{
if(sscanf(params,"us",targetid,params)) return SendClientMessage(playerid,0xf8f8f8fff,"Usage: {ffa700}/fakeban <id> <reason>");
GetPlayerName(targetid,name,sizeof(name));
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xf8f8f8fff,"ERROR: {ffffff}Invalid ID or Player isn't connected!");
format(string,sizeof(string),"{ffa700}An Administrator has banned {f00f00}%s {ffa700}from the server! {f00f00}[REASON: %s]",name,params);
SendClientMessageToAll(0xf8f8f8fff,string);
SetTimerEx("Banned", 2000, false, "i", targetid);// ...
}
else
{
SendClientMessage(playerid,0xf8f8f8fff,"[ERROR] {F00f00}This command doesn't exist! use {ffa700}/cmds {ffffff} and {ffa700}/help!");
}
return 1;
}
But i don't think that you want this. explain more
Re: One Timer for all. -
PepsiCola23 - 13.02.2018
Quote:
Originally Posted by RxErT
hopefully i get what you want..
for example:
PHP код:
forward Banned(id); //forward the callback ur gonna use
public Banned(id)
{
SendClientMessage(id,0xf8f8f8fff,"You have been banned from the server! Bye!");//this gonna display when the timer is used.
return 1;
}
CMD:fakeban(playerid,params[])
{
new
string[128],
name[MAX_PLAYER_NAME],
targetid;
if(IsPlayerAdmin(playerid))
{
if(sscanf(params,"us",targetid,params)) return SendClientMessage(playerid,0xf8f8f8fff,"Usage: {ffa700}/fakeban <id> <reason>");
GetPlayerName(targetid,name,sizeof(name));
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xf8f8f8fff,"ERROR: {ffffff}Invalid ID or Player isn't connected!");
format(string,sizeof(string),"{ffa700}An Administrator has banned {f00f00}%s {ffa700}from the server! {f00f00}[REASON: %s]",name,params);
SendClientMessageToAll(0xf8f8f8fff,string);
SetTimerEx("Banned", 2000, false, "i", targetid);// ...
}
else
{
SendClientMessage(playerid,0xf8f8f8fff,"[ERROR] {F00f00}This command doesn't exist! use {ffa700}/cmds {ffffff} and {ffa700}/help!");
}
return 1;
}
But i don't think that you want this. explain more
|
What is this?
On topic: yes, you can use one timer for multiple purposes.
Re: One Timer for all. -
Mugala - 13.02.2018
okay this is an example a one second timer for server.
PHP код:
forward OneSecTimer();
public OneSecTimer()
{
// one sec timer for example, code here;
/*
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
//1 sec timer for players
}
*/
return 1;
}
OnGameModeInIt
SetTimer("OneSecTimer",1000,1);