Jump to content

dxDrawText ,"onClientMapStarting"


iiv03

Recommended Posts

hey the text not showing when map start why :/ where problem here?

sX, sY = guiGetScreenSize()

tables = {

	moveY = sY+sY*0.5,
	moveX = sX*0.5-sX*0,
	fontSize = 1.00,
	font = dxCreateFont("font/font.ttf",17) or "default-bold"

}

function render()
local x = tables.moveX
local y = tables.moveY
local width = sX*0.01 + tables.moveX
local height = sY*0.05
dxDrawText("Alpha 1.0.2 still work on Developer",x,y,width,height,tocolor(255,255,255,230),tables.fontSize,tables.font,"center","center",false)


setTimer(function () 
removeEventHandler("onClientRender",root,render) 
end,5000,1) 
end 
  
addEventHandler("onClientMapStarting",root,function () 
addEventHandler("onClientRender",root,render) 
end) 

 

lol i used that event onClientScreenFadedIn

and worked i don't know what happen :/

 

have another question how can i check command? in function like /random

use this?

https://wiki.multitheftauto.com/wiki/GetCommandHandlers

i wanna something if he type /random == then removeEventHandler

Edited by xFabel
Link to comment
  • Moderators
3 hours ago, xFabel said:

and worked i don't know what happen

Probably out of the screen.

 

dxDrawText doesn't require width and height.

It needs a start-point(x1,y1) and end-point(x2,y2).

Between those points is the box where your text is placed.

 

local startX, startY = 0, sY - (sY*0.5)
local endX, endY = sX, sY
dxDrawText("Alpha 1.0.2 still work on Developer",startX, startY, endX, endY, tocolor(255,255,255,230),tables.fontSize,tables.font,"center","center",false)

 

(I can't figure out the text position based on your code)

 

  • Like 1
Link to comment
20 minutes ago, IIYAMA said:

Probably out of the screen.

 

dxDrawText doesn't require width and height.

It needs a start-point(x1,y1) and end-point(x2,y2).

Between those points is the box where your text is placed.

 


local startX, startY = 0, sY - (sY*0.5)
local endX, endY = sX, sY
dxDrawText("Alpha 1.0.2 still work on Developer",startX, startY, endX, endY, tocolor(255,255,255,230),tables.fontSize,tables.font,"center","center",false)

 

(I can't figure out the text position based on your code)

 

I just did normal like that

dxDrawText("Alpha 1.0.2 still work on Developer",450,250,150,150,tocolor(255,255,255,230),tables.fontSize,tables.font,"center","center",false)

and didn't work what is the reason?

Edited by xFabel
Link to comment
  • Moderators
27 minutes ago, xFabel said:

I just did normal like that


dxDrawText("Alpha 1.0.2 still work on Developer",450,250,150,150,tocolor(255,255,255,230),tables.fontSize,tables.font,"center","center",false)

and didn't work what is the reason?

 

Also the moment for adding and removing the event can be better.

+ check if the event is triggered.

 


local displayDevTimer
addEventHandler("onClientMapStarting",root,function () 
	iprint("onClientMapStarting is triggered")
	if isTimer(displayDevTimer) then
		resetTimer(displayDevTimer)
		iprint("resetTimer")
	else
		addEventHandler("onClientRender",root,render)
		iprint("addEvent")
		displayDevTimer = setTimer(function () 
			removeEventHandler("onClientRender",root,render)
			displayDevTimer = nil
			iprint("removeEvent")
		end,5000,1) 
	end
end)

 

 

 

 

Edited by IIYAMA
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...