[Help] SetTimerEx
#1

Hey, i have a problem with a timer (SetTimerEx).

I dont really know how to use them, and wiki doesnt tell me the right way.
I want to tell whats going to happend every 5sec, but i need it as an array?
Can somebody tell me how it works?

-Niixie
Reply
#2

With this Function you can Call a Function with Parameters

Код:
public hello(playerid)return SendClientMessage(playerid,Color,"Bla");
Код:
SetTimerEx("hello",2000,1,"i",playerid);
The Last Parameters , the Format an the Variables or Values

i = Integer
f = Float
x = Hex
c = Char

and so on... , The Variables must have the same Datatype like the Format
Reply
#3

and i need to give it a name if i want to kill it too right?
Reply
#4

You mean ?

Код:
new var = SetTimerEx(...);

KillTimer(var);
ye, you can
Reply
#5

I got this:

pawn Код:
public dmvPlayerDamageTimer()
{
    new Float:vhp;
    GetVehicleHealth(GetPlayerVehicleID(playerid), vhp);
    if(strlen(vhp) <= 700)
    {
        SENDMSG(playerid, 0xFFFFFF, "Your car health is now around 700");
    }

    if(strlen(vhp) <= 540)
    {
      SENDMSG(playerid, 0xFFFFFF, "Your car health is now under 540 . you will be charged for the repairings.");
        GivePlayerMoney(playerid, -1000);
        KillTimer(dmvPlayerDamageTimer[playerid]);
    }
    return 1;
}
Also without strlen i get the same error

and the timer is set like this

Global:
pawn Код:
new dmvPlayerDamageTimer;
OnPlayerEnterVehicle:
pawn Код:
dmvPlayerDamageTimer = SetTimerEx("DmvCarDamage", 5000, true, "i", playerid);
OnPlayerExitVehicle:
pawn Код:
KillTimer(dmvPlayerDamageTimer);
and these are my errors:
pawn Код:
(2647) : error 021: symbol already defined: "dmvPlayerDamageTimer"
(2650) : error 021: symbol already defined: "GetVehicleHealth"
(2651) : error 010: invalid function or declaration
(2653) : error 021: symbol already defined: "SENDMSG"
(2656) : error 010: invalid function or declaration
(2658) : error 021: symbol already defined: "SENDMSG"
(2662) : error 010: invalid function or declaration
(2726) : warning 203: symbol is never used: "vhp"
whats wrong?
i dont get it?
Reply
#6

Try it:
pawn Код:
forward DmvPlayerDamageTimer(playerid)
{
  new Float:vhp;
  GetVehicleHealth(GetPlayerVehicleID(playerid), vhp);
  if(vhp < 700) SendClientMessage(playerid, 0xFFFFFF, "Yourcar health is now around 700!");
  else if(vhp < 540)
  {
    SendClientMessage(playerid, 0xFFFFFF, "Your car health is now under 540. You will be charged for the repairings.");
    GivePlayerMoney(playerid, -1000);
    KillTimer(dmvPlayerDamageTimer[playerid]);
  }
  return 1;
}
Reply
#7

i did that and still have these errors:

Код:
(2683) : error 021: symbol already defined: "dmvPlayerDamageTimer"
(2686) : error 021: symbol already defined: "GetVehicleHealth"
(2687) : error 010: invalid function or declaration
(2688) : error 010: invalid function or declaration
(2690) : error 021: symbol already defined: "SENDMSG"
(2694) : error 010: invalid function or declaration
(2766) : warning 203: symbol is never used: "vhp"
Reply
#8

Код:
yourtimer[playerid] = SetTimerEx(...); // Please Change var and other things by yourself...
Код:
forward DmvPlayerDamageTimer(playerid);
public DmvPlayerDamageTimer(playerid)
{
  new Float:vhp;
  GetVehicleHealth(GetPlayerVehicleID(playerid), vhp);
  if(vhp < 700) SendClientMessage(playerid, 0xFFFFFF, "Yourcar health is now around 700!");
  else if(vhp < 540)
  { 
    SendClientMessage(playerid, 0xFFFFFF, "Your car health is now under 540. You will be charged for the repairings.");
    GivePlayerMoney(playerid, -1000);
    KillTimer(yourtimer[playerid]); // Change it Please...
  }
  return 1;
}
Reply
#9

Thanks
Reply
#10

Wrong:
pawn Код:
vhp = 300;

if(vhp < 700) { //my func.. }
else if(vhp < 540) { //my func.. }
Like this the else a branch will never come next.

pawn Код:
if(vhp > 540 && vhp < 700) { //my func.. }
else if(vhp < 540) { //my func.. }
Or:
pawn Код:
if(vhp < 540) { //my func.. }
else if(vhp < 700) { //my func..  }
Reply
#11

Код:
if(vhp < 700)
{
  //blabla
}
else if(vhp <540
{
  //blabla
}
wont work then?
Reply
#12

Код:
if(vhp < 700) // True
{
  //blabla
}
else if(vhp <540 // again True
{
  //blabla
}
so

Код:
vhp > 540 && vhp < 700
Код:
vhp > 375 && vhp < 540
Reply
#13

Okay
Reply
#14

Test filterscript:

Wrong:
pawn Код:
#include <a_samp>

public OnFilterScriptInit() { SetTimer("test", 60, true); return 1; }

forward test();public test() {
    new
        vhp = random(800)+200;
    if(vhp < 700)
    {
        printf("true  vhp: %d", vhp);
    }
    else if(vhp < 540)
    {
        printf("No Callback funkcion true (else if) vhp: %d", vhp);
    }
}
Correct:
pawn Код:
#include <a_samp>

public OnFilterScriptInit() { SetTimer("test", 600, true); return 1; }

forward test();public test()
{
    new
        vhp = random(800)+200;
    if(vhp < 540)
    {
        printf("Your car health is now under 540. VehicleHealth: %d", vhp);
    }
    else if(vhp < 700)
    {
        printf("Your car health is now under 700. VehicleHealth: %d", vhp);
    }
}
Reply
#15

hum?
Quote:
Originally Posted by BlackFoX_UD_
Код:
if(vhp < 700) // True
{
  //blabla
}
else if(vhp <540 // again True
{
  //blabla
}
so

Код:
vhp > 540 && vhp < 700
Код:
vhp > 375 && vhp < 540
not working?
Reply
#16

Quote:
Originally Posted by Niixie
hum?
Quote:
Originally Posted by BlackFoX_UD_
Код:
if(vhp < 700) // True
{
  //blabla
}
else if(vhp <540 // again True
{
  //blabla
}
so

Код:
vhp > 540 && vhp < 700
Код:
vhp > 375 && vhp < 540
not working?
Posted test filterscript, try that!
Reply
#17

i did, doesnt work?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)