09.02.2010, 20:10
Hi, me and some other people have a problem and we can't find a solution.
We think it's a samp-bug, so I report it here.
Train camera problem
This is the code:
Normally when you exit a vehicle the camera switches back to the player.
But when you spawn a vehicle and you emidiatly put yourself in the Freight/Streak/Tram and you exit the vehicle the camera is still behind the train and doesnt follow the player. (Look at the video)
This is only with the Freight/Streak/Tram because I think they use as special cameraposition.
We tried everything:
-OnPlayerExitVehicle
-OnPlayerKeyStateChange
-OnPlayerStateChange
PS: srry for f*cked up identation
We think it's a samp-bug, so I report it here.
Train camera problem
This is the code:
Code:
if(dialogid == 109 && response == 1) { if(listitem == 0) { new Float:x, Float:y, Float:z,Float:a, world, interior; GetPlayerPos(playerid, x, y, z); GetXYInFrontOfPlayer(playerid, x, y, 5.0); GetPlayerFacingAngle(playerid, a); world = GetPlayerVirtualWorld(playerid); interior = GetPlayerInterior(playerid); Geefveh = AddStaticVehicleEx(537, x, y, z + 2.0, a + 90.0, -1, -1, 5000); SetVehicleVirtualWorld(Geefveh, world); LinkVehicleToInterior(Geefveh, interior); PutPlayerInVehicle(playerid, Geefveh, 0); SendClientMessage(playerid, COLOR_WHITE, "Vehicle spawned!"); } if(listitem == 1) { new Float:x, Float:y, Float:z,Float:a, world, interior; GetPlayerPos(playerid, x, y, z); GetXYInFrontOfPlayer(playerid, x, y, 5.0); GetPlayerFacingAngle(playerid, a); world = GetPlayerVirtualWorld(playerid); interior = GetPlayerInterior(playerid); Geefveh = AddStaticVehicleEx(538, x, y, z + 2.0, a + 90.0, -1, -1, 5000); SetVehicleVirtualWorld(Geefveh, world); LinkVehicleToInterior(Geefveh, interior); PutPlayerInVehicle(playerid, Geefveh, 0); SendClientMessage(playerid, COLOR_WHITE, "Vehicle spawned!"); } if(listitem == 2) { new Float:x, Float:y, Float:z,Float:a, world, interior; GetPlayerPos(playerid, x, y, z); GetXYInFrontOfPlayer(playerid, x, y, 5.0); GetPlayerFacingAngle(playerid, a); world = GetPlayerVirtualWorld(playerid); interior = GetPlayerInterior(playerid); Geefveh = AddStaticVehicleEx(449, x, y, z + 2.0, a + 90.0, -1, -1, 5000); SetVehicleVirtualWorld(Geefveh, world); LinkVehicleToInterior(Geefveh, interior); PutPlayerInVehicle(playerid, Geefveh, 0); SendClientMessage(playerid, COLOR_WHITE, "Vehicle spawned!"); } return 1; }
But when you spawn a vehicle and you emidiatly put yourself in the Freight/Streak/Tram and you exit the vehicle the camera is still behind the train and doesnt follow the player. (Look at the video)
This is only with the Freight/Streak/Tram because I think they use as special cameraposition.
We tried everything:
-OnPlayerExitVehicle
-OnPlayerKeyStateChange
-OnPlayerStateChange
Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(IsPlayerInAnyVehicle(playerid)) { new m = GetVehicleModel(GetPlayerVehicleID(playerid)); if(m == 537 || m == 538 || m == 449) { if (newkeys & KEY_SECONDARY_ATTACK) { SetCameraBehindPlayer(playerid); } } } if(IsPlayerInAnyVehicle(playerid)) { new vehicleid = GetPlayerVehicleID(playerid); if(vehicleid == 537 || vehicleid == 538 ||vehicleid == 449) { if (newkeys & KEY_SECONDARY_ATTACK) { SetCameraBehindPlayer(playerid); } } } return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { if(vehicleid == 537 || vehicleid == 538 ||vehicleid == 449) { SetCameraBehindPlayer(playerid); } new m = GetVehicleModel(GetPlayerVehicleID(playerid)); if(m == 537 || m == 538 || m == 449) { SetCameraBehindPlayer(playerid); } return 1; } public OnPlayerStateChange(playerid,newstate,oldstate) { if(IsPlayerInAnyVehicle(playerid)) { new vehicleid = GetPlayerVehicleID(playerid); if(vehicleid == 537 || vehicleid == 538 || vehicleid == 449) { if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) { SetCameraBehindPlayer(playerid); } } } if(IsPlayerInAnyVehicle(playerid)) { new m = GetVehicleModel(GetPlayerVehicleID(playerid)); if(m == 537 || m == 538 || m == 449) { if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) { SetCameraBehindPlayer(playerid); } } } return 1; }