Charlie_Jefferson Posted April 12, 2012 Share Posted April 12, 2012 Hi. function check() local acc = getPlayerAccount(thePlayer) local accName = getAccountName(acc) if isObjectInACLGroup("user."..accName, aclGetGroup("admin")) then atype = "admin" pname = getPlayerName(source) triggerClientEvent(source, "infosend", source, accName, atype, pname) end end addEvent("checkinfo", true) addEventHandler("checkinfo", root, check) function createGUI(acc, atype, pname) aname = guiCreateLabel(11,745,96,18,string(acc),false) admtype = guiCreateLabel(135,745,96,18,string(atype),false) nick = guiCreateLabel(280,745,96,18,string(pname),false) end function getinfopl0x () triggerServerEvent("checkinfo", source) end addEvent("infosend", true) addEventHandler("infosend", root, createGUI) addEventHandler("onClientRender", root, getinfopl0x) I get these errors: [2012-04-12 18:23:28] WARNING: adminhud\adminhud_s.lua:3: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-04-12 18:23:28] WARNING: adminhud\adminhud_s.lua:4: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] [2012-04-12 18:23:28] ERROR: adminhud\adminhud_s.lua:6: attempt to concatenate local 'accName' (a boolean value) [2012-04-12 18:23:28] Stopping adminhud [2012-04-12 18:23:28] ERROR: Client triggered serverside event checkinfo, but event is not added serverside What's wrong? Link to comment
X-SHADOW Posted April 12, 2012 Share Posted April 12, 2012 function check (thePlayer) -- you dont put (thePlayer) here .. local acc = getPlayerAccount(thePlayer) local accName = getAccountName(acc) if isObjectInACLGroup("user."..accName, aclGetGroup("admin")) then atype = "admin" pname = getPlayerName(source) triggerClientEvent(source, "infosend", source, accName, atype, pname) --- and what is this ? wtf end end addEvent("checkinfo", true) addEventHandler("checkinfo", root, check) Link to comment
myonlake Posted April 12, 2012 Share Posted April 12, 2012 (edited) X-SHADOW, your code is wrong. There's no need for "thePlayer", and the clientTrigger is just fine, though I made few fixes to unnecessary parts. Server addEvent("checkinfo", true) addEventHandler("checkinfo", root, function() local acc = getPlayerAccount(source) local accName = getAccountName(acc) if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then atype = "Admin" pname = getPlayerName(source) triggerClientEvent(source, "infosend", source, accName, atype, pname) end end ) Client addEvent("infosend", true) addEventHandler("infosend", root, function(accName, atype, pname) aname = guiCreateLabel(11, 745, 96, 18, tostring(accName), false) admtype = guiCreateLabel(135, 745, 96, 18, tostring(atype), false) nick = guiCreateLabel(280, 745, 96, 18, tostring(pname), false) end ) addEventHandler("onClientRender", root, function() triggerServerEvent("checkinfo", source) end ) Edited April 12, 2012 by Guest Link to comment
X-SHADOW Posted April 12, 2012 Share Posted April 12, 2012 every time i see posts saying source is not defined and when i defined it you say no need i dont get it ? Link to comment
Al3grab Posted April 12, 2012 Share Posted April 12, 2012 (edited) Server function check(player) if player then local acc = getPlayerAccount(player) local accName = getAccountName(acc) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then atype = "admin" pname = getPlayerName(player) triggerClientEvent(player, "infosend", player, accName, atype, pname) end end end addEvent("checkinfo", true) addEventHandler("checkinfo", root, function() setTimer(check,1000,0,source) end ) Client addEventHandler("onClientResourceStart",resourceRoot,function() aname = guiCreateLabel(11,745,96,18,"",false) admtype = guiCreateLabel(135,745,96,18,"",false) nick = guiCreateLabel(280,745,96,18,"",false) addEvent("infosend", true) addEventHandler("infosend", root, setGUI) triggerServerEvent("checkinfo",getLocalPlayer()) end ) function setGUI(acc, atype, pname) if ( acc and atype and pname ) then guiSetText(aname,tostring(acc)) guiSetText(adtype,tostring(atype)) guiSetText(nick,tostring(pname)) end end Edited April 12, 2012 by Guest Link to comment
myonlake Posted April 12, 2012 Share Posted April 12, 2012 triggerClientEvent("infosend", source, accName, atype, pname) After the event name, there's a 'source' defined. The source is basically the thing you do not need to replay in the following code. function stuff(source) Source is not needed there, because it is already defined in the trigger. Link to comment
Charlie_Jefferson Posted April 12, 2012 Author Share Posted April 12, 2012 Copied myonlake's and it gave me the same errors, but with different lines, of course. Edit: I coped algrab's and it gave me an error at the timer. Expected argument 1, got 1000. Link to comment
myonlake Posted April 12, 2012 Share Posted April 12, 2012 Let's try X-SHADOW's code then, but at least my Role Play script works without adding it to the arguments of function. addEvent("infosend", true) addEventHandler("infosend", root, function(accName, atype, pname) aname = guiCreateLabel(11, 745, 96, 18, tostring(accName), false) admtype = guiCreateLabel(135, 745, 96, 18, tostring(atype), false) nick = guiCreateLabel(280, 745, 96, 18, tostring(pname), false) end ) addEventHandler("onClientRender", root, function() triggerServerEvent(source, "checkinfo", source) end ) addEvent("checkinfo", true) addEventHandler("checkinfo", root, function(source) local acc = getPlayerAccount(source) local accName = getAccountName(acc) if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then atype = "Admin" pname = getPlayerName(source) triggerClientEvent(source, "infosend", source, accName, atype, pname) end end ) Link to comment
Charlie_Jefferson Posted April 12, 2012 Author Share Posted April 12, 2012 Okay, corrected the timer and now the script loads. No errors but nothing's displayed. Link to comment
X-SHADOW Posted April 12, 2012 Share Posted April 12, 2012 addEvent("infosend", true) addEventHandler("infosend", root, function(accName, atype, pname) aname = guiCreateLabel(11, 745, 96, 18, tostring(accName), true) admtype = guiCreateLabel(135, 745, 96, 18, tostring(atype), true) nick = guiCreateLabel(280, 745, 96, 18, tostring(pname), true) end ) addEventHandler("onClientRender", root, function() triggerServerEvent(source, "checkinfo", source) end ) Link to comment
Charlie_Jefferson Posted April 12, 2012 Author Share Posted April 12, 2012 X-SHADOW said: addEvent("infosend", true) addEventHandler("infosend", root, function(accName, atype, pname) aname = guiCreateLabel(11, 745, 96, 18, tostring(accName), true) admtype = guiCreateLabel(135, 745, 96, 18, tostring(atype), true) nick = guiCreateLabel(280, 745, 96, 18, tostring(pname), true) end ) addEventHandler("onClientRender", root, function() triggerServerEvent(source, "checkinfo", source) end ) It's what myonlake posted but a bit edited and failed. Two "source" at triggerServerEvent? Do you even know the basics of scripting...? Still doesn't work, I removed one source too. Link to comment
Guest Guest4401 Posted April 12, 2012 Share Posted April 12, 2012 X-Shadow, your code isn't right. It would create 3 labels at every frame, so guiSetText is necessary. Try out my code, for me it worked. Make sure you're logged in, and your screen resolution is 1024x768 or more Client local aname = guiCreateLabel(11,745,96,18,"",false) local admtype = guiCreateLabel(135,745,96,18,"",false) local nick = guiCreateLabel(280,745,96,18,"",false) function createGUI(acc, atype, pname) guiSetText(aname, acc) guiSetText(admtype, atype) guiSetText(nick, pname) end function getinfopl0x () triggerServerEvent("checkinfo", localPlayer) end addEvent("infosend", true) addEventHandler("infosend", root, createGUI) addEventHandler("onClientRender", root, getinfopl0x) Server function check() local acc = getPlayerAccount(source) local accName = getAccountName(acc) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then atype = "admin" pname = getPlayerName(source) triggerClientEvent("infosend", source, accName, atype, pname) end end addEvent("checkinfo", true) addEventHandler("checkinfo", root, check) Link to comment
Charlie_Jefferson Posted April 12, 2012 Author Share Posted April 12, 2012 It works karthik. The text is above the radar, instead of under it though and if I set it to relative, it won't show up. That happens to my acc-sys too. If I set it to relative, it won't show up. Link to comment
Guest Guest4401 Posted April 12, 2012 Share Posted April 12, 2012 It works karthik. The text is above the radar, instead of under it though and if I set it to relative, it won't show up. That happens to my acc-sys too. If I set it to relative, it won't show up. local x,y = guiGetScreenSize() local n = 40 -- increase this to make the text higher from bottom of your screen, decrease to make it lower. (will support all resolutions) local aname = guiCreateLabel(11,y-n,96,18,"",false) local admtype = guiCreateLabel(135,y-n,96,18,"",false) local nick = guiCreateLabel(280,y-n,96,18,"",false) function createGUI(acc, atype, pname) guiSetText(aname, acc) guiSetText(admtype, atype) guiSetText(nick, pname) end function getinfopl0x () triggerServerEvent("checkinfo", localPlayer) end addEvent("infosend", true) addEventHandler("infosend", root, createGUI) addEventHandler("onClientRender", root, getinfopl0x) Updated client side code, now it should support all resolutions (Check 2nd line) Link to comment
Charlie_Jefferson Posted April 12, 2012 Author Share Posted April 12, 2012 Okay. It works. How do I bring the labels together though? One near each other and how do I add "|" 's between them. Link to comment
Castillo Posted April 12, 2012 Share Posted April 12, 2012 You mean all names in just one label? Example: Solidsnake14 | Charlie_Jefferson Link to comment
Guest Guest4401 Posted April 13, 2012 Share Posted April 13, 2012 Did you mean something like this? local x,y = guiGetScreenSize() local n = 40 -- increase this to make it higher, decrease to make it lower. (will support all resolutions) local glabel = guiCreateLabel(11,y-n,300,18,"",false) function createGUI(acc, atype, pname) guiSetText(glabel, acc.." | "..atype.." | "..pname) end function getinfopl0x () triggerServerEvent("checkinfo", localPlayer) end addEvent("infosend", true) addEventHandler("infosend", root, createGUI) addEventHandler("onClientRender", root, getinfopl0x) Link to comment
Charlie_Jefferson Posted April 13, 2012 Author Share Posted April 13, 2012 I love you. Thanks! 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