Jump to content

Biggest noob issue ever.


Eshtiz

Recommended Posts

Ok, so I'm trying to learn lua, I know like MINIMUM,

anyways, I'm trying my way with dxDrawText and bumps into a problem which I cannot seem to fix, I tried and tried and kept getting errors on line 1: expected #, ), ( and so on.

https://wiki.multitheftauto.com/wiki/DxDrawText

Most is copied from there as I'm trying to learn.

This is what I got:

bool= dxDrawText= ( )  string text, int left, int top [, int right=left, int bottom=top, int color=white,  
                  float scale=1, mixed font="default", string alignX="left", string alignY="top", 
                  bool clip=false, bool wordBreak=false, bool postGUI=false ] ) 
  
local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) 
  
  
function createText ( ) 
    local playerX, playerY, playerZ = getElementPosition ( localPlayer )       -- Get our player's coordinates. 
    local playerZoneName = getZoneName ( playerX, playerY, playerZ )          -- Get name of the zone the player is in. 
  
    -- Draw zone name text's shadow. 
    dxDrawText ( playerZoneName, 44, screenHeight - 41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "bankgothic" ) 
    -- Draw zone name text. 
    dxDrawText ( playerZoneName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" )  
end 
  
function HandleTheRendering ( ) 
    addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. 
root = getRootElement () 
function updateCamera () 
    local x, y, z = getElementPosition ( getLocalPlayer () ) 
    setCameraMatrix ( x, y, z + 50, x, y, z ) 
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) 

And a small side-question:

where do I find functions/texts like this?:

function createText ( ) 
    local playerX, playerY, playerZ = getElementPosition ( localPlayer )       -- Get our player's coordinates. 
    local playerZoneName = getZoneName ( playerX, playerY, playerZ )          -- Get name of the zone the player is in. 

Edited by Guest
Link to comment
  
local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) 
  
  
function createText ( ) 
    local playerX, playerY, playerZ = getElementPosition ( localPlayer )       -- Get our player's coordinates. 
    local playerZoneName = getZoneName ( playerX, playerY, playerZ )          -- Get name of the zone the player is in. 
  
    -- Draw zone name text's shadow. 
    dxDrawText ( playerZoneName, 44, screenHeight - 41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "bankgothic" ) 
    -- Draw zone name text. 
    dxDrawText ( playerZoneName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" )  
end 
  
function HandleTheRendering ( ) 
    addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. 
root = getRootElement () 
function updateCamera () 
    local x, y, z = getElementPosition ( getLocalPlayer () ) 
    setCameraMatrix ( x, y, z + 50, x, y, z ) 
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) 

Try this.

Link to comment

Thanks, worked, but had to add another 'end' in the last part,

but what did you do exactly? Can't see any difference a part from the top part being removed and I aldready tried with / without it aldready and it didn't work.

EDIT: How do I move around the texts? to different corners / sides?

Link to comment

top part is copy from wiki. That says what arguments can be passed to function. I dont know how to explain. I'm only beginer of LUA but I have experience in programming/scripting

All serverside functions: https://wiki.multitheftauto.com/wiki/Server_Scripting_Functions

All clientside functions: https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions

Main wiki page: https://wiki.multitheftauto.com/wiki/Main_Page

And sorry for my English. It isn't my first language.

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...