I’m in desperate need of a head tag system for my RP server. I’ve seen it on other servers where the player has an ID number displayed above their head and it turns blue to indicate they’re talking. I can’t for the life of me figure this out and I desperately need it to be able to moderate my RP server effectively. Does anyone know of a script that already does this or how to make one? I’ve found a few head display scripts but none of them do what I’m looking for.
Learn LUA and do it yourself…
Thanks for the help, I’ve been trying but I can’t seem to get it to work myself. Plus, it seems it’s already been done, no need to duplicate someone else’s work if it’s already been done. Seems counter-productive to the community.
Unfortunately not everyone releases their stuff to the community, so we have to do some already existing stuff again. So just learn it and do it!
I’m trying man, but it’s a frustrating battle. I’ve not much experience with coding myself, but I have bashed together a few things for Arma 2. My main problem is I have no idea where I’m going wrong. I don’t know how to pull the user id from the vrp database and get it to display above the head, so far the furthest I’ve gotten was getting a headset to display above the user when they’re talking. It seems like damn near every server has this feature, so I can’t imagine it’s some super-secret hidden script.
Is it me or there are more experienced people who take the newbies as professionals and are able to do it all? It is not everyone who have a learning facility, no one is the same.What xslic want is something that maybe I want to. I have a good base in computer science but not in programming LUA script
It’s hard to learn something when you don’t even have a clue what might be wrong. I don’t know if I’m using the wrong calls for FiveM, the VRP plugin or if it’s a LUA syntax error, anything. I just keep trying and trying and eventually stuff works or it doesn’t, if it doesn’t I have no idea why.
I didn’t take a look at the entire library yet, but you should be able to call an UI element on an OnTick method on your character with an high Z axis (usually it’s Y in the 3d world but I don’t know why people keep using Z coord lol), example of code on the go in C#, sorry if it’s not in lua:
Ped char = Game.Player.Character;
UIElement element = new UIElement(); // UIElement doesn't exist don't worry, I've just created one on the go
...
public async OnTick()
{
// Draw texture over the player THIS METHOD DOESN'T EXIST IN CITIZENFX LIBRARY!!
UI.DrawTexture(element, char.Position.X, char.Position.Y, char.Position.Z + 5f, .......);
}
Sorry again if it’s in C#, but I don’t know the lua library of this game very well, I’m sure you’re able to translate it alone
Also @Flatracer if you don’t know how to do something, instead of hiding it into worthless comments, you may TRY to help a little bit
Citizen.CreateThread(function()
while true do
Wait( 1 )
-- show blips
for id = 0, 32 do
if NetworkIsPlayerActive( id ) then -- and GetPlayerPed( id ) ~= GetPlayerPed( -1 )
ped = GetPlayerPed( id )
--blip = GetBlipFromEntity( ped )
-- HEAD DISPLAY STUFF --
-- Create head display (this is safe to be spammed)
if GetPlayerPed( id ) ~= GetPlayerPed( -1 ) then
headDisplayId = N_0xbfefe3321a3f5015(ped, tonumber(GetPlayerId(i)), false, false, "", false )
end
if (GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), GetEntityCoords(GetPlayerPed(id))) < 30.0001) and HasEntityClearLosToEntity(GetPlayerPed(-1), GetPlayerPed(id), 17) then
N_0x63bb75abedc1f6a0(headDisplayId, 9, true)
N_0xd48fe545cd46f857(headDisplayId, 9, 255)
else
N_0x63bb75abedc1f6a0(headDisplayId, 0, false)
end
if NetworkIsPlayerTalking(id) then
N_0x63bb75abedc1f6a0(headDisplayId, 9, true)
N_0xd48fe545cd46f857(headDisplayId, 9, 255)
else
N_0x63bb75abedc1f6a0(headDisplayId, 9, false)
end
end
end
end
end)
This is basically what I have so far. I want it to display the user’s ID above his head, but I’m not sure if I’m using the correct calls or whatever. It’s based on another script I found here. I also want it to just change the color of the user id to blue instead of turning the icon into a speaker, but that’s as close as I’ve gotten thus far.
I know how to do it and could probably do exactly what he want. My problem is, that the most ppl here are just creating an account and logging in, if they need something. The most of them don’t even try to do something by themself and just request shit!
I’ve been working on this server for weeks and this is the first time I’ve asked for outside help. I’m a big fan of trying to figure things out for myself. Perhaps you could point me in the right direction?
Could you at least tell me if I need to hook it to the VRP user id’s or the server user ids? I’ve noticed they’re different for kicking/banning purposes. E.G. Sometimes user 4 is the 4th user connected to the server, meanwhile user 4 in the VRP database could be a completely different user…
I think I just answered my own question, now to figure out how to get it to look at that database for the user id.
Right, I’m not going to tell you what to do. Instead, I’m going to try and help you understand what’s happening a bit more so you can hopefully make the changes for yourself (sorry, no spoon feeding you code ).
Anyways, I would start by making the code more readable. Currently, your code calls native functions by their Hex code. Most of these have been updated in the latest version so, before you start make sure your script is using the latest manifest.
Now, you can change the horrible function names to their updated ones. To do this, you’re going to need to do a bit of leg work. Don’t worry, it’s not that hard. So, first we need to get the Hex code of the function. This is basically the 0xXYZ stuff. So, for the function N_0x63bb75abedc1f6a0, the hex code would be 0x63bb75abedc1f6a0. Now, go to https://runtime.fivem.net/doc/reference.html and find your hex code (CTRL+F and paste the code). This should give you a function name (e.g. SET_MP_GAMER_TAG_VISIBILITY).
Now, transform this into PascalCase. So, remove all underscores (except ones at the beginning) and only capitalize the first letter of each word. For example, SET_MP_GAMER_TAG_VISIBILITY would become SetMpGamerTagVisibility. Replace the horrible function name (N_0x63bb75abedc1f6a0) with the one you’ve just created. This should allow you to see better what the script is doing, it should also give you some insight into what parameters each functions take. Giving you enough information to change it to your needs
Hope this helps you figure out what you need to do in order to achieve your goals.
I know you feels , almost 2 month that I work with somebody else to build a great server without errors . I find this difficult AF …but we are in a great way to open it one day .
Thank you so much, I appreciate it man.
Citizen.CreateThread(function()
while true do
Wait( 1 )
-- show blips
for id = 0, 32 do
if NetworkIsPlayerActive( id ) then -- and GetPlayerPed( id ) ~= GetPlayerPed( -1 )
ped = GetPlayerPed( id )
--blip = GetBlipFromEntity( ped )
-- HEAD DISPLAY STUFF --
-- Create head display (this is safe to be spammed)
if GetPlayerPed( id ) ~= GetPlayerPed( -1 ) then
headDisplayId = SetMpGamerTagVisibility(ped, "tonumber(GetPlayerId)", false, false, "", false )
end
if (GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), GetEntityCoords(GetPlayerPed(id))) < 30.0001) and HasEntityClearLosToEntity(GetPlayerPed(-1), GetPlayerPed(id), 17) then
SetMpGamerTagVisibility(headDisplayId, 9, true)
SetMpGamerTagAlpha(headDisplayId, 9, 255)
else
SetMpGamerTagVisibility(headDisplayId, 0, false)
end
if NetworkIsPlayerTalking(id) then
SetMpGamerTagVisibility(headDisplayId, 9, true) -- Speaker
SetMpGamerTagAlpha(headDisplayId, 9, 255) -- Alpha
else
SetMpGamerTagAlpha(headDisplayId, 9, false) -- Speaker Off
end
end
end
end
end)
Now it looks like that, my problem is actually the code to get it to display the user id instead of what I have written in the quotes…
headDisplayId = SetMpGamerTagVisibility(ped, “tonumber(GetPlayerId)”, false, false, “”, false )
^ how do I get that line to pull the user’s id and display it above their head? As it sits right now it just says “tonumber” above everyone’s head. There’s something wrong with the syntax in that line, but I’m not exactly sure how it should be written.
Are you tying to display the player’s server ID?
If so, there’s a native for that
You can use it in the loop using “id” as the player parameter (the same way you’re using GetPlayerPed)
Edit: all you’d have to do is transform it into a string. E.g.
SetMpGamerTagVisibility(ped, GetPlayerServerId( player ) .. "", false, false, "", false )
So the 2 periods before the quotes tell the script to insert the called id numer INTO the quotes and display it?
Not exactly, it’s the operator to concat two strings together (read more here).
Basically, it tells Lua to concatenate the number with an empty string (turns the number into a string).
Its called concatenation. Its not exactly putting it into the quotes. Its just displaying it. https://www.lua.org/pil/3.4.html
I guess that’s what I’m failing to understand. How exactly do I pull that user id and get it to display like that? What do you mean by transforming it into a string? I’m trying to understand, my brain just hurts lol.
edit Well, I found one problem. Accidentally named the wrong function at first.
Citizen.CreateThread(function()
while true do
Wait( 1 )
-- show blips
for id = 0, 32 do
if NetworkIsPlayerActive( id ) then -- and GetPlayerPed( id ) ~= GetPlayerPed( -1 )
ped = GetPlayerPed( id )
--blip = GetBlipFromEntity( ped )
-- HEAD DISPLAY STUFF --
-- Create head display (this is safe to be spammed)
if GetPlayerPed( id ) ~= GetPlayerPed( -1 ) then
headDisplayId = SetMpGamerTagVisibility(ped, GetPlayerServerId( player ) .. "", false, false, "", false )
end
if (GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), GetEntityCoords(GetPlayerPed(id))) < 30.0001) and HasEntityClearLosToEntity(GetPlayerPed(-1), GetPlayerPed(id), 17) then
SetMpGamerTagVisibility(headDisplayId, 9, true)
SetMpGamerTagAlpha(headDisplayId, 9, 255)
else
SetMpGamerTagVisibility(headDisplayId, 0, false)
end
if NetworkIsPlayerTalking(id) then
SetMpGamerTagVisibility(headDisplayId, 9, true) -- Speaker
SetMpGamerTagAlpha(headDisplayId, 9, 255) -- Alpha
else
SetMpGamerTagAlpha(headDisplayId, 9, false) -- Speaker Off
end
end
end
end
end)
That is my current script and nothing is working now.