Jump to content

Help! Buttons with images


Recommended Posts

Posted

I am scripting a new userpanel for my clan and I want to make images and use them as buttons! My dilemma is that I cant do that! So what I basically want it to know a code for using images as buttons! Thank you! Just like TG and FFS!

Posted (edited)

When the user click (onClientGUIClick), you can get the mouse position and get the element (image) position. If is equal, execute your function.

Userful functions and events:

guiCreateStaticImage() --to create the image 
guiGetPosition() --to get the image position 
getCursorPosition() --to get the cursor position 
  
onClientGUIClick --event called when the player clicks on something 

Also, you will use some mathematics. You will need get the cursor position and calculate if the cursor is on the image (in other words, calculate if your cursor is in image_position + image_size)(I don't know explain much well).

Edited by Guest
Posted

you mean like this Darken ?

---clientSide 
addEventHandler('onClientGUIClick', root, 
function() 
local me = guiCreateStaticImage( 20, 200, 100, 100, "imagename.png", false ) 
if (source == me ) then 
triggerServerEvent('giveM4', localPlayer) 
end 
end) 
---serverSide 
addEvent('giveM4', true) 
addEvent('giveM4', root, 
function() 
giveWeapon ( source, 31, 200 ) 
end) 

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