Jump to content

Dxdrawtext why not working?


Turbe$Z

Recommended Posts

local screenW, screenH = guiGetScreenSize()

local GUIEditor = {
    button = {},
    window = {},
    edit = {}
}

        GUIEditor.window[1] = guiCreateWindow(0.35, 0.40, 0.32, 0.12, "Event hírdető panel", true)
        guiWindowSetSizable(GUIEditor.window[1], false)
        GUIEditor.button[1] = guiCreateButton(0.04, 0.68, 0.78, 0.23, "Beírt szöveg kiírása", true, GUIEditor.window[1])
        GUIEditor.edit[1] = guiCreateEdit(0.03, 0.21, 0.93, 0.38, "", true, GUIEditor.window[1])
        GUIEditor.button[2] = guiCreateButton(0.84, 0.68, 0.14, 0.23, "Bezár", true, GUIEditor.window[1])  
		guiSetVisible(GUIEditor.window[1], false)
		
guiSetInputMode("no_binds_when_editing")
	
function showGUI()
  guiSetVisible( GUIEditor.window[1], true )
  showCursor( true )
end
addEvent( "showguii", true )
addEventHandler( "showguii", localPlayer, showGUI )

addEventHandler("onClientGUIClick",root,
function ()
 
if source == GUIEditor.button[2] then
 
guiSetVisible(GUIEditor.window[1],false)
 
showCursor(false)
 
end
 
end

)

addEventHandler("onClientGUIClick",root,
function ()
 
if source == GUIEditor.button[1] then
 
guiSetVisible(GUIEditor.window[1],false)
 
showCursor(false)
 
end
 
end

)

addEventHandler("onClientGUIClick", GUIEditor.button[1], 
    function (      )
        text1 = guiGetText ( GUIEditor.edit[1] )
        --text2 = guiGetText ( valasz1 )
        --text3 = guiGetText ( valasz2 )
    if text1 ~= "" then
        triggerServerEvent( "server",localPlayer,text1 )
    setTimer ( 
            function(       )
                text1 = nil
         end,5000, 1 )
    end
end,false
)

addEventHandler ( 'onClientRender',root,
    function (  )
        dxDrawText(text1, (screenW * 0.2924) + 1, (screenH * 0.3778) + 1, (screenW * 0.7014) + 1, (screenH * 0.5400) + 1, tocolor(0, 0, 0, 255), 2.50, "default-bold", "left", "top", false, true, false, false, false)
        dxDrawText(text1, screenW * 0.2924, screenH * 0.3778, screenW * 0.7014, screenH * 0.5400, tocolor(0, 186, 255, 255), 2.50, "default-bold", "left", "top", false, true, false, false, false)
    end
)

the dx text why not show on all players screen? o-O

  • Like 1
Link to comment
3 minutes ago, Simple01 said:

Are you sure that text1 has a value? Try to make an outputChatBox in the onClientRender for checking if it has any value.

This just client side

this is server:

 function teszt(p)
if hasObjectPermissionTo(p,"function.kickPlayer") then
triggerClientEvent(p,"showguii",p)
else
outputChatBox("Ehhez neked nincs jogod")
end
end

addCommandHandler("eventp",teszt)

addEvent("server",true)
 
addEventHandler("server",root,
 
function (text1,text2,text3)
 
 
 outputChatBox("#FF0000~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",root,0,255,0, true)
 outputChatBox("#DD3333[FELHÍVÁS] ~> #00baff"..text1.."",root,0,255,0, true)
  outputChatBox("#FF0000~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",root,0,255,0, true)
 
 end
 
 
 )

 

  • Like 1
Link to comment

I don't see any definition, but anyway. Replace the onClientRender with this for checking if text1 has any value on clientside.

addEventHandler ( 'onClientRender',root,
    function (  )
    	outputChatBox( text1 or "TEXT1 HAS NO VALUE", 0, 255, 0 )
        dxDrawText(text1, (screenW * 0.2924) + 1, (screenH * 0.3778) + 1, (screenW * 0.7014) + 1, (screenH * 0.5400) + 1, tocolor(0, 0, 0, 255), 2.50, "default-bold", "left", "top", false, true, false, false, false)
        dxDrawText(text1, screenW * 0.2924, screenH * 0.3778, screenW * 0.7014, screenH * 0.5400, tocolor(0, 186, 255, 255), 2.50, "default-bold", "left", "top", false, true, false, false, false)
    end
)

If the chat outputs "TEXT1 HAS NO VALUE" then take a look at the content of the editbox.

Link to comment

Ah, so you're trying to make the text from a player show to all of them? If it's like that then this will help you.

CLIENT:

addEvent("onServerSynced", true)

function syncText( c )
  if ( c ) and ( guiGetVisible( GUIEditor.edit[1] ) then
     triggerServerEvent("onSyncText", localPlayer, text1 ) 
  end
end
addEventHandler("onClientCharacter", root, syncText )
  
function changeText( text )
   if ( text1 ~= text ) then
      text1 = text
   end
end
addEventHandler("onServerSynced", root, changeText)

SERVER:

addEvent("onSyncText", true)

function syncServer( text )
   if ( text ) then
     local players = getElementsByType("player")
     for i = 1, players do
      local p = players[ i ]
      triggerClientEvent( p, "onServerSynced", p, text )
     end
   end
end
addEventHandler("onSyncText", root, syncServer)

 

Link to comment
10 minutes ago, Simple01 said:

Ah, so you're trying to make the text from a player show to all of them? If it's like that then this will help you.

CLIENT:


addEvent("onServerSynced", true)

function syncText( c )
  if ( c ) and ( guiGetVisible( GUIEditor.edit[1] ) then
     triggerServerEvent("onSyncText", localPlayer, text1 ) 
  end
end
addEventHandler("onClientCharacter", root, syncText )
  
function changeText( text )
   if ( text1 ~= text ) then
      text1 = text
   end
end
addEventHandler("onServerSynced", root, changeText)

SERVER:


addEvent("onSyncText", true)

function syncServer( text )
   if ( text ) then
     local players = getElementsByType("player")
     for i = 1, players do
      local p = players[ i ]
      triggerClientEvent( p, "onServerSynced", p, text )
     end
   end
end
addEventHandler("onSyncText", root, syncServer)

 

client.lua:81: ')' expected near 'then' :S

  • Like 1
Link to comment

Ah sorry, I forgot to close that quote.

    addEvent("onServerSynced", true)

    function syncText( c )
      if ( c ) and ( guiGetVisible( GUIEditor.edit[1] ) ) then
         triggerServerEvent("onSyncText", localPlayer, text1 ) 
      end
    end
    addEventHandler("onClientCharacter", root, syncText )
      
    function changeText( text )
       if ( text1 ~= text ) then
          text1 = text
       end
    end
    addEventHandler("onServerSynced", root, changeText)

 

Link to comment
2 minutes ago, Simple01 said:

Ah sorry, I forgot to close that quote.


    addEvent("onServerSynced", true)

    function syncText( c )
      if ( c ) and ( guiGetVisible( GUIEditor.edit[1] ) ) then
         triggerServerEvent("onSyncText", localPlayer, text1 ) 
      end
    end
    addEventHandler("onClientCharacter", root, syncText )
      
    function changeText( text )
       if ( text1 ~= text ) then
          text1 = text
       end
    end
    addEventHandler("onServerSynced", root, changeText)

 

Thanks man :D

  • Like 1
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...