MrGamer100 Posted November 23, 2010 Share Posted November 23, 2010 Note: This code was tested and checked many times, but there could still possibly be a mistake. Please let me know if it's not working for you. Also, if this is in the wrong section, I apologize, and would kindly ask if you could move it to the proper section. There is a common bug among Free Roam servers that allow players to use float versions of weapon/vehicle IDs to get restricted weapons/vehicles. I have successfully made a fix for it. Instead of uploading the entire .zip (some people may have modified their Free Roams), I have 2 options that you can use to get this. 1. The MegaUpload link: http://www.megaupload.com/?d=03XLPMSV (IMPORTANT: Make sure the file's attribute is set to "Read-Only"! Check it by right clicking it, selecting properties, and looking at the bottom. If it's not Read-Only, set it to Read-Only, or it will be overwritten!) This is the fr_client.lua file. Just stick it in to servers/mods/deathmatch/resources/freeroam.zip. This is on the assumption that you don't care how it was fixed, but just want the fix to stop people from exploiting your server. If you're interested to know how I fixed this, look through option 2. 2. When I was first trying to fix the problem, I wanted to try and check if Lua had the float type in the variable weapon or vehID, but there was no type for it, as Lua does all numbers and math in double precision floating point. I gave up too easily on that idea, and instead tabled every weapon and their ID. I had the weapon giving function check the table, and if the input didn't match the table, it would not spawn it, which did take care of the problem, but was really unnecessary. Eventually, I poked around more with the MTA wiki, and then I felt stupid: The solution was right under my nose in the standard math library the entire time! Rookie mistake on my part, but in the end, I found it out. It was math.ceil (or math.floor) that would round the decimals, and stop the exploitation due to the fact that it rounds to an integer. I didn't want to put the tables to waste, though, so I kept them in just in case server owners want more control over who can spawn what. Just get in to the script, look for the weapon function, and follow the instructions in comments. I didn't table vehicles because that's just really going too far. Sorry to have kept you, here is the snipplets. Replace the entire weapon function with this: function giveWeaponCommand(cmd, weapon, amount) --[[ If you are more comfortable controlling which weapons players can spawn (table method), uncomment this and follow the instructions below. local wList = {}; wList["Brass Knuckles"] = 1; wList["Golf Club"] = 2; wList["Nightstick"] = 3; wList["Knife"] = 4; wList["Baseball Bat"] = 5; wList["Shovel"] = 6; wList["Pool Cue"] = 7; wList["Katana"] = 8; wList["Chainsaw"] = 9; wList["Long Purple Dildo"] = 10; wList["Short tan Dildo"] = 11; wList["Vibrator"] = 12; wList["Flowers"] = 14; wList["Cane"] = 15; wList["Grenade"] = 16; wList["Tear Gas"] = 17; wList["Molotov Cocktails"] = 18; wList["Pistol"] = 22; wList["Silenced Pistol"] = 23; wList["Desert Eagle"] = 24; wList["Shotgun"] = 25; wList["Sawn-Off Shotgun"] = 26; wList["Spaz 12 Combat Shotgun"] = 27; wList["Uzi"] = 28; wList["MP5"] = 29; wList["AK-47"] = 30; wList["M4"] = 31; wList["TEC-9"] = 32; wList["Country Rifle"] = 33; wList["Sniper Rifle"] = 34; wList["Rocket Launcher"] = 35; wList["Heat-Seeking RPG"] = 36; wList["Flamethrower"] = 37; wList["Minigun"] = 38; wList["Satchel Charges"] = 39; wList["Satchel Detonator"] = 40; wList["Spraycan"] = 41; wList["Fire Extinguisher"] = 42; wList["Camera"] = 43; wList["Night-Vision Goggles"] = 44; wList["Infrared Googles"] = 45; wList["Parachute"] = 46; --]] weapon = tonumber(weapon) or getWeaponIDFromName(weapon) if weapon then -- Comment below line if using table method. weapon = math.ceil(weapon) --[[ Uncomment this if you are using the table method. for k,v in pairs(wList) do if weapon == v then amount = amount and tonumber(amount) or 500 server.giveMeWeapon(weapon, amount) return end end --]] --[[ Uncomment the below line (table method) if you wish. If the player doesn't specify a valid integer, it tells them off. Feel free to correct g_Me. --]] -- outputChatBox("Invalid weapon ID!", g_Me) -- Comment the below two lines if using the table method. amount = amount and tonumber(amount) or 500 server.giveMeWeapon(weapon, amount) return end end addCommandHandler('give', giveWeaponCommand) addCommandHandler('wp', giveWeaponCommand) --]] Sorry it's so big, the size is mostly just the table. Remove if you want, but then you can't use the table method. Now, for the vehicles: ---[[ function createVehicleCommand(cmd, ...) local vehID local vehiclesToCreate = {} local args = { ... } for i,v in ipairs(args) do vehID = tonumber(v) if not vehID then vehID = getVehicleModelFromName(v) end if vehID then vehID = math.ceil(vehID) table.insert(vehiclesToCreate, vehID) end end server.giveMeVehicles(vehiclesToCreate) end addCommandHandler('createvehicle', createVehicleCommand) addCommandHandler('cv', createVehicleCommand) --]] That's really all I have. That's how you fix it. I'm not sure if this was already made, but if I may request, can this be put in the standard Free Roam release that comes with the MTA SA download? Could be helpful. Thank you for your time, hugs and wishes, -MrGamer100 of the RSGP development team 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