Miika Posted April 8, 2015 Posted April 8, 2015 Hi! Anyone have ideas, how to count accounts with more than 500k money? This says all accounts, but, i want it to display only if you have more than 500k money function printAmountOfAccounts ( thePlayer ) local accountTable = getAccounts () if #accountTable == 0 then outputChatBox( "There are no accounts.", thePlayer ) else outputChatBox( "There are " .. #accountTable .. " accounts in this server!", thePlayer, 0, 255, 0 ) end end addCommandHandler( "accountcount", printAmountOfAccounts )
Miika Posted April 8, 2015 Author Posted April 8, 2015 Did you save money to accountData somehow? setAccountData(account , "nordea-cash", amount)
WhoAmI Posted April 8, 2015 Posted April 8, 2015 function printAmountOfAccounts ( thePlayer ) local accountTable = getAccounts () if #accountTable > 0 then local n = 0 for _, account in pairs ( accountTable ) do local money = getAccountData ( account, "nordea-cash" ); if ( money >= 500000 ) then n = n + 1; end end outputChatBox ( "There is " .. n .. " accounts with >= 500000 money.", thePlayer ); end end addCommandHandler( "accountcount", printAmountOfAccounts )
Miika Posted April 8, 2015 Author Posted April 8, 2015 function printAmountOfAccounts ( thePlayer ) local accountTable = getAccounts () if #accountTable > 0 then local n = 0 for _, account in pairs ( accountTable ) do local money = getAccountData ( account, "nordea-cash" ); if ( money >= 500000 ) then n = n + 1; end end outputChatBox ( "There is " .. n .. " accounts with >= 500000 money.", thePlayer ); end end addCommandHandler( "accountcount", printAmountOfAccounts ) Thanks dude! Your script works good!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now