Jump to content

Need Help in GuiSetText


Avir14

Recommended Posts

i don't know what to do :(

--Client

GUIEditor = {
    label = {},
    window = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        GUIEditor.window[1] = guiCreateWindow(746, 409, 429, 418, "", false)
        guiWindowSetSizable(GUIEditor.window[1], false)
   label = guiCreateLabel(128, 186, 188, 111, "TEXT", false, GUIEditor.window[1])    
    end
)

function aapp ()
local tee = guiSetText ( label , "On" )   
      triggerServerEvent("Me",localPlayer)
end
addEventHandler ( "onClientRender", root, aapp )
 

--Server 

addEvent("Me",true)
addEventHandler("Me",root,
  function (tee)
if (getServerConfigSetting( "bullet_sync" ) == "1" ) then
tee
end
end
)
 

-- Debugscript

ERROR: Loading script failed: TestScript server.lua:6: '=' expected near 'end'
ERROR: Client (unle) triggered serverside event Me, but event is not added serverside
 

Link to comment

Hello AmirHzz,

glad to see you ask for support on our MTA scripting forums! I would like to know more about yourself in order to give you proper support.

  • Do you know Lua scripting and how much experience would you say you have in programming in general?
  • Did you create the script that you have posted just now? If not then who has helped you create it?
  • Are you willing to improve your Lua skills?
Link to comment

OK. Then let me try to help you by asking you about this faulty code excerpt. It has been pointed at by the error message so it should be no suprise to you. By having one year of experience you should be able to formulate some basic ideas.

if (getServerConfigSetting( "bullet_sync" ) == "1" ) then
tee
end

What did you mean by these code lines? Especially, what is the reason behind putting the "tee" specifier into your code which is a parameter of the event handler?

  • Like 1
Link to comment
1 hour ago, The_GTA said:

OK. Then let me try to help you by asking you about this faulty code excerpt. It has been pointed at by the error message so it should be no suprise to you. By having one year of experience you should be able to formulate some basic ideas.

if (getServerConfigSetting( "bullet_sync" ) == "1" ) then
tee
end

What did you mean by these code lines? Especially, what is the reason behind putting the "tee" specifier into your code which is a parameter of the event handler?

I know it's wrong I tried to do everything but nothing work

I think that will call : »

local tee = guiSetText ( label , "On" )   

Link to comment
11 minutes ago, AmirHzz said:

I think that will call : »

local tee = guiSetText ( label , "On" )   

It does not because one part of the resource is on the server-side and another on the client-side. In such a scenario where you want to call client-side code from the server-side you need to trigger another client-side event. It looks like you just want the player to know whether his bullet setting is enabled.

-- CLIENTSIDE
addEvent("onClientReportBulletSetting", true)
addEventHandler("onClientReportBulletSetting", root,
  function(is_on)
    if (is_on) then
      guiSetText ( label , "On" )
    end
  end
);

-- SERVERSIDE
...
if (getServerConfigSetting( "bullet_sync" ) == "1" ) then
  triggerClientEvent(client, "onClientReportBulletSetting", true)
end

Also triggering server-events each frame from each connected client is effectively self-DDoSing your server. Here:

function aapp ()
local tee = guiSetText ( label , "On" )   
      triggerServerEvent("Me",localPlayer) -- DDOS
end
addEventHandler ( "onClientRender", root, aapp ) -- WTF? called each game frame

 

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