05.08.2014, 19:31
I've made a simple vehicle system (work in progress) and it loads the vehicles position/angle on player login.
When the player types /park and relogs, the vehicles position/angle saves PERFECT.
When the player types /park and an admin respawns the vehicle, the vehicles position saves but angle is always 90 degrees off.
Here is the codes for the system, firstly here is the /park command:
This is the script which loads the vehicle position/angle on player login:
This is the OnVehicleSpawn callback:
If any more is really necessary, I can post it.
When the player types /park and relogs, the vehicles position/angle saves PERFECT.
When the player types /park and an admin respawns the vehicle, the vehicles position saves but angle is always 90 degrees off.
Here is the codes for the system, firstly here is the /park command:
Код:
CMD:park(playerid,params[]) { if(VehicleInfo[playerid][vModel] == 0) return SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} You don't own a vehicle."); { new vehicleid, Float:NewX, Float:NewY, Float:NewZ, Float:NewAngle; if(GetPlayerState(playerid) == 2) { vehicleid = GetPlayerVehicleID(playerid); if(vehicleid == PlayerVehicleID[playerid]) { GetPlayerPos(playerid,NewX,NewY,NewZ); GetVehicleZAngle(vehicleid,NewAngle); VehicleInfo[playerid][vParkedX] = NewX; VehicleInfo[playerid][vParkedY] = NewY; VehicleInfo[playerid][vParkedZ] = NewZ; VehicleInfo[playerid][vAngleZ] = NewAngle; SendClientMessage(playerid,-1,"{EE7600}You have successfully parked your vehicle, it will always respawn here unless you park it elsewhere."); } else SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} You are not in your vehicle."); } else SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} You are not in your vehicle."); } return 1; }
Код:
if(VehicleInfo[playerid][vModel] > 0) { new vehicleid, modelid, Float:X, Float:Y, Float:Z, Float:AngleZ, colour1, colour2; modelid = VehicleInfo[playerid][vModel]; X = VehicleInfo[playerid][vParkedX]; Y = VehicleInfo[playerid][vParkedY]; Z = VehicleInfo[playerid][vParkedZ]; AngleZ = VehicleInfo[playerid][vAngleZ]; colour1 = VehicleInfo[playerid][vPColour]; colour2 = VehicleInfo[playerid][vSColour]; vehicleid = CreateVehicle(modelid,X,Y,Z,AngleZ,colour1,colour2,-1); PlayerVehicleID[playerid] = vehicleid; SetVehicleZAngle(vehicleid,VehicleInfo[playerid][vParkedZ]); }
Код:
public OnVehicleSpawn(vehicleid) { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(vehicleid == PlayerVehicleID[i]) { new Float:X, Float:Y, Float:Z, Float:Angle; X = VehicleInfo[i][vParkedX]; Y = VehicleInfo[i][vParkedY]; Z = VehicleInfo[i][vParkedZ]; Angle = VehicleInfo[i][vAngleZ]; SetVehiclePos(vehicleid,X,Y,Z); SetVehicleZAngle(vehicleid,VehicleInfo[i][vParkedZ]); } } } return 1; }