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

2 years ago

Advertisement
July 18, 2019, 03:09:44 pm

Author Topic: [UPDATE] Car Godmode v1.1  (Read 4108 times)

123samson456

  • Full Member
  • ***
  • Posts: 139
    • View Profile
[UPDATE] Car Godmode v1.1
« on: May 27, 2014, 08:36:42 pm »
Car Godmode v1.2


This script gives the ability to set your car into a godmode were it can't receive any damage from explosives or crashing.

Command:
type /cargod to toggle car godmode


Version 1.2

Changelog:
- car godmode is passed as a player value
- direct adaption to the chat command

Fixed Bugs:
- car godmode available in gamemodes
- vehicle explosions while car godmode is enabled

Version 1.1

Changelog:
- no more /caron and caroff, from now on you can toggle with /cargod
- fixed bug that godmode was only set for one car
- saving godmode in a variable


If there should be any problems with the script or you want to suggest something please tell me and I will try to fix them.

One last thing: Im german, so there might be some grammar and spelling mistakes in my explanations...

Wish you a lot of fun with this script  ;)


« Last Edit: June 07, 2014, 10:24:28 pm by 123samson456 »

WPK-Wolfseye

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #1 on: December 30, 2014, 04:28:08 pm »
There is an issue with this Mod. In the Server Logs the following is posted as soon as this Script is used by a player.

Lua error in module cargod when running event PostTick:
H:\Path-to-my-Server\scripts\cargod\server\cargodmode.lua:69: attempt tu index a nil value
Callstack:
API function in metamethod __index
server\cargodmode.lua:69: in function <server/cargodmode.lua:65>


From not knowing how all that stuff works, the error suggests that the Mod doesnt work with the current API of JC:Multiplayer. Is that correct ? If so, or anything else, does anyone know how to fix it ?

Cheers

JasonMRC

  • Donator
  • Hero Member
  • *****
  • Posts: 601
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #2 on: December 30, 2014, 08:49:32 pm »
That's not related to JCMP versioning, that's an error due to a nil variable being called on line 69.

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #3 on: December 31, 2014, 01:39:48 am »
I think you are getting this error because self.godTable has no values when created on init and PostTick cannot find anything to iterate. Maybe a check in PostTick to see if  self.godTable ~= nil? Then again i could be wrong.

WPK-Wolfseye

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #4 on: December 31, 2014, 01:52:30 am »
Thats line 65 - 75 on this script thats in question.

function CarGod:PostTick( )
    if self.godTimer:GetSeconds() >= self.checkInterval then
        for steamid, vehicle in pairs( self.godTable ) do
            if IsValid( vehicle ) then
                if GetPlayerBySteamId( steamid ):GetValue( "CarGod" ) == true then
                    vehicle:SetHealth( 1 )
                end
            end
        end
    end
end


Line 69 is supposed to be the issue. But if you, like me, have no idea what it all means, its kinda hard to find the error or fix it. ;)

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #5 on: December 31, 2014, 02:05:20 am »
Thats line 65 - 75 on this script thats in question.

function CarGod:PostTick( )
    if self.godTimer:GetSeconds() >= self.checkInterval then
        for steamid, vehicle in pairs( self.godTable ) do
            if IsValid( vehicle ) then
                if GetPlayerBySteamId( steamid ):GetValue( "CarGod" ) == true then
                    vehicle:SetHealth( 1 )
                end
            end
        end
    end
end


Line 69 is supposed to be the issue. But if you, like me, have no idea what it all means, its kinda hard to find the error or fix it. ;)

Try this:
Code: [Select]
function CarGod:PostTick( )
    if self.godTimer:GetSeconds() >= self.checkInterval then
if self.godTable == nil then return end ---<---- Added this
        for steamid, vehicle in pairs( self.godTable ) do
            if IsValid( vehicle ) then
                if GetPlayerBySteamId( steamid ):GetValue( "CarGod" ) == true then
                    vehicle:SetHealth( 1 )
                end
            end
        end
    end
end

WPK-Wolfseye

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #6 on: December 31, 2014, 02:36:36 am »
Thanks, but this time its the same error, just with line 70 now.

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #7 on: December 31, 2014, 02:49:38 am »
Thanks, but this time its the same error, just with line 70 now.
Try adding below the other line i added.:

if GetPlayerBySteamId( steamid ):GetValue( "CarGod" ) == nil then return end

Sorry, not testing this just looking at it crazy quick.

WPK-Wolfseye

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #8 on: December 31, 2014, 03:07:21 am »
Thanks, the error messages dont come anymore in the server log. ;)

123samson456

  • Full Member
  • ***
  • Posts: 139
    • View Profile
Re: [UPDATE] Car Godmode v1.1
« Reply #9 on: January 06, 2015, 12:27:31 pm »
sorry for me not answering your issue cuz i should be responsible for my own script but i wasnt active in these forums for ages. Thanks Darwood for fixing it :D