Jump to content

What's wrong?


Recommended Posts

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
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

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 by Guest
Link to comment

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 by Guest
Link to comment
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

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
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
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

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
Guest Guest4401
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
Guest Guest4401

Did you mean something like this? Kwpfv.png

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...