Hugo_Almeidowski Posted January 22, 2019 Share Posted January 22, 2019 function showLocalHealth() -- get the player's health and output it local playerHealth = getElementHealth ( localPlayer ) outputChatBox ( "Your health: " .. playerHealth ) -- get the player's vehicle: if he is in one, output its health as well local playerVehicle = getPedOccupiedVehicle ( localPlayer ) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) / 10 -- Divide this by 10, as default the denominator is 1000 outputChatBox ( "Your vehicle's health: " .. vehicleHealth ) end end addCommandHandler ( "showhealth", showLocalHealth ) I copied this one directly from the MTA Wiki and it doesn't work. I receive no message. Why? And how to fix it? Link to comment
Moderators DNL291 Posted January 22, 2019 Moderators Share Posted January 22, 2019 It should work, I see no errors by looking at the code. Make sure to set it as client-side in meta.xml and type the command correctly. Link to comment
Hugo_Almeidowski Posted January 22, 2019 Author Share Posted January 22, 2019 49 minutes ago, DNL291 said: It should work, I see no errors by looking at the code. Make sure to set it as client-side in meta.xml and type the command correctly. (sou português, mas não sei se posso falar português aqui) It was on a server-side script, that was the problem. Anyways I can make it into a server-side? And could you take answer me some small questions please? Link to comment
Moderators DNL291 Posted January 22, 2019 Moderators Share Posted January 22, 2019 Se quiser postar em português use a seção Portuguesa, aqui: Portuguese / Português Server-side version: function showLocalHealth( thePlayer ) -- get the player's health and output it local playerHealth = getElementHealth ( thePlayer ) outputChatBox ( "Your health: " .. playerHealth ) -- get the player's vehicle: if he is in one, output its health as well local playerVehicle = getPedOccupiedVehicle ( thePlayer ) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) / 10 -- Divide this by 10, as default the denominator is 1000 outputChatBox ( "Your vehicle's health: " .. vehicleHealth, thePlayer ) end end addCommandHandler ( "showhealth", showLocalHealth ) Link to comment
Hugo_Almeidowski Posted January 23, 2019 Author Share Posted January 23, 2019 On 22/01/2019 at 19:27, DNL291 said: Se quiser postar em português use a seção Portuguesa, aqui: Portuguese / Português Server-side version: function showLocalHealth( thePlayer ) -- get the player's health and output it local playerHealth = getElementHealth ( thePlayer ) outputChatBox ( "Your health: " .. playerHealth ) -- get the player's vehicle: if he is in one, output its health as well local playerVehicle = getPedOccupiedVehicle ( thePlayer ) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) / 10 -- Divide this by 10, as default the denominator is 1000 outputChatBox ( "Your vehicle's health: " .. vehicleHealth, thePlayer ) end end addCommandHandler ( "showhealth", showLocalHealth ) Thanks!! 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