To create a phone NUI with a PNG border and contents inside the border, you can use HTML, CSS, and JavaScript along with FiveM's NUI (Native User Interface) functionality. You can follow these steps:
-
Create a phone folder in your resource directory to store your HTML, CSS, and JavaScript files, along with the phone border PNG image.
-
Inside the phone folder, create an html folder to store your HTML file. Create a new file called index.html and add the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Phone</title>
<link rel="stylesheet" href="../css/styles.css">
</head>
<body>
<div id="phone-container">
<img src="../images/phone-border.png" alt="Phone Border">
<div id="phone-content">
<!-- Add your phone content here -->
</div>
</div>
<script src="../js/phone.js"></script>
</body>
</html>
- In the
phone folder, create a css folder and add a file called styles.css. This CSS file will position the phone border and the content correctly. Add the following CSS code:
body {
margin: 0;
font-family: 'Arial', sans-serif;
}
#phone-container {
position: relative;
display: inline-block;
}
#phone-content {
position: absolute;
top: /* Set the appropriate value */;
left: /* Set the appropriate value */;
width: /* Set the appropriate value */;
height: /* Set the appropriate value */;
overflow: hidden;
}
Replace the comments with appropriate values to match the position and size of your phone border image.
-
In the phone folder, create a js folder and add a new JavaScript file called phone.js. This will handle any actions needed for interacting with your NUI.
-
(Optional) Add your phone contents inside the phone folder and link the necessary files in the index.html file.
-
Modify your resource __resource.lua or fxmanifest.lua file to include your NUI interface. You should add the following lines:
-- In __resource.lua
ui_page('phone/html/index.html')
files({
'phone/html/index.html',
'phone/css/styles.css',
'phone/js/phone.js',
'phone/images/phone-border.png'
})
-- In fxmanifest.lua
ui_page 'phone/html/index.html'
files {
'phone/html/index.html',
'phone/css/styles.css',
'phone/js/phone.js',
'phone/images/phone-border.png'
}
With these steps completed, your NUI phone interface should display the phone border PNG with phone contents placed inside the border. You can use JavaScript with FiveM's NUI callbacks to interact with the game world and display the relevant information or actions in your phone GUI.