z24d Posted August 11, 2015 Share Posted August 11, 2015 Hi guys i had some problems on my code where is it : ( ? function msg(message, thePlayer) removeEventHandler ( "onClientRender", getRootElement(), dx ) function dx() local nameAdmin = getPlayerName(thePlayer) dxDrawText("* [ Admin ] : #FFFFFF".. message .."", 22, 202, 180, 250, tocolor(150,0,0), 1.3, "default", "left", "top", false, false, true, true, false) dxDrawText(""..nameAdmin.."", 32, 225, 206, 250, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, true, false) end addEventHandler("onClientRender", getRootElement(), dx) end addEvent("admin",true) addEventHandler("admin", getRootElement(), msg) bindKey("u", "down", "chatbox","AM") function () if string.find(message ,"Delete") then return removeEventHandler ( "onClientRender", getRootElement(), dx ) end end Link to comment
Wumbaloo Posted August 11, 2015 Share Posted August 11, 2015 Show us the console error I think it's here: addEventHandler("admin", getRootElement(), msg) miss arguments of the function msg Link to comment
z24d Posted August 11, 2015 Author Share Posted August 11, 2015 Show us the console errorI think it's here: addEventHandler("admin", getRootElement(), msg) miss arguments of the function msg From Debug .. ERROR: Loading script failed: xMsg-GA\Client.lua:14: '' expected near '(' Link to comment
mint3d Posted August 11, 2015 Share Posted August 11, 2015 function msg(message, thePlayer) removeEventHandler ( "onClientRender", getRootElement(), dx ) function dx() local nameAdmin = getPlayerName(thePlayer) dxDrawText("* [ Admin ] : #FFFFFF".. message .."", 22, 202, 180, 250, tocolor(150,0,0), 1.3, "default", "left", "top", false, false, true, true, false) dxDrawText(""..nameAdmin.."", 32, 225, 206, 250, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, true, false) end addEventHandler("onClientRender", getRootElement(), dx) end addEvent("admin",true) addEventHandler("admin", getRootElement(), msg) bindKey("u", "down", "chatbox","AM") function clean (thePlayer) if string.find(message ,"Delete") then return removeEventHandler ( "onClientRender", getRootElement(), dx ) end end Link to comment
z24d Posted August 11, 2015 Author Share Posted August 11, 2015 function msg(message, thePlayer) removeEventHandler ( "onClientRender", getRootElement(), dx ) function dx() local nameAdmin = getPlayerName(thePlayer) dxDrawText("* [ Admin ] : #FFFFFF".. message .."", 22, 202, 180, 250, tocolor(150,0,0), 1.3, "default", "left", "top", false, false, true, true, false) dxDrawText(""..nameAdmin.."", 32, 225, 206, 250, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, true, false) end addEventHandler("onClientRender", getRootElement(), dx) end addEvent("admin",true) addEventHandler("admin", getRootElement(), msg) bindKey("u", "down", "chatbox","AM") function clean (thePlayer) if string.find(message ,"Delete") then return removeEventHandler ( "onClientRender", getRootElement(), dx ) end end when i write Delete its not working i mean its not delete the Draws texts when i write Delete on message Link to comment
Moderators Citizen Posted August 11, 2015 Moderators Share Posted August 11, 2015 Hi, So first, you need to be on the server side to then send the message to all players, and then their client scripts will render the message on their screen. I'm not sure what you did on the server side so here is how you can do it: -- server: function msg(thePlayer, cmd, ...) -- '...' will catch all words you wrote after the command -- need to check if he is admin here local message = table.concat({...}, " ") -- so it will catch your sentence but without spaces, need to concat all words with a space between them if #message == 0 then -- if there is no message outputChatBox("[ERROR] You must specify a message with that command !", thePlayer, 200, 0, 0) else if message == "Delete" then -- if the message is exactly Delete then ask for all clients to stop rendring the message triggerClientEvent("hideAdminMessage", thePlayer) else -- else it's a real message so ask them to get it and start rendering it triggerClientEvent("showAdminMessage", thePlayer, message) end end addCommandHandler("admin", msg) Note that you need to check if he is admin -- client: local adminMsg = {adminName, message} -- this struct will store our admin's name and his message -- SHOW addEvent("showAdminMessage", true) function showAdminMessage(theMessage) local theAdminName = getPlayerName(source) -- I triggered that event with the player who used the command so source is our admin adminMsg = {adminName=theAdminName, message=theMessage} -- updating the struct addEventHandler("onClientRender", getRootElement(), dx) -- start rendering end addEventHandler("showAdminMessage", root, showAdminMessage) -- root is the same as getRootElement() -- HIDE addEvent("hideAdminMessage", true) function hideAdminMessage() removeEventHandler("onClientRender", getRootElement(), dx) -- stop rendering end addEventHandler("hideAdminMessage", root, hideAdminMessage) -- root is the same as getRootElement() -- RENDER function dx() local theAdmin = adminMsg.adminName local theMessage = adminMsg.message dxDrawText("* [ Admin ] : #FFFFFF"..theMessage, 22, 202, 180, 250, tocolor(150,0,0), 1.3, "default", "left", "top", false, false, true, true, false) dxDrawText(theAdmin, 32, 225, 206, 250, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, true, false) end -- bindKey("u", "down", "chatbox", "AM") -- Won't work, what did u try to do ? And please use a real script editing tool like Notepad++ which is free and use tabs to keep your code indeted properly. Best regards, Citizen Link to comment
z24d Posted August 11, 2015 Author Share Posted August 11, 2015 Hi,So first, you need to be on the server side to then send the message to all players, and then their client scripts will render the message on their screen. I'm not sure what you did on the server side so here is how you can do it: -- server: function msg(thePlayer, cmd, ...) -- '...' will catch all words you wrote after the command -- need to check if he is admin here local message = table.concat({...}, " ") -- so it will catch your sentence but without spaces, need to concat all words with a space between them if #message == 0 then -- if there is no message outputChatBox("[ERROR] You must specify a message with that command !", thePlayer, 200, 0, 0) else if message == "Delete" then -- if the message is exactly Delete then ask for all clients to stop rendring the message triggerClientEvent("hideAdminMessage", thePlayer) else -- else it's a real message so ask them to get it and start rendering it triggerClientEvent("showAdminMessage", thePlayer, message) end end addCommandHandler("admin", msg) Note that you need to check if he is admin -- client: local adminMsg = {adminName, message} -- this struct will store our admin's name and his message -- SHOW addEvent("showAdminMessage", true) function showAdminMessage(theMessage) local theAdminName = getPlayerName(source) -- I triggered that event with the player who used the command so source is our admin adminMsg = {adminName=theAdminName, message=theMessage} -- updating the struct addEventHandler("onClientRender", getRootElement(), dx) -- start rendering end addEventHandler("showAdminMessage", root, showAdminMessage) -- root is the same as getRootElement() -- HIDE addEvent("hideAdminMessage", true) function hideAdminMessage() removeEventHandler("onClientRender", getRootElement(), dx) -- stop rendering end addEventHandler("hideAdminMessage", root, hideAdminMessage) -- root is the same as getRootElement() -- RENDER function dx() local theAdmin = adminMsg.adminName local theMessage = adminMsg.message dxDrawText("* [ Admin ] : #FFFFFF"..theMessage, 22, 202, 180, 250, tocolor(150,0,0), 1.3, "default", "left", "top", false, false, true, true, false) dxDrawText(theAdmin, 32, 225, 206, 250, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, true, false) end -- bindKey("u", "down", "chatbox", "AM") -- Won't work, what did u try to do ? And please use a real script editing tool like Notepad++ which is free and use tabs to keep your code indeted properly. Best regards, Citizen ty but i edit what did u do to this function msg(thePlayer, cmd, ...) -- '...' will catch all words you wrote after the command if isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "oneradmin" ) ) or isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "Head.Admin" ) ) or isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "Console" ) ) or isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "big.Admin" ) ) then end local message = table.concat({...}, " ") -- so it will catch your sentence but without spaces, need to concat all words with a space between them if #message == 0 then -- if there is no message outputChatBox("[ERROR] You must specify a message with that command !", thePlayer, 200, 0, 0) else if message == "Delete" then -- if the message is exactly Delete then ask for all clients to stop rendring the message triggerClientEvent("hideAdminMessage", thePlayer) else -- else it's a real message so ask them to get it and start rendering it triggerClientEvent("showAdminMessage", thePlayer, message) end end addCommandHandler("admin", msg) Client local adminMsg = {adminName, message} -- this struct will store our admin's name and his message -- SHOW addEvent("showAdminMessage", true) function showAdminMessage(theMessage) local theAdminName = getPlayerName(source) -- I triggered that event with the player who used the command so source is our admin adminMsg = {adminName=theAdminName, message=theMessage} -- updating the struct addEventHandler("onClientRender", getRootElement(), dx) -- start rendering end addEventHandler("showAdminMessage", root, showAdminMessage) -- root is the same as getRootElement() -- HIDE addEvent("hideAdminMessage", true) function hideAdminMessage() removeEventHandler("onClientRender", getRootElement(), dx) -- stop rendering end addEventHandler("hideAdminMessage", root, hideAdminMessage) -- root is the same as getRootElement() function dx() local theAdmin = adminMsg.adminName local theMessage = adminMsg.message dxDrawText("* [ Admin ] : #FFFFFF"..theMessage, 22, 202, 180, 250, tocolor(150,0,0), 1.3, "default", "left", "top", false, false, true, true, false) dxDrawText(theAdmin, 32, 225, 206, 250, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, true, false) end bindKey("u", "down", "chatbox", "AM") and its not work : ( Sorry for the distrubance Link to comment
Moderators Citizen Posted August 15, 2015 Moderators Share Posted August 15, 2015 You really need to know what you are doing if you want to script things by yourself. You just copied paste some code you found somewhere. You had to put the original code of msg function between the if blablabla admin blabla then and the end that closes that if statement: Server: function msg(thePlayer, cmd, ...) -- '...' will catch all words you wrote after the command if (isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "oneradmin" ) ) or isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "Head.Admin" ) ) or isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "Console" ) ) or isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "big.Admin" ) ) ) then -- the "if admin" statement local message = table.concat({...}, " ") -- so it will catch your sentence but without spaces, need to concat all words with a space between them if #message == 0 then -- if there is no message outputChatBox("[ERROR] You must specify a message with that command !", thePlayer, 200, 0, 0) else if message == "Delete" then -- if the message is exactly Delete then ask for all clients to stop rendring the message triggerClientEvent("hideAdminMessage", thePlayer) else -- else it's a real message so ask them to get it and start rendering it triggerClientEvent("showAdminMessage", thePlayer, message) end end -- end of the "if admin" statement end addCommandHandler("admin", msg) 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