One Timer for all.
#1

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 )
Reply
#2

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(playerid0xf8f8f8fff,"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"2000false"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
Reply
#3

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(playerid0xf8f8f8fff,"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"2000false"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.
Reply
#4

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)