AjaxFTW Posted January 20, 2016 Share Posted January 20, 2016 Guys i made code to set account data to banned/unbanned but IDK why it's nt working any help please? function asda(thePlayer,cmd,acc)if getElementData(thePlayer,"admin.number") > 4 then local account = getAccount(acc) setAccountData(account, "Banned", true) exports.CORtexts:output(account.." has been banned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have access to use this command", thePlayer, 255, 0, 0) end end addCommandHandler ( "banaccount", asda) function asda2(thePlayercmd,acc) if getElementData(thePlayer,"admin.number") > 4 then local account = getAccount(acc) setAccountData(account, "Banned", false) exports.CORtexts:output(account.." has been unbanned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have right to use this command", thePlayer, 255, 0, 0) end end addCommandHandler ( "unbanaccount", asda2) Link to comment
1LoL1 Posted January 20, 2016 Share Posted January 20, 2016 Guys i made code to set account data to banned/unbanned but IDK why it's nt working any help please?function asda(thePlayer,cmd,acc)if getElementData(thePlayer,"admin.number") > 4 then local account = getAccount(acc) setAccountData(account, "Banned", true) exports.CORtexts:output(account.." has been banned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have access to use this command", thePlayer, 255, 0, 0) end end addCommandHandler ( "banaccount", asda) function asda2(thePlayercmd,acc) if getElementData(thePlayer,"admin.number") > 4 then local account = getAccount(acc) setAccountData(account, "Banned", false) exports.CORtexts:output(account.." has been unbanned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have right to use this command", thePlayer, 255, 0, 0) end end addCommandHandler ( "unbanaccount", asda2) Try this and use Lua tags. function asda(thePlayer,cmd) if getElementData(thePlayer,"admin.number") > 4 then local account = getPlayerAccount(thePlayer) setAccountData(account, "Banned", true) exports.CORtexts:output(getAccountName(getPlayerAccount(thePlayer).." has been banned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have access to use this command", thePlayer, 255, 0, 0) end end addCommandHandler("banaccount", asda) function asda2(thePlayer,cmd) if getElementData(thePlayer,"admin.number") > 4 then local account = getPlayerAccount(thePlayer) setAccountData(account, "Banned", false) exports.CORtexts:output(getAccountName(getPlayerAccount(thePlayer).." has been unbanned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have right to use this command", thePlayer, 255, 0, 0) end end addCommandHandler("unbanaccount", asda2) Link to comment
AjaxFTW Posted January 20, 2016 Author Share Posted January 20, 2016 Guys i made code to set account data to banned/unbanned but IDK why it's nt working any help please?function asda(thePlayer,cmd,acc)if getElementData(thePlayer,"admin.number") > 4 then local account = getAccount(acc) setAccountData(account, "Banned", true) exports.CORtexts:output(account.." has been banned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have access to use this command", thePlayer, 255, 0, 0) end end addCommandHandler ( "banaccount", asda) function asda2(thePlayercmd,acc) if getElementData(thePlayer,"admin.number") > 4 then local account = getAccount(acc) setAccountData(account, "Banned", false) exports.CORtexts:output(account.." has been unbanned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have right to use this command", thePlayer, 255, 0, 0) end end addCommandHandler ( "unbanaccount", asda2) Try this and use Lua tags. function asda(thePlayer,cmd) if getElementData(thePlayer,"admin.number") > 4 then local account = getPlayerAccount(thePlayer) setAccountData(account, "Banned", true) exports.CORtexts:output(getAccountName(getPlayerAccount(thePlayer).." has been banned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have access to use this command", thePlayer, 255, 0, 0) end end addCommandHandler("banaccount", asda) function asda2(thePlayer,cmd) if getElementData(thePlayer,"admin.number") > 4 then local account = getPlayerAccount(thePlayer) setAccountData(account, "Banned", false) exports.CORtexts:output(getAccountName(getPlayerAccount(thePlayer).." has been unbanned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have right to use this command", thePlayer, 255, 0, 0) end end addCommandHandler("unbanaccount", asda2) Thanks for help but that code will work when player be online, i want to setAccountData when player offline or online!! Link to comment
AjaxFTW Posted January 21, 2016 Author Share Posted January 21, 2016 No one can fix that code Guys?!! Link to comment
tosfera Posted January 21, 2016 Share Posted January 21, 2016 If you want to set the accountData when they are offline, you're going to need more than just a simple table holding the usernames. You're going to have to ban the users depending on username since the username is the key towards the account. Try something like this; addCommandHandler ( "banaccount", function ( thePlayer, _, accountName ) if ( getElementData ( thePlayer, "admin.number" ) > 4 ) then local playerToBan = getPlayerFromName ( accountName ); if ( isElement ( playerToBan ) ) then local account = getPlayerAccount ( playerToBan ); if ( account ) then setAccountData ( account, "Banned", true ); exports.CORtexts:output ( accountName .." has been banned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not logged in", thePlayer, 255, 0, 0 ); end else local account = getAccount ( accountName ); if ( account ) then setAccountData ( account, "Banned", true ); exports.CORtexts:output ( accountName .." has been banned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not a valid account", thePlayer, 255, 0, 0 ); end end else exports.CORtexts:output ( "You don't have access to use this command", thePlayer, 255, 0, 0 ); end end ); addCommandHandler ( "unbanaccount", function ( thePlayer, _, accountName ) if ( getElementData ( thePlayer, "admin.number" ) > 4 ) then local playerToBan = getPlayerFromName ( accountName ); if ( isElement ( playerToBan ) ) then local account = getPlayerAccount ( playerToBan ); if ( account ) then setAccountData ( account, "Banned", false ); exports.CORtexts:output ( accountName .." has been unbanned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not logged in", thePlayer, 255, 0, 0 ); end else local account = getAccount ( accountName ); if ( account ) then setAccountData ( account, "Banned", false ); exports.CORtexts:output ( accountName .." has been unbanned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not a valid account", thePlayer, 255, 0, 0 ); end end else exports.CORtexts:output ( "You don't have access to use this command", thePlayer, 255, 0, 0 ); end end ); Link to comment
AjaxFTW Posted January 21, 2016 Author Share Posted January 21, 2016 If you want to set the accountData when they are offline, you're going to need more than just a simple table holding the usernames. You're going to have to ban the users depending on username since the username is the key towards the account. Try something like this; addCommandHandler ( "banaccount", function ( thePlayer, _, accountName ) if ( getElementData ( thePlayer, "admin.number" ) > 4 ) then local playerToBan = getPlayerFromName ( accountName ); if ( isElement ( playerToBan ) ) then local account = getPlayerAccount ( playerToBan ); if ( account ) then setAccountData ( account, "Banned", true ); exports.CORtexts:output ( accountName .." has been banned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not logged in", thePlayer, 255, 0, 0 ); end else local account = getAccount ( accountName ); if ( account ) then setAccountData ( account, "Banned", true ); exports.CORtexts:output ( accountName .." has been banned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not a valid account", thePlayer, 255, 0, 0 ); end end else exports.CORtexts:output ( "You don't have access to use this command", thePlayer, 255, 0, 0 ); end end ); addCommandHandler ( "unbanaccount", function ( thePlayer, _, accountName ) if ( getElementData ( thePlayer, "admin.number" ) > 4 ) then local playerToBan = getPlayerFromName ( accountName ); if ( isElement ( playerToBan ) ) then local account = getPlayerAccount ( playerToBan ); if ( account ) then setAccountData ( account, "Banned", false ); exports.CORtexts:output ( accountName .." has been unbanned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not logged in", thePlayer, 255, 0, 0 ); end else local account = getAccount ( accountName ); if ( account ) then setAccountData ( account, "Banned", false ); exports.CORtexts:output ( accountName .." has been unbanned successfully", thePlayer, 0, 255, 0 ); else exports.CORtexts:output ( accountName .." is not a valid account", thePlayer, 255, 0, 0 ); end end else exports.CORtexts:output ( "You don't have access to use this command", thePlayer, 255, 0, 0 ); end end ); Bro you didn't understood what i mean!! i want to make if the admin(me) or any one of my staffs have level higher than L4 then he can ban any account they want if it was offline or online like for example /banaccount Ajax and i offline or online my accountData will be set to Banned==True and the same with unbanaccount if used /unbanaccount Ajax And i'am offline or online my accountdata will be set to Banned==false Got it? I made this function asda(thePlayer,cmd, acc) if getElementData(thePlayer,"admin.number") > 4 then local account = getAccount(acc) setAccountData(account, "Banned", true) exports.CORtexts:output(account.." has been banned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have access to use this command", thePlayer, 255, 0, 0) end end addCommandHandler("banaccount", asda) function asda2(thePlayer,cmd, acc) if getElementData(thePlayer,"admin.number") > 4 then local account = getAccount(acc) setAccountData(account, "Banned", flase) exports.CORtexts:output(account.." has been unbanned successfully", thePlayer, 0, 255, 0) else exports.CORtexts:output("You don't have access to use this command", thePlayer, 255, 0, 0) end end addCommandHandler("unbanaccount", asda2) but message didn't work also maybe getElementData didn't work. i hope find solution. Link to comment
tosfera Posted January 21, 2016 Share Posted January 21, 2016 I've done what you've asked as far as I could understand your question and the script. It might not work because your "admin.number" hasn't been set correctly or what so ever. Whether the player is online or offline, the account data will be set to either true or false ( depending on the command used ) while providing a player's name or his accountname. Since you can't get the account name of a player that has left the server, you need his account username. Link to comment
AjaxFTW Posted January 21, 2016 Author Share Posted January 21, 2016 ohhh i got it you are right Thx Link to comment
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