Jump to content

Problem with getAccounts()


spAik

Recommended Posts

Hi,

I use getAccounts() in my teammanager. The teammanager displays every player with the right AccountData "clan"

Its able to kick a player you have specified to kick. Lets say this player is called "spAik.

"nick" would be spAik then. It works then.

But with some nicks it doesnt work. For example the nick "!<~BoX|3R|~>!"

nick = !<~BoX|3R|~>! 
for _,v in ipairs(getAccounts()) do 
if (getAccountData(v,"clannick") == nick) then 
acc = v 
break 
end 
end -- it works until here. the clannick "!<~BoX|3R|~>!" is found  

local accNick = getAccountData(acc,"clannick") --also this is working. It gets the accNick-Data 
outputChatBox("#ffffff"..getPlayerName(source).."#ffffff kicked "..accNick,getRootElement(),255,0,0,true) -- it displays the accNick-Data (just to check if it really got an account 
setAccountData(acc,"clan","0") -- this doesnt work though. It just doesnt delete the clan, although the acc should be valid 
  

Someone knows what might be the problem here? :)

Link to comment

hi krzo, thanks for the reply.

it doesnt set the AccountData to false.

But I only have this problem with some nicks and I dont know how. I mean its only if the player has a strange nickname. But what has the nickname to do with acc I wonder...

Link to comment
  
nick = !<~BoX|3R|~>! 
for _,v in ipairs(getAccounts()) do 
if (if string.find(getAccountData(v,"clannick"),nick,1,true) then -- this will be more usefull. 
acc = v 
break 
end 
end 
local accNick = getAccountData(acc,"clannick") 
outputChatBox("#ffffff"..getPlayerName(source).."#ffffff kicked "..accNick,getRootElement(),255,0,0,true) 
setAccountData(acc,"clan",0) -- you can't delete a account table by using lua, so instead of it set 0 
  

Link to comment
thanks fury :)

ow now i found so much errors :)

it also doesnt work because i had more accounts with the accountdata "!<~BoX|3R|~>!", so it always results in a table of accounts, not in 1 account :(

no problem. so using nick data is may cost getting wrong account, instead of it use only account itself. you may wanna do it like that;

you need a main element that will kick the player out of team, and the kicked element.

function(source,kicked) 
-- use source element to check if it have rights to kick the other element. 
-- and then you can use kicked element to change its account data. 
-- finally you dont need to use getAccounts at this subject. 
end 

so basicly, use the element itself instead of nick data.

Link to comment

u must set account data value string

local nick = '!<~BoX|3R|~>!' 
local table = {  } 
  
for _,v in ipairs( getAccounts(   ) ) do 
  if ( getAccountData( v, "clannick" ) == nick ) then 
           table.insert ( table, v ) 
      end 
end    
  
for i = 1, #table do 
    local accNick = getAccountData( table[i], "clannick" ) 
end 
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...