PyTrO Posted December 24, 2016 Share Posted December 24, 2016 hello, i want to warp all players so i made this but it didnt work with account allowed local Access = { ["None"] = true, ["*-*"] = true, } function warpall() for players in ipairs(getElementsByType("player")) do local paccount = getPlayerAccount(source) if paccount and not isGuestAccount(paccount) and Access[getAccountName(paccount)] then local x3,y3,z3 = getElementPosition(source) setElementPosition ( players, x3, y3, z3 ) end end end addCommandHandler("warpall", warpall) Link to comment
T!GER Posted December 24, 2016 Share Posted December 24, 2016 use they key not the index in the loop. and no need to check the account in the loop check it before. Link to comment
Risk Posted December 24, 2016 Share Posted December 24, 2016 I have re-written the code and cleaned it up a bit for you, not tested though but should work: local Access = { ["None"] = true, ["*-*"] = true, } function warpall(playerSource) if (Access[getAccountName(getPlayerAccount(playerSource))]) then local x, y, z = getElementPosition(playerSource) for i, player in ipairs(getElementsByType("player")) do setElementPosition(player, x, y, z) end end end addCommandHandler("warpall", warpall) Link to comment
1B0Y Posted December 24, 2016 Share Posted December 24, 2016 local Access = { ["None"] = true, ["*-*"] = true, } function warpAll(player) local account = getPlayerAccount(player) if not account or isGuestAccount(account) then return false end if not (Access[getAccountName(account)]) then return false end --You can output an error here as well, as long as you use return to stop the function. for i, player in ipairs(getElementsByType("player")) do local x,y,z = getElementPosition(player) setElementPosition(player,x+math.random(-3,3),y+math.random(-3,3),z) end end addCommandHandler("warpall",warpAll) Here yah go, enjoy. 2 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