Jokeℝ1472771893 Posted May 14, 2012 Share Posted May 14, 2012 vehicleMarker = createMarker (938.79998779297,-1053.1999511719,30.60000038147, 'cylinder', 2.0, 16, 16, 16, 255 ) function vehicleMarkerHit ( hitElement, matchingDimension ) if ( isElement( hitElement ) and getElementType( hitElement ) == "player" and not isPedInVehicle (hitElement)) then local team = getPlayerTeam ( hitElement ) if ( getTeamName( team ) == "FBI" ) then local x, y, z = getElementPosition( hitElement ) local vehicle = createVehicle ( 490, 938.79998779297, -1050.5, 31.89999961853, 0, 0, 0 ) warpPedIntoVehicle( hitElement, vehicle ) else outputChatBox( "You must be on the FBI to use this.", hitElement, 255, 0, 0 ) end end end addEventHandler( "onMarkerHit", vehicleMarker , vehicleMarkerHit ) this make car onmarkerhit but how to make it like that when take first car and whant take second car first car disappear? Link to comment
Castillo Posted May 14, 2012 Share Posted May 14, 2012 You must create a table which will store player created vehicle. vehicleMarker = createMarker (938.79998779297,-1053.1999511719,30.60000038147, 'cylinder', 2.0, 16, 16, 16, 255 ) playerVehicles = { } function vehicleMarkerHit ( hitElement, matchingDimension ) if ( isElement ( hitElement ) and getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement ) ) then local team = getPlayerTeam ( hitElement ) if ( team and getTeamName ( team ) == "FBI" ) then local x, y, z = getElementPosition ( hitElement ) if ( isElement ( playerVehicles [ hitElement ] ) ) then destroyElement ( playerVehicles [ hitElement ] ) end playerVehicles [ hitElement ] = createVehicle ( 490, 938.79998779297, -1050.5, 31.89999961853, 0, 0, 0 ) warpPedIntoVehicle( hitElement, playerVehicles [ hitElement ] ) else outputChatBox( "You must be on the FBI to use this.", hitElement, 255, 0, 0 ) end end end addEventHandler ( "onMarkerHit", vehicleMarker , vehicleMarkerHit ) Link to comment
Kenix Posted May 14, 2012 Share Posted May 14, 2012 local pVehicleMarker = createMarker ( 938.79998779297, -1053.1999511719, 30.60000038147, 'cylinder', 2.0, 16, 16, 16, 255 ) local aPlayerVehicles = { } local function OnMarkerHit ( pHitElement ) if getElementType ( pHitElement ) == 'player' and not isPedInVehicle ( pHitElement ) then local pTeam = getPlayerTeam ( pHitElement ) if pTeam and getTeamName ( pTeam ) == 'FBI' then if isElement ( aPlayerVehicles [ pHitElement ] ) then destroyElement ( aPlayerVehicles [ pHitElement ] ) end aPlayerVehicles [ pHitElement ] = createVehicle ( 490, 938.79998779297, -1050.5, 31.89999961853, 0, 0, 0 ) setTimer( warpPedIntoVehicle, 200, 1, pHitElement, aPlayerVehicles [ pHitElement ] ) else outputChatBox( 'You must be on the FBI to use this.', pHitElement, 255, 0, 0 ) end end end addEventHandler ( 'onMarkerHit', pVehicleMarker , OnMarkerHit ) You should use warpPedIntoVehicle with timer. Link to comment
Stanley Sathler Posted May 14, 2012 Share Posted May 14, 2012 Kenix, we always must use a setTimer() to use warpPedIntoVehicle() ? Is more recommended? Or he must use only in this example? Link to comment
Kenix Posted May 14, 2012 Share Posted May 14, 2012 Always. While not fixed If you not use this function warpPedIntoVehicle with timer, this function not warped ped /player into vehicle. http://bugs.mtasa.com/view.php?id=6909 Link to comment
Stanley Sathler Posted May 14, 2012 Share Posted May 14, 2012 (edited) Strange, Kenix. Because I made this code: function CreateVehicleCommand(source, command, VehicleName) local VehicleModel = getVehicleModelFromName(VehicleName) local PlayerX, PlayerY, PlayerZ = getElementPosition(source) local Vehicle = createVehicle(VehicleModel, PlayerX+2, PlayerY+2, PlayerZ) warpPedIntoVehicle(source, Vehicle) end addCommandHandler("CreateVehicle", CreateVehicleCommand) It works, bro. Here, I'm warped to the vehicle (server-sided). Edited May 14, 2012 by Guest Link to comment
Kenix Posted May 14, 2012 Share Posted May 14, 2012 You need a risk? I think no. Anyway use this with timer. Link to comment
ben_wright Posted May 14, 2012 Share Posted May 14, 2012 timer isn't needed as far as I'm concerned. It's not a bug (or maybe it is), but you have to spawnPlayer first or it won't work. if it doesn't work, it's because of this, you can fetch more info from kenix's link Link to comment
Castillo Posted May 15, 2012 Share Posted May 15, 2012 In SAUR I had to use a 100 milliseconds timer to warp the player, because for some reason it teleports him really far in the sky, same happened when I gave myself a vehicle with the Admin Panel. Link to comment
yMassai Posted May 15, 2012 Share Posted May 15, 2012 In this case the player get only a team, but to get a skin? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now