Jump to content

A little problem here


tommymaster

Recommended Posts

In my server every vehicle, interior entrance, gate has a key. But my item system won't display the key item picture, until localPlayer hasn't got a "key:any number" at slot1. In other programs we can search for file names as picture.***, and the *** could mean any file extension there, in lua is there a way i can do like the same thing, but with numbers?

setElementData (localPlayer, "slot1", "key:"..1, true)

if getElementData (localPlayer, "slot1") == "key:"..all the int numbers.."" then
	--draw key image in inventory
else
	--slot 1 is blank
end

 

Link to comment

Not quite sure if I understand but it looks like you're trying to check if "slot1" contains any key and then proceed with some code.

There are different ways you can probably approach this. First is a table, which would be smarter because it is faster than element data and element data is not very safe. If this is the server side I think you should be fine but still personally I'd go with an actual table.

What you can do is just simply check if any element data exists on "slot1" by just doing

if getElementData (localPlayer, "slot1") then
	--draw key image in inventory
else
	--slot 1 is blank
end

if you set the "slot1" data to nil or false setElementData("slot1", nil) then it will return false and execute the second part of your code.

 

If this is not what you meant, please try to explain your issue a bit more.

Edited by Tails
  • Thanks 1
Link to comment

Hi! Slot1 is a place in inventory. Slot 1 could contain food, drinks, weapons, and keys. So if the player has a "key:"..mysqlID on his slot1 place in inventory, i would like a key icon to be drawn on the screen.

 

if getElementData (localPlayer, "slot1") == "key:"..0 then 

This would work, but it only draws the key if the slot1 elementdata is 0. I would like to see the key, whatever the number is behind the "key:" string.

Edited by tommymaster
Link to comment

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...