Charlie_Jefferson Posted October 11, 2011 Posted October 11, 2011 (edited) Hai, I'm trying to make a special command so that admins can speak to each other, without that chat being seen by normal players. Here's the code I've got. Help please and if you add more stuff to the code, please explain it, I'm new to lua scripting. Thanks! function adminchat() local account = getPlayerAccount ( thePlayer ) if isObjectInACLGroup ( "user." .. getAccountName(string (account)), aclGetGroup ( "Admin" ) ) and type == 0 then cancelEvent ( ) local r, g, b = getPlayerNametagColor(source) outputChatBox ( "#00FF00[Admin]-#ffffff" .. getPlayerName ( source ) .. ": " .. message, getRootElement(), r, g, b, true ) else outputChatBox("#C6FA78Fuck you.", getRootElement(), 255, 255, 255, true) end end addCommandHandler("a", adminchat) Edited October 11, 2011 by Guest
Baseplate Posted October 11, 2011 Posted October 11, 2011 Hmm can we know the error on Debugscript? /debugscript 3
Charlie_Jefferson Posted October 11, 2011 Author Posted October 11, 2011 WARNING: achat/achat.lua:3: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] ERROR: achat\achat.lua:4: attempt to call global 'string' (a table value)
MTA Team qaisjp Posted October 11, 2011 MTA Team Posted October 11, 2011 function adminchat(p,_,...) local message = table.concat({...}, " ") local account = getPlayerAccount (p) if isGuestAccount(account) then return end if not isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup("Admin") ) then return end local r, g, b = getPlayerNametagColor(source) outputChatBox ( "[Admin]"..getPlayerName ( source ) .. ":#ffffff " .. message, root, r, g, b, true ) end addEventHandler("onPlayerJoin", root, function() bindKey(source, "u", "down", "chatbox", "a") end ) addCommandHandler("a", adminchat) Please learn from the code, because i spoon fed this. Press U ingame to open the chat.
GamerNob300 Posted October 12, 2011 Posted October 12, 2011 I have a problem no where to put this script, I'm new mta. I'm learning. By the way do not speak English very well so hopefully I understand
Charlie_Jefferson Posted October 12, 2011 Author Posted October 12, 2011 Qaisjp, it gave me this error, now and I replaced my code with yours. It gave me the same error, on my code, except it was for a different function. [2011-10-12 10:00:37] WARNING: achat\achat.lua:21: Bad argument @ 'getPlayerNametagColor' [2011-10-12 10:00:37] WARNING: achat\achat.lua:22: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2011-10-12 10:00:37] ERROR: achat\achat.lua:22: attempt to concatenate a boolean value
chironex Posted October 12, 2011 Posted October 12, 2011 You tried this code from server console? If yes then you don't have a player name or color... Else well I don't know ^^ And Gamenob300, read the mta wiki, it's very useful!
Charlie_Jefferson Posted October 12, 2011 Author Posted October 12, 2011 No. I made a .lua file with it and loaded it with the server console, yes.(the script) and then tried it and it gave me that error.
MTA Team qaisjp Posted October 12, 2011 MTA Team Posted October 12, 2011 Aha yes, sorry. One minute. edit: function adminchat(_,...) local p = source local message = table.concat({...}, " ") local account = getPlayerAccount (p) if isGuestAccount(account) then return end if not isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup("Admin") ) then return end local r, g, b = getPlayerNametagColor(source) outputChatBox ( "[Admin]"..getPlayerName ( source ) .. ":#ffffff " .. message, root, r, g, b, true ) end addEventHandler("onPlayerJoin", root, function() bindKey(source, "u", "down", "chatbox", "a") end ) addCommandHandler("a", adminchat)
Charlie_Jefferson Posted October 12, 2011 Author Posted October 12, 2011 Yet, another error in the script: [2011-10-12 17:27:48] LOGIN: (Admin, Everyone) Charlie successfully logged in as 'Charlie' (IP: 127.0.0.1 Serial: FA3C6E5FBF3B66FC15FCB1F2AAD204F4) [2011-10-12 17:27:51] WARNING: achat\achat.lua:19: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2011-10-12 17:27:51] WARNING: achat\achat.lua:20: Bad argument @ 'isGuestAccount' [Expected account at argument 1, got boolean] [2011-10-12 17:27:52] WARNING: achat\achat.lua:21: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] [2011-10-12 17:27:52] ERROR: achat\achat.lua:21: attempt to concatenate a boolean value
novo Posted October 12, 2011 Posted October 12, 2011 Are you sure that you have the script on "server" side ?
Charlie_Jefferson Posted October 12, 2011 Author Posted October 12, 2011 Hai, made some changes to my own script and now I get this error: [2011-10-12 19:44:26] ERROR: achat\achat.lua:4: bad argument #1 to 'concat' (table expected, got string) Script is here: function adminchat(thePlayer, ...) local word = ( ... ) local message = table.concat(word, " ") local account = getPlayerAccount ( thePlayer ) if isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Admin" ) ) then outputChatBox ( "#C6FA78[Admin]" .. getPlayerName ( thePlayer ) .. ": " .. message, getRootElement(), 255, 255, 255, true ) else outputChatBox("#C6FA78No.", getRootElement(), 255, 255, 255, true) end end addCommandHandler("a", adminchat)
MTA Team qaisjp Posted October 12, 2011 MTA Team Posted October 12, 2011 function adminchat(thePlayer, ...) local word = {...} local message = table.concat(word, " ") local account = getPlayerAccount ( thePlayer ) if isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup ( "Admin" ) ) then outputChatBox ( "#C6FA78[Admin]" .. getPlayerName ( thePlayer ) .. ": " .. message, getRootElement(), 255, 255, 255, true ) else outputChatBox("#C6FA78No.", getRootElement(), 255, 255, 255, true) end end addCommandHandler("a", adminchat)
Charlie_Jefferson Posted October 12, 2011 Author Posted October 12, 2011 function adminchat(thePlayer, ...) local word = {...} local message = table.concat(word, " ") local account = getPlayerAccount ( thePlayer ) if isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup ( "Admin" ) ) then outputChatBox ( "#C6FA78[Admin]" .. getPlayerName ( thePlayer ) .. ": " .. message, getRootElement(), 255, 255, 255, true ) else outputChatBox("#C6FA78No.", getRootElement(), 255, 255, 255, true) end end addCommandHandler("a", adminchat) Worked, thanks! But it displays as: (color here)[Admin]Charlie: a test. And I didn't put that a there. Help!
Charlie_Jefferson Posted October 12, 2011 Author Posted October 12, 2011 Also another problem with another script. function veh(thePlayer, modelid) local X = 5 local Y = 0 local Z = 0 model = modelid player = getPlayerName( thePlayer ) if isObjectInACLGroup ("user." .. player, aclGetGroup("Admin") ) then createVehicle (modelid, X, Y, Z) elseif not isObjectInACLGroup ("user." .. player, getACLGroup("Admin") ) then outputChatBox ( "Admin cmd only!" ) end end addCommandHandler("veh", veh) It works, I get no error/debug error but the car doesn't spawn.
chironex Posted October 12, 2011 Posted October 12, 2011 Z 0 is under ground at this place, that's maybe why...
Castillo Posted October 12, 2011 Posted October 12, 2011 function veh(thePlayer, cmd, modelid) local X = 5 local Y = 0 local Z = 0 local model = tonumber(modelid) if isObjectInACLGroup ("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Admin") ) then createVehicle (model, X, Y, Z) else outputChatBox ( "Admin cmd only!" ) end end addCommandHandler("veh", veh)
MTA Team qaisjp Posted October 13, 2011 MTA Team Posted October 13, 2011 function veh(thePlayer, cmd, modelid) local x,y,z = getElementPosition(thePlayer) local model = tonumber(modelid) if isObjectInACLGroup ("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Admin") ) then createVehicle (model, x+5,y,z) else outputChatBox ( "Admin cmd only!" ) end end addCommandHandler("veh", veh) i think that is waht u want
Charlie_Jefferson Posted October 13, 2011 Author Posted October 13, 2011 Qaisjp, your script gave me some errors, so I just integrated it into mine. thanks. But I still get that unwated "a" on the admin chat script. I type something and it's like [Admin]Charlie: a hai.
MTA Team qaisjp Posted October 14, 2011 MTA Team Posted October 14, 2011 function adminchat(thePlayer, _,...) local word = {...} local message = table.concat(word, " ") local account = getPlayerAccount ( thePlayer ) if isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup ( "Admin" ) ) then outputChatBox ( "#C6FA78[Admin]" .. getPlayerName ( thePlayer ) .. ": " .. message, getRootElement(), 255, 255, 255, true ) else outputChatBox("#C6FA78No.", getRootElement(), 255, 255, 255, true) end end addCommandHandler("a", adminchat) I am very nice, aren't I
Castillo Posted October 14, 2011 Posted October 14, 2011 That's pretty weird, is an admin chat or a kind of announcer? because you are sending the message to everyone. P.S: That "No" message is sent to all, can be abused to spam.
MTA Team qaisjp Posted October 14, 2011 MTA Team Posted October 14, 2011 function outputForAdmins(player, msg) for i,v in pairs(getElementsByType("player")) do local account = getPlayerAccount ( v ) if isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup ( "Admin" ) ) then outputChatBox ( "#C6FA78[Admin]" .. getPlayerName ( player ) .. ": " .. message, v, 255, 255, 255, true ) end end end function adminchat(thePlayer, _,...) local word = {...} local message = table.concat(word, " ") local account = getPlayerAccount ( thePlayer ) if isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup ( "Admin" ) ) then outputForAdmins(thePlayer, message) else outputChatBox("#C6FA78No.", thePlayer, 255, 255, 255, true) end end addCommandHandler("a", adminchat) This one is only to show what you say for admins, above castillos post is announce
taryn Posted October 14, 2011 Posted October 14, 2011 function adminchat(thePlayer, ...) local word = {...} local message = table.concat(word, " ") local account = getPlayerAccount ( thePlayer ) if isObjectInACLGroup ( "user." .. getAccountName(account), aclGetGroup ( "Admin" ) ) then outputChatBox ( "#C6FA78[Admin]" .. getPlayerName ( thePlayer ) .. ": " .. message, getRootElement(), 255, 255, 255, true ) else outputChatBox("#C6FA78No.", getRootElement(), 255, 255, 255, true) end end addCommandHandler("a", adminchat) Worked, thanks! But it displays as: (color here)[Admin]Charlie: a test. And I didn't put that a there. Help! lol look at line 15
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