SA-MP Forums Archive
Timer doesn't work - 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: Timer doesn't work (/showthread.php?tid=397267)



Timer doesn't work - Louris - 04.12.2012

Код:
forward liftass();
Код:
public liftass()
{
if(GetPVarInt(playerid, "liftas") == 1)
{
MoveDynamicObject(liftas, 1481.07, 1744.07, 9.35, 5.0);
SetPVarInt(playerid, "liftas", 0);
}
Код:
public OnGameModeInit()
{
SetTimer("liftass", 10000, true);
I want to make that, if lift is high, it backs on the ground, but its not work..


Re: Timer doesn't work - Horrible - 04.12.2012

the lift does not move ? or the timer doesnt run ?
if the timer doesnt run. you must add variable to the timer
pawn Код:
new timer;
timer = SetTimer("liftass", 10000, true);
to stop the timer you can use
pawn Код:
KillTimer(timer);



Re: Timer doesn't work - Louris - 04.12.2012

The lift doesn't back on the ground, here is problem..


Re: Timer doesn't work - Horrible - 04.12.2012

Quote:
Originally Posted by Louris
Посмотреть сообщение
The lift doesn't back on the ground, here is problem..
where is the cordinate for ground and for top ?


Re: Timer doesn't work - Louris - 04.12.2012

Here all code..

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( newkeys == KEY_HANDBRAKE )
    {
        if(IsPlayerInRangeOfPoint(playerid, 20.0 , 1477.21, 1750.11, 9.29))
        {
            if(GetPVarInt(playerid, "liftas") == 0)
            {
                MoveDynamicObject(liftas, 1480.31, 1746.09, 96.01, 5.0);
                SetPVarInt(playerid, "liftas", 1);
                GameTextForPlayer(playerid, "~G~ Keliates Aukstyn!", 2000, 5);
            }
        }
        if(IsPlayerInRangeOfPoint(playerid, 20.0 , 1480.31, 1746.09, 96.01))
        {
            if(GetPVarInt(playerid, "liftas") == 1)
            {
                MoveDynamicObject(liftas, 1481.07, 1744.07, 9.35, 5.0);
                SetPVarInt(playerid, "liftas", 0);
                GameTextForPlayer(playerid, "~R~ Keliates zemyn!", 2000, 5);
}
}
}



Re: Timer doesn't work - Horrible - 04.12.2012

where is the create object function ?
pawn Код:
CreateDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 100.0);



Re: Timer doesn't work - Louris - 04.12.2012

The problem not in object, but in timer.

liftas = CreateDynamicObject(18769, 1480.31, 1746.09, 9.25, 0.00, 0.00, 0.11);


Re: Timer doesn't work - Louris - 04.12.2012

OMG people please help, i waiting for a help all day..


Re: Timer doesn't work - Lordzy - 04.12.2012

You could create normal variables for the lift and set it to '1' when lift moves, and then set it to '0' when it stops.

Example:
pawn Код:
new mLift = 0;
public OnGameModeInit()
{
 mlift = 0;
 SetTimer("liftupdate", 5000, true);
 return 1;
}

//Set the mlift to 1 on a command or where the lift gets moved!

forward liftupdate();
public liftupdate()
{
 print("Timer works well");
 if(mlift == 1)
 {
   MoveDynamicObject(liftas, 1481.07, 1744.07, 9.35, 5.0); //liftas must be defined.
   mlift = 0;
   print("Lift got moved!");
 }
 return 1;
}



Re: Timer doesn't work - Horrible - 04.12.2012

Quote:
Originally Posted by Louris
Посмотреть сообщение
OMG people please help, i waiting for a help all day..
Quote:
Originally Posted by Louris
Посмотреть сообщение
The problem not in object, but in timer.

liftas = CreateDynamicObject(18769, 1480.31, 1746.09, 9.25, 0.00, 0.00, 0.11);
Of course the problem is from the object why ? It because it has same variable with pvar so.. What you have to do now is change the variable of the create object function.. And BTW I don't see any code say "settimer" so it means you don't use any timer


Re: Timer doesn't work - Louris - 04.12.2012

#define liftas
forward liftass();
public liftass()
{
if(mLift == 1)
MoveDynamicObject(liftas, 1481.07, 1744.07, 9.35, 5.0);
}

I remaked, but nothing happens..