Jump to content

Hud_Messages


FuriouZ

Recommended Posts

Posted (edited)

ok no one don't help me .. :|

I explain more.

I have resource 'car locks'

function toggleVehicleLocked(thePlayer) 
    playervehicle=getPlayerOccupiedVehicle(thePlayer); 
    if(playervehicle) then 
        if(isVehicleLocked(playervehicle)) then 
            setVehicleLocked(playervehicle,false); 
            exports.hud_messages:showBox(Vehicle unlocked), player, 0, 255, 0, 200) 
        else 
            setVehicleLocked(playervehicle,true); 
            exports.hud_messages:showBox(Vehicle locked), player, 255, 0, 0, 200) 
        end 
    end 
end 

What is wrong here ?

Edited by Guest
  • Moderators
Posted

It should work, unless the player don't get send. Or the hudmessages isn't running.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)
It should work, unless the player don't get send. Or the hudmessages isn't running.

But it doesn't :| ,hudm_messages running... i cheked debugscript ,no errors ,also script is server-side

I really need it :?

EDIT:

Debugscript says something in line 25:

')' expected near 'unlocked' 

?

Edited by Guest
Posted

function toggleVehicleLocked(thePlayer) 
    playervehicle = getPlayerOccupiedVehicle(thePlayer); 
    if (playervehicle) then 
        if (isVehicleLocked(playervehicle)) then 
            setVehicleLocked(playervehicle,false); 
            exports.hud_messages:showBox(Vehicle unlocked.,thePlayer, 0, 255, 0, 200) 
        else 
            setVehicleLocked(playervehicle,true); 
            exports.hud_messages:showBox(Vehicle locked.,thePlayer, 255, 0, 0, 200) 
        end 
    end 
end 

  

Posted
function toggleVehicleLocked(thePlayer) 
    playervehicle = getPlayerOccupiedVehicle(thePlayer); 
    if (playervehicle) then 
        if (isVehicleLocked(playervehicle)) then 
            setVehicleLocked(playervehicle,false); 
            exports.hud_messages:showBox(Vehicle unlocked.,thePlayer, 0, 255, 0, 200) 
        else 
            setVehicleLocked(playervehicle,true); 
            exports.hud_messages:showBox(Vehicle locked.,thePlayer, 255, 0, 0, 200) 
        end 
    end 
end 

Doesn't work :|

Debug says

.lua:25: ')' expected near 'unlocked' 

Posted

The first argument in the function should be a string but you didn't use the quotation marks (you wrote Vehicle locked. but it should be "Vehicle locked.").

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

You're welcome.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...