Sign in to follow this  
slapztea

wanted level

Recommended Posts

Hello! Can you help me to write a script for wanted lvl.

I want to do so: there will be a picture in format png(star.png) and when player have (example 2 lvl wanted ) then two identical pictures will appear (star.png) in given coordinates(example under the hud).

Need custom script for wanted level not default.

Share this post


Link to post
local sw, sh = guiGetScreenSize()

local icon_width, icon_height = 20, 20 -- star.png width, height
local space = 1 -- space between icons
local x, y = sw - icon_width - 50, sh * 0.5 -- x, y position

addEventHandler("onClientRender", root,
function()
	for i = 1, getPlayerWantedLevel() do
		dxDrawImage(x + (icon_width + space) - i * (icon_width + space), y, icon_width, icon_height, "star.png")
	end
end)

 

Edited by SaNoR
  • Like 1

Share this post


Link to post

Or you could use a shader to replace the wanted star icons, that would allow you to keep using the built-in functions while displaying a custom icon.

Share this post


Link to post
5 hours ago, SaNoR said:

local sw, sh = guiGetScreenSize()

local icon_width, icon_height = 20, 20 -- star.png width, height
local space = 1 -- space between icons
local x, y = sw - icon_width - 50, sh * 0.5 -- x, y position

addEventHandler("onClientRender", root,
function()
	for i = 1, getPlayerWantedLevel() do
		dxDrawImage(x + (icon_width + space) - i * (icon_width + space), y, icon_width, icon_height, "star.png")
	end
end)

 

Can you tell me how to make the star size the same for all resolutions?

Share this post


Link to post
38 minutes ago, slapz0r said:

Can you tell me how to make the star size the same for all resolutions?

-- player's screen size width * (icon size / you'r screen size width) -- same with height

local sw, sh = guiGetScreenSize()
local mineX, mineY = 1280, 720 -- you'r current screen resolution (from video setting)

local icon_width, icon_height = sw * (20 / mineX), sh * (20 / mineY) -- star.png width, height
local space = sw * (1 / mineX) -- space between icons
local x, y = sw - icon_width - sw * (50 / mineX), sh * 0.5 -- x, y position

 

  • Like 1

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.