isa_Khamdan Posted July 31, 2013 Share Posted July 31, 2013 ok I have this admin msg script but it have one problem , it show the player name instead of the name of the admin who sent the message so can someone tell me how to fix it? function as() local r, g, b = getPlayerNametagColor(getLocalPlayer()) local r1, g1, b1 = guiLabelGetColor (GTN_Label[6]) dxDrawText("Admin : ",13.0,220.0,61.0,206.0,tocolor(255,0,0,255),1.0,"default-bold","left","top",false,false,false) dxDrawColorText (""..rgbTo(r, g, b)..""..getPlayerName(getLocalPlayer()).. " :".. rgbTo(r1, g1, b1).." ".. message,55.0,220.0,264.0,226.0,tocolor(255,255,0,255),1.0,"default-bold","left","top",false,false,false) end addEventHandler("onClientRender", getRootElement(), as) Link to comment
xXMADEXx Posted July 31, 2013 Share Posted July 31, 2013 Thats because its on the client side. You need to make it trigger to the server side, get the info and trigger back to the client side. Link to comment
isa_Khamdan Posted July 31, 2013 Author Share Posted July 31, 2013 Thats because its on the client side. You need to make it trigger to the server side, get the info and trigger back to the client side. hmm can you show me an example? that's the whole script --Server Side LastMessage = "" function wla(player,cmd,...) local accName = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin1")) or isObjectInACLGroup("user." .. accName, aclGetGroup("Console")) then local veve = {...} local message = table.concat(veve, " ") LastMessage = message triggerClientEvent("new", getRootElement(),message) end end addCommandHandler("AM", wla) function onLoad() for _,v in ipairs(getElementsByType("Player")) do local acc = getPlayerAccount(v) if isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Admin1")) or isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Console")) then bindKey(v,"u","down","chatbox","AM") end end end addEventHandler("onResourceStart", resourceRoot, onLoad) addEventHandler("onPlayerLogin",root, function(_,acc) if isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Admin1")) or isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Console")) then bindKey(source,"u","down","chatbox","AM") triggerClientEvent("new", getRootElement(),LastMessage) end end) function justme(thePlayer) if ( hasObjectPermissionTo (thePlayer, "command.shutdown", true) ) then triggerClientEvent(thePlayer, "openWindow1", getRootElement()) else outputChatBox ("This for admin only", thePlayer, 193, 13, 13) end end addCommandHandler("xxx", justme) ---Client Side function rgbTo (Nu9aif_1, Nu9aif_1_1, Nu9aif_2) local Nu9aif = "#" Nu9aif_1 = string.format("%X", Nu9aif_1) Nu9aif = Nu9aif .. (string.len(Nu9aif_1) == 1 and "0" .. Nu9aif_1 or Nu9aif_1) Nu9aif_1_1 = string.format("%X", Nu9aif_1_1) Nu9aif = Nu9aif .. (string.len(Nu9aif_1_1) == 1 and "0" .. Nu9aif_1_1 or Nu9aif_1_1) Nu9aif_2 = string.format("%X", Nu9aif_2) Nu9aif = Nu9aif .. (string.len(Nu9aif_2) == 1 and "0" .. Nu9aif_2 or Nu9aif_2) return Nu9aif end function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" if alignX then if alignX == "center" then ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 elseif alignX == "right" then ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) end end if alignY then if alignY == "center" then ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 elseif alignY == "bottom" then ay = by - dxGetFontHeight(scale, font) end end local alpha = string.format("%08X", color):sub(1,2) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(getColorFromString("#"..col..alpha)) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(getColorFromString("#"..col..alpha)) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) dxDrawText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) end end GTN_Window = {} GTN_Button = {} GTN_Checkbox = {} GTN_Label = {} GTN_Edit = {} GTN_Grid = {} GTN_Window[1] = guiCreateWindow(130,237,267,180,"Text Color",false) guiSetVisible(GTN_Window[1], false) guiWindowSetSizable(GTN_Window[1], false) guiSetFont(GTN_Window[1], "default-bold-small") GTN_Label[2] = guiCreateLabel(070,040,16,15,"R",false,GTN_Window[1]) guiLabelSetColor(GTN_Label[2],255,0,0) GTN_Label[3] = guiCreateLabel(118,039,21,14,"G",false,GTN_Window[1]) guiLabelSetColor(GTN_Label[3],0,255,0) GTN_Label[4] = guiCreateLabel(167,038,24,15,"B",false,GTN_Window[1]) guiLabelSetColor(GTN_Label[4],0,0,255) GTN_Edit[2] = guiCreateEdit(060,058,40,22,"",false,GTN_Window[1]) GTN_Edit[3] = guiCreateEdit(110,058,40,22,"",false,GTN_Window[1]) GTN_Edit[4] = guiCreateEdit(154,58,40,22,"",false,GTN_Window[1]) GTN_Button[2] = guiCreateButton(110,089,74,27,"OK",false,GTN_Window[1]) GTN_Label[6] = guiCreateLabel(017,101,77,17,"Color of the Text",false,GTN_Window[1]) guiLabelSetColor(GTN_Label[6],255,255,255) GTN_Label[7] = guiCreateLabel(038,132,187,17,"All Copyrights Reversed To Nu9aiF",false,GTN_Window[1]) guiLabelSetColor(GTN_Label[7],255,255,0) function onGuiClick (button, state, absoluteX, absoluteY) if (source == GTN_Button[2]) then getrpxr = guiGetText(GTN_Edit[2]) getrpxg = guiGetText(GTN_Edit[3]) getrpxb = guiGetText(GTN_Edit[4]) guiLabelSetColor ( GTN_Label[6], getrpxr, getrpxg, getrpxb ) end end addEventHandler("onClientGUIClick", getRootElement(), onGuiClick ) function setTextColorPanel () if (guiGetVisible(GTN_Window[1]) == true) then guiSetVisible(GTN_Window[1], false) showCursor(false) else guiSetVisible(GTN_Window[1], true) showCursor(true) end end addEvent("openWindow1",true) addEventHandler("openWindow1", getRootElement(), setTextColorPanel) message = "" function start(msg) message = msg CodColor = msg end addEvent("new", true ) addEventHandler("new", getRootElement(), start) function as() local r, g, b = getPlayerNametagColor(getLocalPlayer()) local r1, g1, b1 = guiLabelGetColor (GTN_Label[6]) dxDrawText("Admin : ",13.0,220.0,61.0,206.0,tocolor(255,0,0,255),1.0,"default-bold","left","top",false,false,false) dxDrawColorText (""..rgbTo(r, g, b)..""..getPlayerName(getLocalPlayer()).. " :".. rgbTo(r1, g1, b1).." ".. message,55.0,220.0,264.0,226.0,tocolor(255,255,0,255),1.0,"default-bold","left","top",false,false,false) end addEventHandler("onClientRender", getRootElement(), as) 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