Jump to content

Need little help


-.Paradox.-

Recommended Posts

  • Moderators

First, why aren't you using local variables for drawY, nameWidth and teamWidth (95, 112 and 113) ?

Also drawY is never used ...

Second, why are you drawing 2 texts at line 116 and 117 ? Since only the color will change, only the second text (117) will be visible for the player. I'm guessing that it was for testing purposes.

And I couldn't understand the y calculation of the texts :shock:

It's looking like you tried random magic numbers untill you got the clan text at the position you wanted at.

You should get the text height of the player name, adding it to the y player name text and add a margin to get a little space between the two lines/texts.

Third, why are they two times the same if statements (121to123 and 124to126) ?? I'm guessing you want to draw the classicon on the left and on the right of the drawn texts. Well, you should put the two dxDrawImage in only one if statement.

If you can't see the images, there is 2 possible issues:

- the getElementData or the fileExists return false (or maybe both) so you never enter in that statement. You can easily check it by adding an outputChatBox before the 2 dxDrawImage like this:

if getElementData(player, "Classicon") and fileExists ( ":Class/class/classicon_"..getElementData(player, "Classicon")..".png" ) then 
    outputChatBox("I'm in !!") --It will flood your chatbox so remove it once you checked 
    dxDrawImage ( sx - math.max(nameWidth/2, teamWidth/2) - imageSize - 1*scale, sy - imageSize, imageSize, imageSize, ":Class/class/classicon_"..getElementData(player, "Classicon")..".png" ) 
    dxDrawImage ( sx + math.max(nameWidth/2, teamWidth/2) + 1*scale, sy - imageSize, imageSize, imageSize, ":Class/class/classicon_"..getElementData(player, "Classicon")..".png" ) 
end 

If it's flooding your chatbox with "I'm in !" then this wasn't the problem.

- The second one is just that your images are drawn out of the screen. So try to output the calculated position (x and y) of the images. if it's under 0 or over your screen resolution, then that's the problem.

Best regards,

Citizen

PS: Hey Solidsnake, it's been a long time :wink: I hope you still remember me (we were basically fighting to be the first to find the solutions :D). And according to the number of messages, you stayed active all the time. :o

I'm slowly coming back to MTA 8)

Cheers !

Link to comment

Try this:

if getElementData(player, "Classicon") and fileExists ( getElementData(player, "Classicon") ) then 
    outputChatBox("I'm in !!") --It will flood your chatbox so remove it once you checked 
    dxDrawImage ( sx - math.max(nameWidth/2, teamWidth/2) - imageSize - 1*scale, sy - imageSize, imageSize, imageSize, getElementData(player, "Classicon") ) 
    dxDrawImage ( sx + math.max(nameWidth/2, teamWidth/2) + 1*scale, sy - imageSize, imageSize, imageSize, getElementData(player, "Classicon") ) 
end 

If it doesn't work, then post the part where you set "Classicon" element data.

Link to comment
addEventHandler( 'onClientRender', root, 
 function ( ) 
 for i,v in ipairs ( getElementsByType( "player" ) ) do  
local x, y, z = getElementPosition( v );  
local cx, cy, cz = getCameraMatrix( ); if getDistanceBetween 
Points3D( cx, cy, cz, x, y, z ) <= 15 then  
local px,py = getScreenFromWorldPosition( x, y, z + 1.3, 0.06 );  
if px and py then 
 dxDrawImage( px, py, px, py, getElementData( v, "Classicon" ), 0, 0, 0, tocolor( 255, 255, 255, 255 ) ); 
 end  
end  
end  
end 
); 

Not working too but when I tried this it works but it show a big image and i want it to appear only in player head

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...