Jump to content

[help] Bad argument


#RooTs

Recommended Posts

because you are giving bad argument?

I'm trying to do, if the player is the VIP group, then display the icon in DX

server.lua -- bad argument

local acls = { "VIP"  } 
  
function CarVehiclePainelVip(source) 
    local accName = getAccountName ( getPlayerAccount ( source ) ) 
    for _, k in ipairs ( acls ) do 
        if isObjectInACLGroup ("user."..accName, aclGetGroup(k)) then 
        setElementData(source,"VehiclePainel",true)  
        else 
        setElementData(source,"VehiclePainel",false) 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getRootElement(), CarVehiclePainelVip ) 

client.lua

        if getElementData( source, 'VehiclePainel' ) then 
        dxDrawImage(botX+sizeX+650, 250, 49, 39, "img/icoRepair.png") 
        end 

Link to comment
    
-- Server-side   
local acls = {"VIP"} 
  
function CarVehiclePainelVip() 
    local accName = getAccountName(getPlayerAccount(source)) 
    for _, k in ipairs(acls) do 
        if isObjectInACLGroup("user."..accName, aclGetGroup(k)) then 
            setElementData(source,"VehiclePainel",true) 
        end 
    end 
end 
addEventHandler("onPlayerVehicleEnter", getRootElement(), CarVehiclePainelVip) 
  
-- Client-side 
if getElementData(getLocalPlayer(), "VehiclePainel") then 
    dxDrawImage(botX+sizeX+650, 250, 49, 39, "img/icoRepair.png") 
end 
  

Link to comment

It's a mistake you keep on making #RooTs, you're trying to replace the default source variable with a function variable. Stop doing that since it'll only cause a lot of trouble.

Also, KariiiM is totally right. You're looping for a table which will only take more memory that required. Try something like this;

addEventHandler ( "onPlayerVehicleEnter", getRootElement(), 
    function () 
        local account = getPlayerAccount ( source ); 
        if ( account ) then 
            if ( isObjectInACLGroup ( "user.".. getAccountName ( account ), aclGetGroup ( "VIP" ) ) ) then 
                setElementData ( source, "VehiclePainel", true ); 
            end 
        end 
    end 
); 

Link to comment
It's a mistake you keep on making #RooTs, you're trying to replace the default source variable with a function variable. Stop doing that since it'll only cause a lot of trouble.

Also, KariiiM is totally right. You're looping for a table which will only take more memory that required. Try something like this;

addEventHandler ( "onPlayerVehicleEnter", getRootElement(), 
    function () 
        local account = getPlayerAccount ( source ); 
        if ( account ) then 
            if ( isObjectInACLGroup ( "user.".. getAccountName ( account ), aclGetGroup ( "VIP" ) ) ) then 
                setElementData ( source, "VehiclePainel", true ); 
            end 
        end 
    end 
); 

LOL. thanks, guys

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