gerlachmax123 Posted February 22, 2013 Share Posted February 22, 2013 Why this doesnt work? function getNearestVehicle( player ) local x, y, z = getElementPosition( player ) local prevDistance local nearestVehicle for i, v in ipairs( getElementsByType( "vehicle" ) ) do local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( v ) ) if distance <= ( prevDistance or distance + 1 ) then prevDistance = distance nearestVehicle = v end end return nearestVehicle or false end function doSomethingWithTheNearestVeh( player ) local vehicle = getNearestVehicle( player ) if vehicle then if not getPedOccupiedVehicle( player ) then if isfeuerwehr ( player ) then if (getPedWeapon (player) == 42) then if (getElementHealth ( vehicle ) <= 255 setPedAnimation( player, "FLAME", "FLAME_fire" ) setTimer( setPedAnimation, 15000, 1, player ) setElementHealth( vehicle, 255 ) else outputChatBox ( "Dieses Fahrzeug brennt nicht!", player, 125, 0, 0 ) end else outputChatBox ( "Du hast keinen Feuerloescher!", player, 125, 0, 0 ) end else outputChatBox ( "Du bist kein Mitglied der Feuerwehr!", player, 125, 0, 0 ) end else outputChatBox ( "Du musst vor der Motorhaube des Fahrzeuges stehen!", player, 125, 0, 0 ) end end end addCommandHandler( "loeschen", doSomethingWithTheNearestVeh ) And how i can set the distance to 5m ? So I can repair the Vehicle (thats burning) only in 5 m Link to comment
Castillo Posted February 22, 2013 Share Posted February 22, 2013 You must calculate the distance, you can use this: getElementPosition getDistanceBetweenPoints3D Link to comment
gerlachmax123 Posted February 22, 2013 Author Share Posted February 22, 2013 So? function getNearestVehicle( player ) local x, y, z = getElementPosition( player ) local prevDistance local nearestVehicle for i, v in ipairs( getElementsByType( "vehicle" ) ) do local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( v ) ) if distance <= ( prevDistance or distance + 1 ) then prevDistance = distance nearestVehicle = v end end return nearestVehicle or false end function doSomethingWithTheNearestVeh( player ) local vehicle = getNearestVehicle( player ) local x1, y1, z1 = getElementPosition ( vehicle ) local x2, y2, z2 = getElementPosition ( player ) if vehicle then if not getPedOccupiedVehicle( player ) then if isfeuerwehr ( player ) then if (getPedWeapon (player) == 42) then if getDistanceBetweenPoints3D ( x1, y1, z1, x2, y2, z2 ) < 5 then if (getElementHealth ( vehicle ) <= 255 setPedAnimation( player, "FLAME", "FLAME_fire" ) setTimer( setPedAnimation, 15000, 1, player ) setElementHealth( vehicle, 255 ) else outputChatBox ( "Dieses Fahrzeug brennt nicht!", player, 125, 0, 0 ) end else outputChatBox ( "Hier ist kein Fahrzeug zum Reparieren!", player, 125, 0, 0 ) end else outputChatBox ( "Du hast keinen Feuerloescher!", player, 125, 0, 0 ) end else outputChatBox ( "Du bist kein Mitglied der Feuerwehr!", player, 125, 0, 0 ) end else outputChatBox ( "Du musst vor der Motorhaube des Fahrzeuges stehen!", player, 125, 0, 0 ) end end end addCommandHandler( "loeschen", doSomethingWithTheNearestVeh ) Link to comment
gerlachmax123 Posted February 22, 2013 Author Share Posted February 22, 2013 fraktionen/feuerwehr/feuerwehr_server.lua:75: ')' expected (to close '(' at line 74) near 'setPedAnimation' Link to comment
iPrestege Posted February 22, 2013 Share Posted February 22, 2013 function getNearestVehicle( player ) local x, y, z = getElementPosition( player ) local prevDistance local nearestVehicle for i, v in ipairs( getElementsByType( "vehicle" ) ) do local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( v ) ) if distance <= ( prevDistance or distance + 1 ) then prevDistance = distance nearestVehicle = v end end return nearestVehicle or false end function doSomethingWithTheNearestVeh( player ) local vehicle = getNearestVehicle( player ) local x1, y1, z1 = getElementPosition ( vehicle ) local x2, y2, z2 = getElementPosition ( player ) if vehicle then if not getPedOccupiedVehicle( player ) then if isfeuerwehr ( player ) then if (getPedWeapon (player) == 42) then if getDistanceBetweenPoints3D ( x1, y1, z1, x2, y2, z2 ) < 5 then if (getElementHealth ( vehicle ) <= 255 ) then setPedAnimation( player, "FLAME", "FLAME_fire" ) setTimer( setPedAnimation, 15000, 1, player ) setElementHealth( vehicle, 255 ) else outputChatBox ( "Dieses Fahrzeug brennt nicht!", player, 125, 0, 0 ) end else outputChatBox ( "Hier ist kein Fahrzeug zum Reparieren!", player, 125, 0, 0 ) end else outputChatBox ( "Du hast keinen Feuerloescher!", player, 125, 0, 0 ) end else outputChatBox ( "Du bist kein Mitglied der Feuerwehr!", player, 125, 0, 0 ) end else outputChatBox ( "Du musst vor der Motorhaube des Fahrzeuges stehen!", player, 125, 0, 0 ) end end end addCommandHandler( "loeschen", doSomethingWithTheNearestVeh ) Link to comment
gerlachmax123 Posted February 22, 2013 Author Share Posted February 22, 2013 omg i forgot "then" ^^ thank you Link to comment
iPrestege Posted February 22, 2013 Share Posted February 22, 2013 You're Welcome And You Forgot ')' near then to ^^ . Link to comment
iPrestege Posted February 22, 2013 Share Posted February 22, 2013 Just Try To Use "debugscript 3" and you will find the problem or the wrong . Link to comment
gokalpfirat Posted February 22, 2013 Share Posted February 22, 2013 The basic missing end or missing closing things like " or ) are always be in debugscript Link to comment
50p Posted February 22, 2013 Share Posted February 22, 2013 The basic missing end or missing closing things like " or ) are always be in debugscript And in the MTA:SE syntax checker. Link to comment
iPrestege Posted February 22, 2013 Share Posted February 22, 2013 The basic missing end or missing closing things like " or ) are always be in debugscript And in the MTA:SE syntax checker. What is the MTA:SE ? Link to comment
gokalpfirat Posted February 22, 2013 Share Posted February 22, 2013 The basic missing end or missing closing things like " or ) are always be in debugscript And in the MTA:SE syntax checker. You are talking about this https://forum.multitheftauto.com/viewtop ... 7&p=338194 ? Link to comment
50p Posted February 22, 2013 Share Posted February 22, 2013 Check my signature "MTA Script Editor". I'm planning to release an update this weekend if things will follow the way I expect. Link to comment
iPrestege Posted February 22, 2013 Share Posted February 22, 2013 Check my signature "MTA Script Editor". I'm planning to release an update this weekend if things will follow the way I expect. Am Using It Thanks . Link to comment
gokalpfirat Posted February 22, 2013 Share Posted February 22, 2013 Check my signature "MTA Script Editor". I'm planning to release an update this weekend if things will follow the way I expect. Waiting for it because old version has got old functions and has some bugs Link to comment
50p Posted February 22, 2013 Share Posted February 22, 2013 Thanks. Bare in mind that it may seem basic now and some features not working properly if at all but I'm doing all I can do make it as bug free as possible. My first approach was wrong when I kept adding new things and fixed a few bugs now and then. Currently, I wait for people to report bug or give requests for new features before I start working on a new version so that I can fix the bugs first. Anyway, this is going off topic. If you want you can post in MTASE topic or PM with requests. I will also need a tester. 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