fairyoggy Posted July 30, 2019 Share Posted July 30, 2019 What's wrong with my code? --client(onClientGUIClick) local idrep = guiGetText(edit1_Report) triggerServerEvent("repotvet",getRootElement(),localPlayer, idrep) --server function repotvet (player, idrep, otvet, target, id) for k, player in ipairs ( getElementsByType ( "player" ) ) do local id = getElementData ( player, "ID" ) outputChatBox("#FFD700ID Player: ["..id.. "] Test: " ..tonumber(idrep).."", source, 255, 255, 255, true) if id == idrep then outputChatBox("+", source, 255, 255, 255, true) else outputChatBox("-", source, 255, 255, 255, true) end end end addEvent("repotvet", true) addEventHandler("repotvet", resourceRoot, repotvet) For example, a player with id(1) on the server When I enter "1" in idrep(Edit(edit1_Report)) a message " +" should appear in the chat but appears "-" What am I doing wrong? Link to comment
HassoN Posted July 30, 2019 Share Posted July 30, 2019 Your idrep variable is a string value and you are comparing it to a number. Use: if tonumber(id) == tonumber(idrep) then 1 Link to comment
fairyoggy Posted July 30, 2019 Author Share Posted July 30, 2019 5 minutes ago, HassoN said: Your idrep variable is a string value and you are comparing it to a number. Use: if tonumber(id) == tonumber(idrep) then Works as intended. You have already helped me in many questions, thanks! Link to comment
HassoN Posted July 30, 2019 Share Posted July 30, 2019 (edited) 8 minutes ago, slapz0r said: Works as intended. You have already helped me in many questions, thanks! You're welcome! I'd like to recommend you to use: triggerServerEvent("repotvet", resourceRoot, idrep) Instead of passing your 'localPlayer' as a parameter. and then on your server side use client instead of source. Edited July 30, 2019 by HassoN 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now