SoManyTears Posted March 30, 2020 Share Posted March 30, 2020 Hello MTA World, I prepared something so that the wanted level can be seen on the player's head.but with these codes, I have to have a wanted level to see the text on the head of the player.but I don't want this.I want everyone to see whoever has a wanted level.so what's wrong here? addEventHandler( "onClientRender",root, function( ) local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for k, player in pairs(getElementsByType("player",root, true)) do if(player ~= localPlayer) then local level = getPlayerWantedLevel ( player ) if ( level > 0 ) then tx, ty, tz = getElementPosition( player ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 30.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( player, 6 ) local x,y = getScreenFromWorldPosition( sx, sy, sz +0.7 ) if (x) then dxDrawText( "WANTED ["..level.."]", x-34, y+1, x+1, y+1, tocolor(0,0,0), 0.85 + ( 15 - dist ) * 0.030, "default-bold" ) dxDrawText( "WANTED ["..level.."]", x-35, y, x, y, tocolor(250,250,0), 0.85 + ( 15 - dist ) * 0.030, "default-bold" ) end end end end end end end ) Link to comment
SoManyTears Posted March 31, 2020 Author Share Posted March 31, 2020 can someone help ? Link to comment
The_GTA Posted March 31, 2020 Share Posted March 31, 2020 On 30/03/2020 at 19:30, SoManyTears said: Hello MTA World, I prepared something so that the wanted level can be seen on the player's head.but with these codes, I have to have a wanted level to see the text on the head of the player.but I don't want this.I want everyone to see whoever has a wanted level.so what's wrong here? Hello SoManyTears did you know that the clientside version of getPlayerWantedLevel does just return the wanted level of you, not other players? Think of every game client to be an isolated box that just returns data from the local game, if not otherwise requested through client-server interaction. What you have to do to fix this is transfer the wanted level of each player on-change to every other player. You can either monitor for wanted level change on the client and then send a server-event or monitor on the server using a timer + for all players loop. You must make sure that you only send the wanted level on a real change because you would otherwise kill the bandwidth of your server Hopefully this helps! 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now