SA-MP Forums Archive
Object movement - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Object movement (/showthread.php?tid=156178)



Object movement - Liustas - 21.06.2010

This code works, but moves my object not regularly. How to fix that?


Код:
#include <a_samp>
#define COLOR_LIGHTBLUE 0x33CCFFAA

new Scud;
new SkudSmoke;
new ProgressTimer;
new Float:x,Float:y,Float:z;

forward Misile(playerid);
forward ScudLaunch(playerid);
forward ScudProgres(playerid);


public OnFilterScriptInit()
{
SetTimer("Misile",30000,0);

return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}


public Misile(playerid)
{
Scud=CreateObject(17050,-1648.990,281.410,6.170,0.0,0.0,-339.434);
SkudSmoke=CreateObject(2780,-1649.058,281.403,5.425,0.0,0.0,0.0);
SetTimer("ScudLaunch",10000,0);
return 0;
}


public ScudLaunch(playerid)
{
MoveObject(Scud,-1648.990,281.410,170.000,15);
DestroyObject(SkudSmoke);
ProgressTimer=SetTimer("ScudProgres",200,1);
}


public ScudProgres(playerid)
{
GetObjectPos(Scud,x,y,z);
CreateExplosion(x,y,z,3,3);
{
if(z>=160.000)
{
KillTimer(ProgressTimer);
DestroyObject(Scud);
SetTimer("Misile",30000,0);
}
return 0;
}
}



Re: Object movement - c-middia - 21.06.2010

pawn Код:
SetTimer("Misile",30000,0);
try a shorter time 30,000 = 30 seconds



Re: Object movement - Liustas - 21.06.2010

change time interval is not a solution, i tried. The problem is somewhere else.


Re: Object movement - Brian_G - 21.06.2010

Try this:

Код:
#include <a_samp>

#define COLOR_LIGHTBLUE 0x33CCFFAA

new Scud;
new SkudSmoke;
new ProgressTimer;
new Float:x,Float:y,Float:z;

forward Misile(playerid);
forward ScudLaunch(playerid);
forward ScudProgres(playerid);


public OnFilterScriptInit()
{
  SetTimer("Misile",30000,0);
  return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}


public Misile(playerid)
{
   Scud=CreateObject(17050,-1648.990,281.410,6.170,0.0,0.0,-339.434);
   SkudSmoke=CreateObject(2780,-1649.058,281.403,5.425,0.0,0.0,0.0);
   SetTimer("ScudLaunch",10000,0);
   return 0;
}


public ScudLaunch(playerid)
{
   MoveObject(Scud,-1648.990,281.410,170.000,15);
   DestroyObject(SkudSmoke);
   ProgressTimer=SetTimer("ScudProgres",200,1);
}


public ScudProgres(playerid)
{
   GetObjectPos(Scud,x,y,z);
   CreateExplosion(x,y,z,3,3);
   {
   if(z>=160.000)
   {
   KillTimer(ProgressTimer);
   DestroyObject(Scud);
   SetTimer("Misile",30000,0);
   }
   return 0;
  }
}



Re: Object movement - Liustas - 21.06.2010

This is exactly the same code. This funcion shuld be looping, so this object shuld be created and destroyed with same time intervals. However sometimes this cycle tooks about 50 seconds, which is normal and sometimes about 2 minutes. So i want to ask why this funcion cycle is not a constant?


Re: Object movement - Brian_G - 21.06.2010

Quote:
Originally Posted by Liustas
This is exactly the same code. This funcion shuld be looping, so this object shuld be created and destroyed with same time intervals. However sometimes this cycle tooks about 50 seconds, which is normal and sometimes about 2 minutes. So i want to ask why this funcion cycle is not a constant?
I changed it a bit just try it , replace with the old code.


Re: Object movement - Liustas - 21.06.2010

Still the same problem, works for the first few times then starts late.


Re: Object movement - Liustas - 23.06.2010

Any suggestions ?