Attaching objects to vehicles -
sim_sima - 25.06.2013
Hi guys.
I am scripting something, which includes attaching 2 objects to a vehicle.
When a player types a command, one of the objects will be attached to the vehicle, and after one second, the other object will be attached to the vehicle. I know this is simple to do with timers, but is there any way to avoid using a timer? I know that some other scripting languages have "wait" functions.
Hope you can help. Thanks.
Re: Attaching objects to vehicles -
dEcooR - 25.06.2013
yes of course maybe with functions gettime() not?
Re: Attaching objects to vehicles -
sim_sima - 25.06.2013
Quote:
Originally Posted by dEcooR
yes of course maybe with functions gettime() not?
|
gettime is used to get the time in the server. This has nothing with that to do.
Thanks for your time though.
Re: Attaching objects to vehicles -
DeMoX - 25.06.2013
Try this:
pawn Код:
wait(seconds)
{
new _newTime[4], _oldTime[4];
gettime(_oldTime[0], _oldTime[1], _oldTime[2]);
_oldTime[3] = _oldTime[2] + (_oldTime[1] * 60) + (_oldTime[0] * 600);
while(_newTime[3] != (_oldTime[3] + seconds))
{
gettime(_newTime[0], _newTime[1], _newTime[2]);
_newTime[3] = _newTime[2] + (_newTime[1] * 60) + (_newTime[0] * 600);
}
}
Then use wait(1);
To wait one sec
And yeah GetTime() will help.
Read this
V
Edit: Wait fonction freezes the server, use this include :
Sleep
Re: Attaching objects to vehicles -
Mennims - 26.06.2013
Hello guys I need help I have my code but where do I put it? Under what function?
new objectid = CreateObject(10245);
new vehicleid = GetPlayerVehicleID(playerid);
AttachObjectToVehicle(objectid, vehicleid, 0.0303, 1.6107, 6.4743, 0.0000, 0.0000, 314.6721);
Thanks in advance
Re: Attaching objects to vehicles -
Pottus - 26.06.2013
Quote:
Originally Posted by DeMoX
Try this:
pawn Код:
wait(seconds) { new _newTime[4], _oldTime[4]; gettime(_oldTime[0], _oldTime[1], _oldTime[2]); _oldTime[3] = _oldTime[2] + (_oldTime[1] * 60) + (_oldTime[0] * 600);
while(_newTime[3] != (_oldTime[3] + seconds)) { gettime(_newTime[0], _newTime[1], _newTime[2]); _newTime[3] = _newTime[2] + (_newTime[1] * 60) + (_newTime[0] * 600); } }
Then use wait(1);
To wait one sec
And yeah GetTime() will help.
Read this
V
Edit: Wait fonction freezes the server, use this include : Sleep
|
All of this is non-sense you don't want to prevent your script from working, just use a timer what is the big deal ? Usually people use timers when they don't have to your trying to do the opposite by not using timers. However what your trying to do won't work unless a timer is used.
If it's syntax your looking for try y_timers
https://sampforum.blast.hk/showthread.php?tid=182948 your looking for this part.
pawn Код:
timer DelayedTimer[500](playerid)
{
printf("May be called after 0.5 seconds");
}
main()
{
defer DelayedTimer(42);
}
I don't think it could be easier to read than that.
Re: Attaching objects to vehicles -
sim_sima - 27.06.2013
Quote:
Originally Posted by [uL]Pottus
All of this is non-sense you don't want to prevent your script from working, just use a timer what is the big deal ? Usually people use timers when they don't have to your trying to do the opposite by not using timers. However what your trying to do won't work unless a timer is used.
If it's syntax your looking for try y_timers https://sampforum.blast.hk/showthread.php?tid=182948 your looking for this part.
pawn Код:
timer DelayedTimer[500](playerid) { printf("May be called after 0.5 seconds"); }
main() { defer DelayedTimer(42); }
I don't think it could be easier to read than that.
|
Alright, thanks!