gerlachmax123 Posted February 3, 2013 Share Posted February 3, 2013 How I can check the Vehicle Health? I have it serverside online but getElementHealth must be clientside function reparierungszieltut(thePlayer) if ( getElementHealth(pruefungsrepVehicle) == 800 ) then outputChatBox ( "Nice Job!", player, 125, 0, 0 ) destroyElement(pruefungsrepVehicle) setElementPosition ( player, 1172.158, 1350.906, 10.922 ) setElementDimension ( player, 0 ) end end Pleas help me. Link to comment
Fury Posted February 3, 2013 Share Posted February 3, 2013 client; function getVehHealt() getElementHealth ( getPedOccupiedVehicle ( getLocalPlayer() ) end server; function getVehHealt() getElementHealth ( getPedOccupiedVehicle ( source ) end Link to comment
gerlachmax123 Posted February 3, 2013 Author Share Posted February 3, 2013 function getVehHealt() getElementHealth ( getPedOccupiedVehicle ( pruefungsrepVehicle ) end so? i need it serverside... Link to comment
Puma Posted February 3, 2013 Share Posted February 3, 2013 Read this page: https://wiki.multitheftauto.com/wiki/GetElementHealth Link to comment
gerlachmax123 Posted February 3, 2013 Author Share Posted February 3, 2013 I know, but i need getElementHealth serverside Link to comment
TAPL Posted February 3, 2013 Share Posted February 3, 2013 I know, but i need getElementHealth serverside getElementHealth is client side and server side. How about tell us what you are trying to do so we can help you? Link to comment
gerlachmax123 Posted February 3, 2013 Author Share Posted February 3, 2013 function reparierungszieltut(thePlayer) if ( getElementHealth(pruefungsrepVehicle) == 800 ) then outputChatBox ( "Nice Job!", player, 125, 0, 0 ) destroyElement(pruefungsrepVehicle) setElementPosition ( player, 1172.158, 1350.906, 10.922 ) setElementDimension ( player, 0 ) end end Ok, when the car (pruefungsrepVehicle) set on 800 then outputChatBox ( "Nice Job!", player, 125, 0, 0 ) But it will come not .... Link to comment
TAPL Posted February 3, 2013 Share Posted February 3, 2013 function reparierungszieltut(thePlayer) if ( getElementHealth(pruefungsrepVehicle) == 800 ) then outputChatBox ( "Nice Job!", player, 125, 0, 0 ) destroyElement(pruefungsrepVehicle) setElementPosition ( player, 1172.158, 1350.906, 10.922 ) setElementDimension ( player, 0 ) end end Ok, when the car (pruefungsrepVehicle) set on 800 then outputChatBox ( "Nice Job!", player, 125, 0, 0 ) But it will come not .... Where is the event or whatever the way you calling the function reparierungszieltut? Link to comment
gerlachmax123 Posted February 3, 2013 Author Share Posted February 3, 2013 I dont know how to do that .. Link to comment
Fury Posted February 3, 2013 Share Posted February 3, 2013 function reparierungszieltut(thePlayer) if ( getElementHealth(pruefungsrepVehicle) == 800 ) then outputChatBox ( "Nice Job!", player, 125, 0, 0 ) destroyElement(pruefungsrepVehicle) setElementPosition ( player, 1172.158, 1350.906, 10.922 ) setElementDimension ( player, 0 ) end end Ok, when the car (pruefungsrepVehicle) set on 800 then outputChatBox ( "Nice Job!", player, 125, 0, 0 ) But it will come not .... Where is the event or whatever the way you calling the function reparierungszieltut? he can use timer to check that. Link to comment
Fury Posted February 3, 2013 Share Posted February 3, 2013 (edited) how? function reparierungszieltut() if ( getElementHealth ( getPedOccupiedVehicle ( source ) ) == 800 ) then -- your code goes here end end setTimer ( reparierungszieltut, 1000, 0 ) this check player's healt in every 1 second. Edited February 3, 2013 by Guest Link to comment
gerlachmax123 Posted February 3, 2013 Author Share Posted February 3, 2013 Can i change the "source" to "pruefungsrepVehicle" ? Link to comment
Fury Posted February 3, 2013 Share Posted February 3, 2013 Can i change the "source" to "pruefungsrepVehicle" ? you can; function reparierungszieltut(pruefungsrepVehicle) if ( getElementHealth ( getPedOccupiedVehicle ( pruefungsrepVehicle ) ) == 800 ) then -- your code goes here end end setTimer ( reparierungszieltut, 1000, 0 ) Link to comment
gerlachmax123 Posted February 3, 2013 Author Share Posted February 3, 2013 function reparierungszieltut(pruefungsrepVehicle) if ( getElementHealth ( getPedOccupiedVehicle ( pruefungsrepVehicle ) ) == 800 ) then -- your code goes here end end setTimer ( reparierungszieltut, 1000, 0 ) This works serverside? Link to comment
Fury Posted February 3, 2013 Share Posted February 3, 2013 function reparierungszieltut(pruefungsrepVehicle) if ( getElementHealth ( getPedOccupiedVehicle ( pruefungsrepVehicle ) ) == 800 ) then -- your code goes here end end setTimer ( reparierungszieltut, 1000, 0 ) This works serverside? yes, its for server-side. Link to comment
Anderl Posted February 3, 2013 Share Posted February 3, 2013 The code is wrong. The function has one parameter, but setTimer doesn't pass any to it. Link to comment
Fury Posted February 3, 2013 Share Posted February 3, 2013 The code is wrong. The function has one parameter, but setTimer doesn't pass any to it. i used setTimer with that way a lot of time. not got any error at debug. Link to comment
Anderl Posted February 3, 2013 Share Posted February 3, 2013 You did it other way then, your code is wrong. Link to comment
Fury Posted February 3, 2013 Share Posted February 3, 2013 setTimer( function () if ( getElementHealth ( getPedOccupiedVehicle ( source ) ) == 800 ) then -- your code goes here end end, 1000, 0 ) Link to comment
Anderl Posted February 3, 2013 Share Posted February 3, 2013 It's still wrong, there's no source. Link to comment
Puma Posted February 3, 2013 Share Posted February 3, 2013 What vehicle do you want to check health for? Link to comment
gerlachmax123 Posted February 4, 2013 Author Share Posted February 4, 2013 pruefungsrepVehicle local pruefungsrepVehicle = createVehicle ( 507, 1174.229, 1339.781, 10.637, 359.764, 0, 180.851 ) --Elegant Link to comment
TAPL Posted February 4, 2013 Share Posted February 4, 2013 tt = setTimer(function() if isElement(pruefungsrepVehicle) and getElementHealth(pruefungsrepVehicle) <= 800 then local player = getVehicleController(pruefungsrepVehicle) if player then if isTimer(tt) then killTimer(tt) end destroyElement(pruefungsrepVehicle) outputChatBox("Nice Job!", player, 125, 0, 0) setElementPosition(player, 1172.158, 1350.906, 10.922) setElementDimension(player, 0) end end end, 3000, 0) 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