Rockstar23 Posted June 23, 2010 Share Posted June 23, 2010 Hey there, I was wanting to make a text above the players heads that shows what mode they are in but I am not very familiar with (I guess it's called 3D text) that kind of text. I already have a function called modeName that will return the name of the mode they are in but I don't know what to do to create the text. Sorry for this newbish question I am just new to MTA:SA scripting. Link to comment
50p Posted June 23, 2010 Share Posted June 23, 2010 You want to use client-side drawing functions. If your function that returns mode is server-side, use setElementData and sync it so then you can use getElementData client-side to get mode. Check my peds resource and use https://wiki.multitheftauto.com/wiki/DxDrawText to draw the text instead of drawing health bars. You'll need to use onClientRender event to draw text every frame, getPedBonePosition to get player's neck position and getScreenFromWorldPosition to get screen position of that bone. Link to comment
dzek (varez) Posted June 23, 2010 Share Posted June 23, 2010 like this? https://community.multitheftauto.com/index.html?p ... ils&id=383 Link to comment
Rockstar23 Posted June 23, 2010 Author Share Posted June 23, 2010 like this?https://community.multitheftauto.com/index.html?p ... ils&id=383 Yes I mean something like that but I want it to stay. You want to use client-side drawing functions. If your function that returns mode is server-side, use setElementData and sync it so then you can use getElementData client-side to get mode.Check my peds resource and use https://wiki.multitheftauto.com/wiki/DxDrawText to draw the text instead of drawing health bars. You'll need to use onClientRender event to draw text every frame, getPedBonePosition to get player's neck position and getScreenFromWorldPosition to get screen position of that bone. Sounds complicated. I don't like things being complicated. Link to comment
MaddDogg Posted June 23, 2010 Share Posted June 23, 2010 I don't like things being complicated. Then you should leave your hands off of those topics, because they are inevitably a bit of work. I just did a very similar script yesterday, where there are texts above pickups, and it took me 5 minutes. It's not that hard. 50p gave you a good start, it is probably the best way to do it. Link to comment
50p Posted June 23, 2010 Share Posted June 23, 2010 It's the most accurate way I'd say and not hard at all. What's so hard about this snippet? addEventHandler( "onClientRender", getRootElement(), function( ) for _, plr in ipairs( getElementsByType( "player" ) ) do local x, y, z = getPedBonePosition( plr, 8 ); -- head local sX, sY = getScreenFromWorldPosition( x, y, z ); if sX then dxDrawText( get_your_player_modename, sX, sY ) end end end ) Link to comment
Rockstar23 Posted June 23, 2010 Author Share Posted June 23, 2010 It's the most accurate way I'd say and not hard at all. Then you should leave your hands off of those topics, because they are inevitably a bit of work. Well i'm fourteen and don't like big words. Link to comment
Xierra Posted June 23, 2010 Share Posted June 23, 2010 Well I'm even younger, 13 and I obey what they said. Cmon, do some effort, there is no way you could waste time when you go script it. Link to comment
Rockstar23 Posted June 23, 2010 Author Share Posted June 23, 2010 Well I'm even younger, 13 and I obey what they said. Cmon, do some effort, there is no way you could waste time when you go script it. Well i've been scripting like 5 different servers that all have different languages so I get jumbled up and dont know what im saying sometimes. That's why I really need help with this. Link to comment
50p Posted June 23, 2010 Share Posted June 23, 2010 If you've scripted in the past (not necessarily in Lua) then you shouldn't have problems understanding this script. BTW, I don't know what's so big about that sentence you quoted me Link to comment
Rockstar23 Posted June 23, 2010 Author Share Posted June 23, 2010 So I did this: local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution function createText ( ) local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() ) dxDrawText(modeName(playerData.mode), 44, screenHeight-41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) dxDrawText(modeName(playerData.mode), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) end function HandleTheRendering() addEventHandler("onClientRender",rootElement, createText) -- keep the text visible with onClientRender. end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) But it's not doing anything, i'm guessing that the script has to be defined as a client script? Link to comment
50p Posted June 23, 2010 Share Posted June 23, 2010 Yes it has to be a client-side script... If you have read my first post then you'd know the script has to be client-side. Your code will draw the text at the left bottom of the screen. If you'll use my script, you'll have the text above heads or rather on the head. My code is exactly what you want.. All you need to change is the variable I used in the 1st dxDrawText argument. Link to comment
Rockstar23 Posted June 23, 2010 Author Share Posted June 23, 2010 It works but it's only returning "Racing" EDIT: Solved. 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