Zuqaa
April 13, 2017, 12:45am
1
I would like to put the jobs below money but his does not display
PS: I want to show the jobs of the addon loadout
sdf is my job
My code:
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold" title="roboto">
<link href="https://afeld.github.io/emoji-css/emoji.css" rel="stylesheet">
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script>
function addCommas(nStr) {
nStr += '';
var x = nStr.split('.');
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + '<span style="margin-left: 3px; margin-right: 3px;"/>' + '$2');
}
return x1 + x2;
}
window.onload = function(e){
// NUI Callback
window.addEventListener('message', function(event){
var item = event.data;
if(item.setmoney == true)
document.getElementById("cash").innerHTML = "<div><font style='color: rgb(0, 125, 0); font-weight: 700; margin-right: 6px;'>ā¬</font>" + addCommas(item.money);
if(item.addcash == true){
$(".tiny").remove();
var element = $("<div class='tiny'>+<font style='color: rgb(0, 125, 0); font-weight: 700; margin-right: 6px;'>ā¬</font>"+addCommas(item.money)+"</div>")
$("#money").append(element)
setTimeout(function(){
$(element).fadeOut(600, function() { $(this).remove(); })
}, 1000)
}
if(item.removecash == true){
$(".tiny").remove();
var element = $("<div class='tiny'>-<font style='color: rgb(250, 0, 0); font-weight: 700; margin-right: 6px;'>ā¬</font>"+addCommas(item.money)+"</div>")
$("#money").append(element)
setTimeout(function(){
$(element).fadeOut(600, function() { $(this).remove(); })
}, 1000)
}
if(LOADOUTS == sdf) then {
$(".tiny").remove();
var element = $("<div class='tiny'>+<font style='color: rgb(0, 125, 0); font-weight: 700; margin-right: 6px;'><i class="em em-tractor"></i></font>"+addCommas(LOADOUTS, sdf)+"</div>")
$("#sdf").append(element)
setTimeout(function(){
$(element).fadeOut(600, function() { $(this).remove(); })
}, 1000)
}
if(item.removeStartWindow == true){
$("#starter").remove();
}
if(item.setDisplay == true){
$("#money").css('opacity', item.display)
}
})
}
</script>
<style>
@font-face {
font-family: pcdown;
src: url(pdown.ttf);
}
.tiny {
font-size: 29px;
position: absolute; right: 10;
}
#money {
font-family: pcdown;
font-size: 35px;
color: white;
padding: 4px;
#sdf {
font-family: pcdown;
font-size: 35px;
color: white;
padding: 4px;
text-shadow:
-1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000;
}
#container {
position: absolute;
top: 40; right: 40;
}
</style>
</head>
<body>
<div id="starter" style="font-family: 'roboto'; color: white; position: absolute; left: 20%; top: 5%; width: 60%; background: rgba(40, 40, 40, 0.8)">
</div>
<div id="container">
<div id="money">
<div id="cash"/>
</div>
</div>
</body>
2 Likes
Zuqaa
April 13, 2017, 10:39am
2
up nobody know how to make this ???
Havoc
April 13, 2017, 12:25pm
3
Try the following:
Edit āessentialmode/ui.htmlā with the following:
Add the code below to the javascript:
if(item.setJob == true){
document.getElementById("job").innerHTML = "<font style='color: #FFFFFF; font-weight: 400;'>Job:</font> " + item.job;
}
Add <div id="job"></div>
below the āmoneyā div tags.
Edit āessentialmode/client/main.luaā
Add the following coode at the bottom of the file
RegisterNetEvent("es:setJobDisplay")
AddEventHandler("es:setJobDisplay", function(name)
SendNUIMessage({
setJob = true,
job = name
})
end)
Edit āfivem-loadouts/loadout/server.luaā
Add TriggerClientEvent("es:setJobDisplay", player, loadout.name)
to the end of the ādoLoadoutā event.
et voila!
You are now displaying the job (below?) with the money.
Note: This is a hack and should probably be put into itās own addon.
Zuqaa
April 13, 2017, 12:50pm
4
Havoc:
</div>
Thx ur the best !
the code is good ?
[details=Code]```
function addCommas(nStr) {
nStr += '';
var x = nStr.split('.');
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + '
' + '$2');
}
return x1 + x2;
}
window.onload = function(e){
// NUI Callback
window.addEventListener('message', function(event){
var item = event.data;
if(item.setmoney == true)
document.getElementById("cash").innerHTML = "<div><font style='color: rgb(0, 125, 0); font-weight: 700; margin-right: 6px;'>ā¬</font>" + addCommas(item.money);
if(item.addcash == true){
$(".tiny").remove();
var element = $("<div class='tiny'>+<font style='color: rgb(0, 125, 0); font-weight: 700; margin-right: 6px;'>ā¬</font>"+addCommas(item.money)+"</div>")
$("#money").append(element)
setTimeout(function(){
$(element).fadeOut(600, function() { $(this).remove(); })
}, 1000)
}
if(item.removecash == true){
$(".tiny").remove();
var element = $("<div class='tiny'>-<font style='color: rgb(250, 0, 0); font-weight: 700; margin-right: 6px;'>v</font>"+addCommas(item.money)+"</div>")
$("#money").append(element)
setTimeout(function(){
$(element).fadeOut(600, function() { $(this).remove(); })
}, 1000)
}
if(item.removeStartWindow == true){
$("#starter").remove();
}
if(item.setDisplay == true){
$("#money").css('opacity', item.display)
}
if(item.setJob == true){
document.getElementById("job").innerHTML = "<font style='color: #FFFFFF; font-weight: 400;'>MĆ©tiers:</font> " + item.job;
}
})
}
</script>
<style>
@font-face {
font-family: pcdown;
src: url(pdown.ttf);
}
.tiny {
font-size: 29px;
position: absolute; right: 10;
}
#money {
font-family: pcdown;
font-size: 35px;
color: white;
padding: 4px;
text-shadow:
-1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000;
}
#container {
position: absolute;
top: 40; right: 40;
}
</style>
</div>
<div id="container">
<div id="money">
<div id="cash"/>
<div id="job"></div>
</div>
</div>
```[/details]
Havoc
April 13, 2017, 12:51pm
5
Should be
<div id="money">
<div id="cash"/>
</div>
<div id="job"></div>
Zuqaa
April 13, 2017, 1:06pm
6
I have this error in the consoleā¦
Zuqaa
April 13, 2017, 1:11pm
7
ok its my fault i have resolved the error but i have an other error
Zuqaa
April 13, 2017, 1:12pm
8
and at the line 49 i have: TriggerClientEvent(āes:setJobDisplayā, player, loadout.name)
Zuqaa
April 13, 2017, 1:18pm
9
its good: D i have resolve the error
Zuqaa
April 13, 2017, 1:20pm
10
Ok now i have a question it is possible to make a menu for choose a jobā¦ The menu open with a marker at a specific position
Bonjour ,jāai modifier les fichier comme vous aviez dit mais jāai un decalage au niveau de lāaffichage et en nom de metier sa me mais āRANDOMā pouvez vous maider sāil vous plait .
je vous mais les fichier que jāai modifier pour que vous voyer ou se trouve mon erreur.
Hello, I have modified the files as you said but I have a shift in the display and in the name of metier its me but āRANDOMā can please you please.
I you but the file I have modified so that you see or find my error.
ui.html (2.7 KB)
main.lua (2.5 KB)
server.lua (8.1 KB)
voila comment lāaffichage se mais sur mon serveur.
Here is how the display happens but on my server.
Merci dāavance
thank you in advance
Formex
May 10, 2017, 12:04am
13
I have the same, do you know how can we fix it?