DjMixCuma Posted August 28, 2012 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 !!!!!!!!
TAPL Posted August 28, 2012 Posted August 28, 2012 it's looks you don't have table with name Account.
DjMixCuma Posted August 28, 2012 Author Posted August 28, 2012 TAPL i have table "Account" local Account = {}
TAPL Posted August 28, 2012 Posted August 28, 2012 The index shouldn't be 0 you should start from 1 for i = 0, maxSlots - 1 do
DjMixCuma Posted August 28, 2012 Author Posted August 28, 2012 When i set from 0 to 1, is 0 errors, but message not sending to admins. ://
Anderl Posted August 28, 2012 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? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Anderl Posted August 29, 2012 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. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
denny199 Posted August 29, 2012 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? Sometimes I dream about cheese
GTX Posted August 29, 2012 Posted August 29, 2012 I think he wants to send a message to all online admins. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
DjMixCuma Posted August 29, 2012 Author Posted August 29, 2012 Oh sorry, my bad. @GTX: Yes, i want send message to admins online.
GTX Posted August 31, 2012 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 ) Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
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