Jump to content

[HELP] setElementData


opnaiC

Recommended Posts

Posted

Hello, I made a faction script for grove street gang. The gang script is fully working. But to test the gang script I have to set me as a member of the gang. The gang has two markers one for ammo and one for the skin. So when I am using my function the set my rank and faction (script below) and I am hitting the skin marker it says in console: getElementData nil

I know what its standing for but I dont know why my rankme script is not working ... I hope you can help me

Also its outputting in the chat "working", so it should work but it doesnt..

function rankMySelf (thePlayer) 
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
local oFaction = getElementData(thePlayer, "Faction") 
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
if tonumber(iFaction) == nil then 
    setElementData(thePlayer, "Faction", 1) 
    setElementData(thePlayer, "Rank", 6) 
    outputChatBox ("working", thePlayer) 
end 
end 
end 
addCommandHandler( "rankme", rankMySelf, false, false) 

Posted

you had a typo should be oFaction not iFaction

function rankMySelf (thePlayer) 
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
local oFaction = getElementData(thePlayer, "Faction") 
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
if tonumber(oFaction) == nil then 
    setElementData(thePlayer, "Faction", 1) 
    setElementData(thePlayer, "Rank", 6) 
    outputChatBox ("working", thePlayer) 
end 
end 
end 
addCommandHandler( "rankme", rankMySelf) 

Posted
you had a typo should be oFaction not iFaction
function rankMySelf (thePlayer) 
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
local oFaction = getElementData(thePlayer, "Faction") 
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
if tonumber(oFaction) == nil then 
    setElementData(thePlayer, "Faction", 1) 
    setElementData(thePlayer, "Rank", 6) 
    outputChatBox ("working", thePlayer) 
end 
end 
end 
addCommandHandler( "rankme", rankMySelf) 

Still dont working

ER8DBpe.png

Posted

Try this

function rankMySelf (thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if account and not isGuestAccount(account) then  
        local accName = getAccountName (account) 
        local oFaction = getElementData(thePlayer, "Faction") or 0 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
            if tonumber(oFaction) == 0 then  
                setElementData(thePlayer, "Faction", 1) 
                setElementData(thePlayer, "Rank", 6) 
                outputChatBox ("working", thePlayer) 
            end  
        end 
    end 
end 
addCommandHandler( "rankme", rankMySelf) 

Posted
Try this
function rankMySelf (thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if account and not isGuestAccount(account) then  
        local accName = getAccountName (account) 
        local oFaction = getElementData(thePlayer, "Faction") or 0 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
            if tonumber(oFaction) == 0 then  
                setElementData(thePlayer, "Faction", 1) 
                setElementData(thePlayer, "Rank", 6) 
                outputChatBox ("working", thePlayer) 
            end  
        end 
    end 
end 
addCommandHandler( "rankme", rankMySelf) 

Its not outputting working and I have the same problem

Posted
Its not outputting working and I have the same problem

Working fine for me.

  • Make sure it's server side
  • You need to be logged in.
  • You need to be in admin ACL group.
  • Check if it's "Admin" or "admin".

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