Jump to content

[HELP] Output accounts by AccountData


knightscript

Recommended Posts

Thanks @tosfera, one more question, is there a way to set an account data of an account that is offline? this is what I am trying:

local offlineacc = getAccount(online) 
local antihead = setAccountData( offlineacc, "antiheadshot", "on" ) 
local antiheadexpire = setAccountData( offlineacc, "antiheadexpira", ending) 

but i think the problem is I need to write the password in, and I dont have that, thanks

EDIT: just checked out "password" is an optional argument, but I am getting this error on debugscript:

[12:40:30] WARNING: [gameplay]/headshot/vipantiheadshot.lua:15: Bad argument @ ' 
setAccountData' [Expected account at argument 1, got boolean] 

LINE 15:

local antiheadexpire = setAccountData( offlineacc, "antiheadexpira", ending) 

EDIT: fixed it, i was passing the wrong variable, in getAccount, thanks!.

Link to comment

Thanks tosfera, one last thing, this is my code:

function printAllData ( thePlayer ) 
local allAccounts = getAccounts(); 
for i = 1,#allAccounts do 
    local account = getAccountName( allAccounts[i] ) 
    local text = getAccountData (allAccounts[i], "antiheadshot" ); 
    outputChatBox("ACCOUNT: "..account.."RESULT: "..text) 
end 
end 
addCommandHandler( "getall", printAllData )  

I would like to show the account that has the account data, this shows the first entry but it gives me an error on debugscript:

[13:17:55] ERROR: [gameplay]/headshot/vipantiheadshot.lua:33: attempt to concate 
nate local 'text' (a boolean value) 
  

Thanks!.

EDIT: :( It was happening because an account doesnt have that accountdata, is there a way to skip it or just show N/A for example? thanks!.

EDIT: Fixed it, hahaha, i just added an else, which shows N/A instead of the result of the local "text", here is my full code for someone that needs it:

function printAllData ( thePlayer ) 
local allAccounts = getAccounts(); 
for i = 1,#allAccounts do 
    local account = getAccountName( allAccounts[i] ) 
    local text = getAccountData (allAccounts[i], "antiheadexpira" ); 
    if (text) then  
    outputChatBox("cuenta: "..account.."TEXTO: "..text) 
    else 
        outputChatBox("cuenta: "..account.."TEXTO: N/A") 
    end 
end 
end 
addCommandHandler( "getall", printAllData ) 

Link to comment

You can do that with a ternary statement. That'll keep it smaller, like so;

outputChatBox ( "cuenta: ".. account .." TEXTO: ".. ( text and text or "N/A" ) ) 

This actually says;

if ( text ) then text or "N/A". So, if the text isn't false ( so it has some data ), it'll add the text after that outputchatbox. Else it'll add "N/A".

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