Flipi Posted November 9, 2013 Share Posted November 9, 2013 How do I run the setting of my script? (the script is a shout admin) Server-side function shout( player, cmd, ... ) local accountname = getAccountName( getPlayerAccount( player ) ) local w = {...} local message = table.concat(w, " ") if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then triggerClientEvent ( root, "onShouts", root, message ) if get ("ColorText") then dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) else outputChatBox( "* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true ) end end end addCommandHandler( "shout", shout ) Client local sx, sy = guiGetScreenSize() local sx = sx / 2 local sy = sy / 2 function drawText() local width = dxGetTextWidth(theText, 3, "default") local height = dxGetFontHeight(3, "default") local leftB = sx - width / 2 local topB = sy - (height + 5) local left = sx - width / 2 local top = sy - height local ColorText = "#0080FF" dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) end draw = false function drawShout(text) if not draw then theText = text addEventHandler("onClientRender", root, drawText) draw = true setTimer(function() draw = false removeEventHandler("onClientRender", root, drawText) end, 5000, 1) end end addEvent("onShouts", true) addEventHandler("onShouts", root, drawShout) Meta setting name="*Colortexto" value="#0080FF" /> Link to comment
Price. Posted November 9, 2013 Share Posted November 9, 2013 why don't you just color the name when he shouts, why do you have to make a settings for it? Link to comment
Flipi Posted November 9, 2013 Author Share Posted November 9, 2013 why don't you just color the name when he shouts, why do you have to make a settings for it? but as I can make it change color with the setting? Link to comment
Price. Posted November 9, 2013 Share Posted November 9, 2013 uhm yes you could afaik, but its more complicated better to do it from the main files. Link to comment
Flipi Posted November 9, 2013 Author Share Posted November 9, 2013 uhm yes you could afaik, but its more complicated better to do it from the main files. I do not understand how to do so Link to comment
Gallardo9944 Posted November 9, 2013 Share Posted November 9, 2013 dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) dx functions can't be executed serverside. Won't work. Use triggerClientEvent to trigger some custom event and execute drawShout. This will work. triggerClientEvent -- send the text as an argument. Should be executed serverside addEventHandler("onShouts", root, drawShout) -- You have this one. It's okay. Trigger it. Link to comment
Flipi Posted November 9, 2013 Author Share Posted November 9, 2013 dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) dx functions can't be executed serverside. Won't work. Use triggerClientEvent to trigger some custom event and execute drawShout. This will work. triggerClientEvent -- send the text as an argument. Should be executed serverside addEventHandler("onShouts", root, drawShout) -- You have this one. It's okay. Trigger it. help me add it to my script?, I'm confused Link to comment
tosfera Posted November 9, 2013 Share Posted November 9, 2013 since the dxDraw functions are only clientsided and has to be used with onClientRender You should add a new event and trigger it. Add a new eventHandler which would display what you want. Making this command client-sided would even be alot easier. Link to comment
Flipi Posted November 9, 2013 Author Share Posted November 9, 2013 since the dxDraw functions are only clientsided and has to be used with onClientRender You should add a new event and trigger it. Add a new eventHandler which would display what you want. Making this command client-sided would even be alot easier. then remove the dxtext of server-side and added a new event in client-side? in where part the client? some example? Link to comment
TAPL Posted November 9, 2013 Share Posted November 9, 2013 Client Side: local sx, sy = guiGetScreenSize() local sx = sx/2 local sy = sy/2 function drawText() local width = dxGetTextWidth(theText, 3, "default") local height = dxGetFontHeight(3, "default") local leftB = sx - width/2 local topB = sy - (height + 5) local left = sx - width/2 local top = sy - height dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) dxDrawText(ColorText..theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) end function drawShout(text, color) if not isTimer(drawTimer) and text and color then addEventHandler("onClientRender", root, drawText) theText = text ColorText = color drawTimer = setTimer(function() removeEventHandler("onClientRender", root, drawText) end, 5000, 1) end end addEvent("onShouts", true) addEventHandler("onShouts", root, drawShout) Server Side: function shout(player, cmd, ...) local accountName = getAccountName(getPlayerAccount(player)) local message = table.concat({...}, " ") if isObjectInACLGroup("user."..accountName, aclGetGroup("Admin")) then triggerClientEvent(root, "onShouts", root, message, get("ColorText")) else outputChatBox("* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true) end end addCommandHandler("shout", shout) Meta setting: > name="*ColorText" value="#0080FF" />> Link to comment
Flipi Posted November 9, 2013 Author Share Posted November 9, 2013 Client Side: local sx, sy = guiGetScreenSize() local sx = sx/2 local sy = sy/2 function drawText() local width = dxGetTextWidth(theText, 3, "default") local height = dxGetFontHeight(3, "default") local leftB = sx - width/2 local topB = sy - (height + 5) local left = sx - width/2 local top = sy - height dxDrawText(theText, leftB+2, topB+2, left, top, tocolor(0, 0, 0, 255), 3, "default-bold", "left", "top", false, true, true) dxDrawText(ColorText..theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) end function drawShout(text, color) if not isTimer(drawTimer) and text and color then addEventHandler("onClientRender", root, drawText) theText = text ColorText = color drawTimer = setTimer(function() removeEventHandler("onClientRender", root, drawText) end, 5000, 1) end end addEvent("onShouts", true) addEventHandler("onShouts", root, drawShout) Server Side: function shout(player, cmd, ...) local accountName = getAccountName(getPlayerAccount(player)) local message = table.concat({...}, " ") if isObjectInACLGroup("user."..accountName, aclGetGroup("Admin")) then triggerClientEvent(root, "onShouts", root, message, get("ColorText")) else outputChatBox("* #0080FFNo puedes usar este comando!", player, 255, 255, 255, true) end end addCommandHandler("shout", shout) Meta setting: > name="*ColorText" value="#0080FF" />> oh thanks , I added some font sizes! c: 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