DjMixCuma Posted August 28, 2012 Share Posted August 28, 2012 I have big trouble, with my LUA Code. function SendMessageToAdmins(color1, color2, color3, msg) for i = 0, maxSlots - 1 do if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then SendPlayerMessage(i, color1, color2, color3, string.format("%s", msg)) end end end Here is the error: if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then Content of error: attempt to index field '?' (a nil value) How to fix that? Code not forom MTA:SA !!!!!!!! Link to comment
TAPL Posted August 28, 2012 Share Posted August 28, 2012 it's looks you don't have table with name Account. Link to comment
DjMixCuma Posted August 28, 2012 Author Share Posted August 28, 2012 TAPL i have table "Account" local Account = {} Link to comment
TAPL Posted August 28, 2012 Share Posted August 28, 2012 The index shouldn't be 0 you should start from 1 for i = 0, maxSlots - 1 do Link to comment
DjMixCuma Posted August 28, 2012 Author Share Posted August 28, 2012 When i set from 0 to 1, is 0 errors, but message not sending to admins. :// Link to comment
Anderl Posted August 28, 2012 Share Posted August 28, 2012 I have big trouble, with my LUA Code. function SendMessageToAdmins(color1, color2, color3, msg) for i = 0, maxSlots - 1 do if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then SendPlayerMessage(i, color1, color2, color3, string.format("%s", msg)) end end end Here is the error: if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then Content of error: attempt to index field '?' (a nil value) How to fix that? Code not forom MTA:SA !!!!!!!! What exactly do you want to do? Link to comment
DjMixCuma Posted August 29, 2012 Author Share Posted August 29, 2012 Repair error in this function. Link to comment
Anderl Posted August 29, 2012 Share Posted August 29, 2012 Repair error in this function. Oh cool, I didn't know. I asked what you want to do with this code, not what you are trying to do. Link to comment
denny199 Posted August 29, 2012 Share Posted August 29, 2012 first off all your'e not showing your'e whole code. exapmle: What is this?: SendPlayerMessage and if Account and Account.Admin >= 1 or Account and Account.GameMaster >= 1 then Where is evrything? Link to comment
GTX Posted August 29, 2012 Share Posted August 29, 2012 I think he wants to send a message to all online admins. Link to comment
DjMixCuma Posted August 29, 2012 Author Share Posted August 29, 2012 Oh sorry, my bad. @GTX: Yes, i want send message to admins online. Link to comment
GTX Posted August 31, 2012 Share Posted August 31, 2012 Is that what you wanted? addCommandHandler("sendmessage", function(player, command, ...) msgt = { ... } message = table.concat(msgt, " ") for i, v in ipairs(getElementsByType("player")) do while true do if not getPlayerAccount(v) or isGuestAccount(getPlayerAccount(v)) then break end if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(v)), aclGetGroup("Admin")) then outputChatBox("Message sent.", player, 255, 255, 255, true) outputChatBox(getPlayerName(player) .. " said: "..message, v, 255, 255, 255, true) end break end end end ) 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