qaisjp Posted February 28, 2011 Share Posted February 28, 2011 Hey it's me again and I need a little help in this table...and a little info about tables. This is what I kept in the beginning of my script: local randomCarTable ={ "Jetmax" = 4964, --Boats "Coastguard" = 946, "Dinghy" = 49674, "Launch" = 9642, "Predator" = 97645, "Reefer" = 9644, "Speeder" = 7643, "Squalo" = 8544, "Tropic" = 28653, "Marquis" = 8759, "Beagle" = 75784, --Aircraft "Nevada" = 647619, "Shamal" = 8759, "AT-400" = 11752, "Leviathan" = 878876, --Airplanes "Raindance" = 9908, "Cargobob" = 1800, "Barracks" = 1200, --Vehicles "Trashmaster" = 200, "Journey" = 8080, "Camper" = 480, "FBI Truck" = 2600, "Hotdog" = 90760, "Mr. Whoopee" = 9060 } Don't ask why about why the number's are so random.. lol. But I need these number's AND the name, as my script will be using vehicle names and the value (like *vehicle names and seats* or* vehicle names and max speeds*) well I won't make my script obvious (main reason why the numbers are random ) but please help me with the table only after i get the table working would if randomCarTable[getVehicleName(theVehicle)] then -- my beautiful code here end this work? If the vehicle name is found from the table .. then it will execute my code. A small example: I have added an event handler when the player enters a car, will this happen when i enter an at-400? function(thePlayer, theVehicle, theSeat) if randomCarTable[getVehicleName(theVehicle)] then outputChatBox("The max vehicle speed of your vehicle(" .. getVehicleName(theVehicle) .. ") is " (get the table value) end Will this appear? The max vehicle speed of your vehicle(AT-400) is 11752 Link to comment
dzek (varez) Posted February 28, 2011 Share Posted February 28, 2011 you are having (almost) full code, and using us if this will work? why not try it before posting anything? i think it should work. Link to comment
Discord Moderators Zango Posted February 28, 2011 Discord Moderators Share Posted February 28, 2011 why not try? And no it doesn't work, you need brackets around string key in table ie. table = {["key"] = value} Link to comment
qaisjp Posted February 28, 2011 Author Share Posted February 28, 2011 I did try, lol, forgot to post the debugscript output, and thank you Zango, I'm going to try it now! I couldnt try at the end because the code was incomplete, how do i get the value of the AT-400 speed? EDIT: Thanks Zango, I don't get the error any more EDIT2: This is what is in my script, above the script is the table. -- ********************** -- * Main Functions * -- ********************** function xxxxxInit(thePlayer,xxxPlayer) local theVehicle = getPedOccupiedVehicle(xxxPlayer) local theVehicleName = getVehicleName(theVehicle) for index, veh in pairs(randomCarTable) do if veh ~= theVehicleName then outputChatBox("No max veh speed in " .. getPlayerName(xxxPlayer) .. "'s vehicle.", thePlayer, 255, 0, 0, false) return else after else is what happens if it find's the AT-400 in the list. The script sound's pointless, but again, I have changed it a bit Link to comment
qaisjp Posted March 2, 2011 Author Share Posted March 2, 2011 (edited) Ah, it's ok now. I have this code for a small censor system and it work's perfectly, except one problem. words = [ "f_uck", "n_word"] addEventHandler("onPlayerChat", getRootElement(), function(message, messageType) censorUsed = false for _,_x in pairs(words) do if string.find(message,string.lower(_x)) then cancelEvent() censorUsed = true local _number = string.len(_x) local message = string.lower(message) if (messageType == 0) or (messageType == 1) then --Cmessage = "(!) " .. message .. " (!)" --Cmessage = "<censored>" Cmessage = string.rep("*",tonumber(_number)) end end end if censorUsed == false then cancelEvent() Cmessage = message end -- Get the player class. local playerClass = getPlayerClass(source) local nameR, nameG, nameB = getPlayerNametagColor(source) if getElementData(source, "hideTag") == true then hexcode = "#ffff00" playerTag = "" nameR, nameG, nameB = 255,255,0 elseif (playerClass == 1) then playerTag = "" hexcode = "#FFFF00" elseif (playerClass == 2) then hexcode = "#00FF00" playerTag = serverTag elseif (playerClass == 3) then hexcode = "#FF8800" playerTag = serverTag elseif (playerClass == 4) then playerTag = serverTag hexcode = "#FF0000" end -- Normal chat if (messageType == 0) then outputChatBox(playerTag .. getPlayerName(source):gsub('#%x%x%x%x%x%x', '') .. ': ' .. "#FFFFFF" .. Cmessage:gsub('#%x%x%x%x%x%x', ''), getRootElement(), nameR, nameG, nameB, true) -- Register the message to the log. outputServerLog("CHAT: " .. getPlayerName(source) .. ": " .. message:gsub('#%x%x%x%x%x%x', '')) The problem is that when I say "F_uck the world, n_word" I don't want "****" to appear I want "**** the world *****" to appear instead. LOL, could you help me? Also, how do i make it NOT case sensitive? Edited June 9, 2020 by qaisjp Change bad word 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