MrGamer100
Members-
Posts
7 -
Joined
-
Last visited
Everything posted by MrGamer100
-
Changes I make to standard free roam don't save
MrGamer100 replied to MrGamer100's topic in Scripting
I fixed it just now, also had found a better way to fix it. viewtopic.php?f=108&t=30240&p=328271#p328271 -
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
-
Changes I make to standard free roam don't save
MrGamer100 replied to MrGamer100's topic in Scripting
I'd give more mention of it, but someone reading this topic who doesn't know about the glitch will catch on to it, which will only give free roams even more problems... My current fix to it was to have removed the chat commands and leave it handled by VGUI (very easy fix), but I know another way that will work although it's quite time consuming. >_> -
Changes I make to standard free roam don't save
MrGamer100 replied to MrGamer100's topic in Scripting
I would like to thank you for trying to help me, but I have reinstalled my MTA instead of going through the trouble. It is now fixed, and I found a way to stop the files from being overwritten. I marked them as "Read Only" so they will not be overwritten any longer. Thank you very much for your help, and I have now found the solution to the bug I was trying to fix. ( Free Roam's little "float ID" exploit to get Minigun and Rhino, which I have already fixed. ) -MrGamer100 -
Changes I make to standard free roam don't save
MrGamer100 replied to MrGamer100's topic in Scripting
(Apologies for a double post) I have attempted to reverse it, in hopes of fixing the black screen. However, it would now seem that I have an even bigger problem: I cannot fix this black screen. I am unable to host my own local servers for temporary testing now. I really hope I don't have to re-install MTA. >. -
Changes I make to standard free roam don't save
MrGamer100 replied to MrGamer100's topic in Scripting
That didn't seem to work. When I had removed the free roam zip file, it kept with a black screen when I started it up. I didn't make any edits that could have broken the script... -
Hello, I am MrGamer100. I have been working with Lua for around a year and recently started reading up on MTA's implementation of Lua. I decided to start by making some edits to the Free Roam standard gamemode, such as restricting certain other vehicles from being spawned due to a bug. However, whenever I have made a change to any Lua or XML file in Free Roam, the change is overwritten when I run the gamemode, as if I had never made a change at all. It's not just a specific file, it's all of them. It's very strange. Anyone know why this happens? Is there any way around this, so that I may make some modifications? Apologies if I seem pitifully new, -MrGamer100
