Timer Help
#1

Sorry if this is the wrong section.

I really have problems using timers,I don't really know how to make a timer like,for an object,a command,I saw some examples and I could copy them but this won't make me understand them.

So,can somebody help me with timers? I would be very grateful,like timers for commands,for object,who knows for vehicles,textdraws.
Thanks in advance,I appreciate any help
Have a nice day/night
Reply
#2

pawn Код:
// Top of script

forward Timer();

// Bottom of script.

public Timer()
{
     //effect
}

// Somewhere else.
     SetTimer("Timer", /*SECONDS_IN_MILLISECONDS*/, /*TRUE=REPEATING - 1, FALSE=NON_REPEATING - 0*/);
Reply
#3

https://sampwiki.blast.hk/wiki/Scripting...29_RU#SetTimer
https://sampwiki.blast.hk/wiki/Scripting..._RU#SetTimerEx
https://sampwiki.blast.hk/wiki/Scripting...9_RU#KillTimer

I don't know why it's in Russian.

You can create a Timer with this:

pawn Код:
new Timer
and

pawn Код:
forward Timer
Reply
#4

Becuase you're linking to the russian examples.
https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
https://sampwiki.blast.hk/wiki/KillTimer
Reply
#5

Ok thanks
But how can I make a timer for a command? like the command should only be available if the timer passed.
Like player does something like /gotolasventuras and he can do it again after lets say 1 minute has passed
Reply
#6

it can be done with a variable.
pawn Код:
//On top of script
new CommandUsed[MAX_PLAYERS];
// command
if(strcmp(...)==0)
{
  if(CommandUsed[playerid] == -1) return SendClientMessage(... /* command was used before, pleae wait this and that */);
  //do command here
  CommandUsed[playerid] = -1;
  SetTimerEx("ResetCmd", 5000 /*5 seconds*/, 0 /* not repeating*/, "i", playerid /* this sets the first parameter of ResetCmd(i) to be playerid);
}

//ResetCmd(i)
{
  CommandUsed[i] = 0;
}
sorry it's messy but if you edit it properly it hsould work. this is just the principle how it should be like
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)