09.02.2014, 17:57
Quote:
pawn Код:
|
Quote:
Use a Timer..
Код:
//OnGameModeInit: SetTimer("RotateVehicle", 1000, 1); // e.g. bottom of your script: forward RotateVehicle(); public RotateVehicle() { new Float:angle; GetVehicleZAngle(vehicleid, angle); SetVehicleZAngle(vehicleid, angle + 5.0); // Turn vehicleid by 5 degrees } |
Both solutions you have supplied will not work... The SetVehicleZAngle only works when the vehicle is occupied. Making it completely useless in the situation that it's required for. I found this out through extensive bug testing with a vehicle respawn system I scripted. I ended up searching half the world looking for a solution on why the cars weren't rotating the way I'd scripted them too, until I stumbled across a post which actually stated that the "SetVehicleZAngle" function only works when the vehicle is occupied. If it's un-occupied you could pretty much say the script "looks over" it.
However.. I'm not going to leave without providing some kind of solution to you as I did in fact get my system to work. The way I got my system to work was actually by deleting the vehicle, and re-creating it with the same position as before but changing the Z / A (rotational) angle. So something along the lines of:
pawn Код:
//GetVehiclePos(vehicleid, &Float:X, &Float:Y, &Float:Z);
GetVehiclePos(VehID, X, Y, Z);
//GetVehicleZAngle(vehicleid, &Float:Z); -- May I also note that this function works even with un-occupied vehicles. It's only the "SetVehicleZAngle" that doesn't.
GetVehicleZAngle(VehID, A);
//DestroyVehicle(vehicleid);
DestroyVehicle(VehID);
//CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
CreateVehicle(model, X, Y, Z, A + 360, 0, 0, 5000);