Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

Patch 0.3 was just released! Full changelog here: https://t.co/4A50m6IKen

3 years ago

Advertisement
May 27, 2020, 11:42:23 am

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Parvulster

Pages: [1]
1
Latest / Re: 0.3 Released
« on: May 30, 2017, 09:43:49 pm »
Awesome work guys! Can't wait to try out some of the new stuff!  :)

2
Scripting support / Re: Custom Sound
« on: March 04, 2017, 10:10:52 pm »
Okay. Thanks for the clarification!

3
Scripting support / Custom Sound
« on: March 04, 2017, 05:05:57 am »
I was digging though the documentation to try to see the different things you can do with scripting the game. I came across the ClientSound function, and noticed how it said that you need to use this to load the function:
Code: [Select]
ClientSound.Create(AssetLocation, table)
For AssetLocation, I was wondering if it was actually possible to change this to say Base64 in order to load custom sounds. My attempts so far have turned up at nothing but a bunch of crashes, so I was wondering if it is actually possible, or just confusing wording.

Thanks!

4
Scripting support / Re: Issue with Spawning Object with No Model
« on: January 16, 2017, 04:02:10 pm »
One of the issues I have to fix in the future as well is that when you jump out of a plane, it takes a second to despawn the object, causing the plane to crash into said object at speed and blow up. When I noticed that the gear was not coming down, I jumped out of the plane to see if it blew up. It did not. Now, I know that is probably not the best was of seeing if it actually spawns or not, but it blowing up has happened every time I jump out of the plane when gear supposedly was down, except for when it actually wasn't in this issue.

EDIT: Okay, so I have done a bit more testing, and it seems that the script will not work with no model after leaving and then rejoining the server.

EDIT 2: I have found a weird workaround, and I have no idea why this works. Basically, if I spawn and then don't despawn an object with a model, and then try spawning one with no model after reloading the script, it works. Gonna see if I can use this to fix the issue.

EDIT 3: Got it working. I am spawning an object with a model and no collision -200 under the map on ModuleLoad. For some reason, this allows for other objects with no models to spawn perfectly fine.

5
Scripting support / Issue with Spawning Object with No Model
« on: January 16, 2017, 02:36:45 am »
I have been having an issue spawning and moving a ClientStaticObject with no model (only a collision), while trying to make a manual landing gear script. Trying to spawn the previously mentioned ClientStaticObject had not been working for a while, but as I was rewriting the core of the script this morning to test the issue, it magically started working. Now, 12ish hours later, the script is no longer working again, without me changing a single thing inbetween. Below is the client and server side of the script (I know the code is a mess, I am going to clean it up once I get this issue solved). Any and all help is appreciated. Thanks in advance!  :)

Client:
Code: Lua
  1. object = nil
  2. enabled = false
  3. safetospawn = true
  4. slowtimer = nil
  5. ispilot = false
  6. inplane = false
  7. planelist = {24, 30, 34, 39, 51, 59, 81, 85} -- remove peek (59)
  8. gear = nil
  9. slowdowntimer = nil
  10. cancelspeed = false
  11. vehicle = nil
  12. vehicleid = nil
  13. infotimer = nil
  14. inforeason = 0
  15.  
  16. pitch = nil -- remove
  17. roll = nil -- remove
  18.  
  19. steamidlist = {"STEAM_0:0:93101298"} -- remove in final
  20. useable = false -- remove in final
  21.  
  22. function PreTick()
  23.         if ispilot == false or inplane == false then
  24.                 gear = nil
  25.                 DespawnObject()
  26.                 return
  27.         elseif enabled == true then
  28.                 gear = true
  29.                 if safetospawn == true then
  30.                         if object ~= nil then
  31.                                 MoveObject()
  32.                         elseif object == nil then
  33.                                 SpawnObject()
  34.                         end
  35.                 elseif safetospawn == false then
  36.                         DespawnObject()
  37.                 end
  38.         elseif enabled == false then
  39.                 gear = false
  40.                 DespawnObject()
  41.         end
  42. end
  43.  
  44. function MoveObject()
  45.         if object == nil then return
  46.         else
  47.                 local angle = LocalPlayer:GetAngle()
  48.                 local distance = angle * Vector3.Down * 5
  49.                 local position = LocalPlayer:GetPosition() + distance
  50.                 angle = angle * Angle(math.pi * -0.5, 0, 0)
  51.                 object:SetPosition(position)
  52.                 object:SetAngle(angle)
  53.         end
  54. end
  55.  
  56. function DespawnObject()
  57.         if object ~= nil then
  58.                 object:Remove()
  59.                 object = nil
  60.         end
  61. end
  62.  
  63. function SpawnObject()
  64.         if ispilot == false or inplane == false then
  65.                 return
  66.         else
  67.                 DespawnObject()
  68.                 local angle = LocalPlayer:GetAngle()
  69.                 local distance = angle * Vector3.Down * 5
  70.                 local position = LocalPlayer:GetPosition() + distance
  71.                 angle = angle * Angle(math.pi * -0.5, 0, 0)
  72.                 spawnArgs = {}
  73.                 spawnArgs.position = position
  74.                 spawnArgs.angle = angle
  75.                 spawnArgs.model = "" -- areaset01.blz/gb245-d.lod
  76.                 spawnArgs.collision = "gb245_lod1-d_col.pfx" -- gb245_lod1-d_col.pfx
  77.                 object = ClientStaticObject.Create(spawnArgs)
  78.         end
  79. end
  80.  
  81. function EnteredVehicle()
  82.         vehicle = LocalPlayer:GetVehicle()
  83.         if vehicle == nil then return end
  84.         vehicleid = vehicle:GetModelId()
  85.         if CheckList(planelist, vehicleid) then
  86.                 inplane = true
  87.                 if LocalPlayer:GetSeat() == 0 then
  88.                         ispilot = true
  89.                         if safetospawn == true then
  90.                                 enabled = false
  91.                         elseif safetospawn == false then
  92.                                 enabled = true
  93.                         end
  94.                 end
  95.         end
  96. end
  97.  
  98. function ExitedVehicle()
  99.         inplane = false
  100.         ispilot = false
  101.         gear = nil
  102. end
  103.  
  104. function SlowDown()
  105.         if inplane == false or ispilot == false then return end
  106.         if slowdown == true then
  107.                 slowdowntimer = Timer()
  108.                 slowdown = false
  109.                 cancelspeed = true
  110.         elseif slowdowntimer == nil then return
  111.         elseif CheckList(planelist, vehicleid) and slowdowntimer:GetSeconds() > 2 and slowdowntimer:GetSeconds() < 4 then
  112.                 cancelspeed = true
  113.                 Input:SetValue(65, 100)
  114.         elseif CheckList(planelist, vehicleid) and slowdowntimer:GetSeconds() >= 4 then
  115.                 cancelspeed = false
  116.                 slowdowntimer = nil
  117.         end
  118. end
  119.  
  120. function KeyDown(args)
  121.         if args.key == string.byte("L") then
  122.                 if inplane == false then
  123.                         infotimer = Timer()
  124.                         inforeason = 2
  125.                         Chat:Print("You must be in a plane in the pilot's seat to raise or lower landing gear!", Color.Red)
  126.                         return
  127.                 end
  128.                 if ispilot == false then
  129.                         infotimer = Timer()
  130.                         inforeason = 3
  131.                         Chat:Print("You must be in the pilot's seat to raise or lower landing gear!", Color.Red)
  132.                         return
  133.                 end
  134.                 if safetospawn == false then
  135.                         infotimer = Timer()
  136.                         inforeason = 6
  137.                         Chat:Print("You cannot raise or lower landing gear less than 20m from the ground! Gear maintaining position.", Color.Red)
  138.                         return
  139.                 end
  140.                 enabled = not enabled
  141.                 if enabled == true then
  142.                         slowdown = true
  143.                         infotimer = Timer()
  144.                         inforeason = 4
  145.                         Chat:Print("Gear Lowered", Color.Lime)
  146.                         gear = true
  147.                         SpawnObject()
  148.                 elseif enabled == false then
  149.                         infotimer = Timer()
  150.                         inforeason = 5
  151.                         Chat:Print("Gear Raised", Color.Cyan)
  152.                         gear = false
  153.                         DespawnObject()
  154.                 end
  155.         end
  156. end
  157.  
  158. function CancelInput(args)
  159.         local input = args.input
  160.         if cancelspeed == true then
  161.                 if input == 64 then
  162.                         return false
  163.                 end
  164.         end
  165. end
  166.  
  167. function CheckList(list, var)
  168.         for k,v in pairs(list) do
  169.                 if v == var then return true end
  170.         end
  171.         return false
  172. end
  173.  
  174. function ModuleLoad()
  175.         local steam = LocalPlayer:GetSteamId()
  176.         EnteredVehicle()
  177.         Chat:Print("MLG V0.0A LOADED, STEAM ID: "..tostring(steam), Color.Red)
  178. end
  179.  
  180. function ModuleUnload()
  181.         DespawnObject()
  182.         Events:Fire( "HelpRemoveItem", {
  183.                 name = "Manual Landing Gear"
  184.         })
  185. end
  186.  
  187. function ModulesLoad()
  188.     Events:Fire("HelpAddItem", {
  189.                 name = "Manual Landing Gear",
  190.                 text =
  191.                         "Want to manually control your landing gear? Well, then this is for you.\n"..
  192.                         "\n"..
  193.                         "Controls:\n"..
  194.                         "/mlg - enable and disable manual landing gear\n"..
  195.                         "L - raise and lower landing gear (defaults to lowered when entering a plane on the ground)\n"..
  196.                         "\n"..
  197.                         "Known Issues:\n"..
  198.                         "- You cannot be accelerating or using throttle control through autopilot when attempting to lower landing gear\n"..
  199.                         "- Pitching or rolling beyond 60° causes the gear to automatically disable\n"..
  200.                         "- Plane might explode if ejecting midair with landing gear down"
  201.         })
  202. end
  203.  
  204. function CheckExtremes()
  205.         if inplane == false or ispilot == false or enabled == false then return end
  206.         pitch = math.abs(math.deg(vehicle:GetAngle().pitch)) -- make local
  207.         roll = math.abs(math.deg(vehicle:GetAngle().roll)) -- make local
  208.         if pitch > 60 or roll > 60 then
  209.                 enabled = false
  210.                 infotimer = Timer()
  211.                 inforeason = 1
  212.                 Chat:Print("You cannot pitch or roll beyond 60° with the gear down! Raising gear.", Color.Red)
  213.         end
  214. end
  215.  
  216. function RenderInfo()
  217.         local infostring = ""
  218.         local color = ""
  219.         if infotimer ~= nil then
  220.                 if infotimer:GetSeconds() < 3 then
  221.                         color = Color.Aqua
  222.                         if inforeason == 1 then
  223.                                 infostring = "You cannot pitch or roll beyond 60° with the gear down! Raising Gear."
  224.                         elseif inforeason == 2 then
  225.                                 infostring = "You must be in a plane in the pilot's seat to raise or lower landing gear!"
  226.                         elseif inforeason == 3 then
  227.                                 infostring = "You must be in the pilot's seat to raise or lower landing gear!"
  228.                         elseif inforeason == 4 then
  229.                                 infostring = "Lowering Gear"
  230.                         elseif inforeason == 5 then
  231.                                 infostring = "Raising Gear"
  232.                         elseif inforeason == 6 then
  233.                                 infostring = "You can not raise or lowering landing gear less than 20m from the ground!"
  234.                         end
  235.                 else
  236.                         infotimer = nil
  237.                         inforeason = 0
  238.                 end
  239.         elseif inplane == false or ispilot == false or gear == nil then return
  240.         elseif gear == true then
  241.                 infostring = "Gear Down"
  242.                 color = Color.Lime
  243.         elseif gear == false then
  244.                 infostring = "Gear Up"
  245.                 color = Color.Red
  246.         end
  247.         --local position = Vector2(100, 100)
  248.         local position = Vector2(Render.Width / 2, Render.Height)
  249.         position.y = position.y - Render:GetTextHeight(infostring, 24)
  250.         position.x = position.x - Render:GetTextWidth(infostring, 24) / 2
  251.         Render:DrawText(position, infostring, color, 24)
  252. end
  253.  
  254. function GetHeight()
  255.         local x = LocalPlayer:GetPosition().x
  256.         local y = LocalPlayer:GetPosition().y - 200
  257.         local z = LocalPlayer:GetPosition().z
  258.         local height = Physics:GetTerrainHeight(Vector2(x, z)) - 200
  259.         if height < 0 then height = 0 end
  260.         local angle = LocalPlayer:GetAngle()
  261.         local direction = angle * Vector3.Forward
  262.         local position = LocalPlayer:GetPosition() + direction * 25
  263.         local distance = y - height
  264.         local futuredistance = position.y - height - 200
  265.         if futuredistance < distance then futuredistance = distance end
  266.         if futuredistance < 20 then
  267.                 safetospawn = false
  268.         elseif futuredistance >= 20 then
  269.                 safetospawn = true
  270.         end
  271.         -- <remove>
  272.         Render:DrawText(Render.Size / 2, "Ground: "..tostring(math.floor(height)).."\nHeight: "..tostring(math.floor(y)).."\nDistance: "..tostring(math.floor(distance)).."\nFuture Distance: "..tostring(math.floor(futuredistance)).."\nIn Plane: "..tostring(inplane).."\nIs Pilot: "..tostring(ispilot).."\nSafe To Spawn Object: "..tostring(safetospawn).."\nGear Out: "..tostring(gear).."\nPitch: "..tostring(pitch).."\nRoll: "..tostring(roll), Color.White)
  273.         -- </remove>
  274. end
  275. Events:Subscribe("Render", GetHeight) -- CHANGE TO ("PreTick", GetHeight)
  276.  
  277. Events:Subscribe("Render", RenderInfo)
  278. Events:Subscribe("PostTick", CheckExtremes)
  279. Events:Subscribe("LocalPlayerInput", CancelInput)
  280. Events:Subscribe("LocalPlayerEnterVehicle", EnteredVehicle)
  281. Events:Subscribe("LocalPlayerExitVehicle", ExitedVehicle)
  282. Events:Subscribe("InputPoll", SlowDown)
  283. Events:Subscribe("PreTick", PreTick)
  284. Events:Subscribe("KeyDown", KeyDown)
  285. Events:Subscribe("ModuleLoad", ModuleLoad)
  286. Events:Subscribe("ModuleUnload", ModuleUnload)
  287. Events:Subscribe("ModulesLoad", ModulesLoad)

Server:
Code: Lua
  1. function ClientLoaded(args)
  2.         print(args.player:GetName().." has loaded the client-side script.")
  3. end
  4.  
  5. Events:Subscribe("ClientModuleLoad", ClientLoaded)

Pages: [1]