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
September 20, 2019, 10:20:31 pm

Author Topic: GodMode script  (Read 4231 times)

Mellnik

  • Donator
  • Jr. Member
  • *****
  • Posts: 80
    • View Profile
GodMode script
« on: December 15, 2013, 11:36:58 am »
This script sets your health to 10000 which should be 10000 * 100 HP. Use /god to toggle the godmode, when using it removes your weapons.

My first try in LUA, lets see at release if it works :D

http://files.mellnik.com/jcmp/scripts/GodMode.zip

dreadmullet

  • Developer
  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: GodMode script
« Reply #1 on: December 15, 2013, 11:39:01 am »
I'm sorry to say, but a player's health cannot go above 1.

Edit: You're not providing a Color to the Player:SendChatMessage function. On line 20, you're inserting player, not args.player. In two places you're trying to remove from the players table, not GodModePlayers. Otherwise, with these issues fixed, it works.

I realise it's hard to write scripts without a way to validate them. I wrote 500 lines of the race script without access to a server, and it was a disaster.
« Last Edit: December 15, 2013, 11:49:50 am by dreadmullet »

Mellnik

  • Donator
  • Jr. Member
  • *****
  • Posts: 80
    • View Profile
Re: GodMode script
« Reply #2 on: December 15, 2013, 12:06:53 pm »
I'm sorry to say, but a player's health cannot go above 1.

Edit: You're not providing a Color to the Player:SendChatMessage function. On line 20, you're inserting player, not args.player. In two places you're trying to remove from the players table, not GodModePlayers. Otherwise, with these issues fixed, it works.

I realise it's hard to write scripts without a way to validate them. I wrote 500 lines of the race script without access to a server, and it was a disaster.

Damn. Well there is another way, initially I wanted to block
http://wiki.jc-mp.com/Lua/Events/Client/LocalPlayerBulletHit and
http://wiki.jc-mp.com/Lua/Events/Client/LocalPlayerExplosionHit, clientside but I don't know how to check if he is in the sideside variable^^

I fixed the other errors and reuploaded it.


OkamiTheWusky

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: GodMode script
« Reply #3 on: December 16, 2013, 08:01:57 am »
Well if you are doing that way, what about fall damage? Being hit by vehicles?

Mellnik

  • Donator
  • Jr. Member
  • *****
  • Posts: 80
    • View Profile
Re: GodMode script
« Reply #4 on: December 16, 2013, 02:26:15 pm »
True but what about a timer which refuels the players health.

ROODAY

  • Sr. Member
  • ****
  • Posts: 298
    • View Profile
Re: GodMode script
« Reply #5 on: December 17, 2013, 05:07:08 am »
Instead of giving massive health, why not find a way to disable hit counting. Not collisions, just make it so that any instance of damage done to a player in god mode will return 0 damage. Or for extra fun, make it so their health starts at 1%, then every time they're damaged, it comes as health. That would be much more advanced though.

123samson456

  • Full Member
  • ***
  • Posts: 139
    • View Profile
Re: GodMode script
« Reply #6 on: May 29, 2014, 08:15:21 pm »
Thank you so much man. Genarally your script didnt work but because im very new to lua i have learned a bunch of new things which i will use for my own scripts... so thanks man.

LordNoob

  • Sr. Member
  • ****
  • Posts: 349
    • View Profile
Re: GodMode script
« Reply #7 on: May 30, 2014, 03:35:07 pm »
The best way to do this is to use Game:FireEvent("ply.invulnerable") to turn it on, and Game:FireEvent("ply.makevulnerable") to turn it off.

JasonMRC

  • Donator
  • Hero Member
  • *****
  • Posts: 601
    • View Profile
Re: GodMode script
« Reply #8 on: May 30, 2014, 09:20:00 pm »
Thank you so much man. Genarally your script didnt work but because im very new to lua i have learned a bunch of new things which i will use for my own scripts... so thanks man.
You wouldn't happen to be running GK7 MOTD, would you? Or another script that runs the game event "ply.pause" ? This event prevents ply.makeinvulnerable from running on playerjoin.

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: GodMode script
« Reply #9 on: June 01, 2014, 05:17:52 am »
I have it running with GK7_motd using player values with its own function.

Code: [Select]
function GK7Motd:GodMode()
godmode = LocalPlayer:GetValue("GodMode")

if godmode == nil then
        if LocalPlayer:GetSteamId().string == "STEAM_0:1:xxxxxxx" or LocalPlayer:GetSteamId().string == "STEAM_0:0:xxxxxxx" then
print("God mode enabled")
LocalPlayer:SetValue("GodMode", "On")
Game:FireEvent("ply.makeinvulnerable")
Chat:Print("God mode enabled.", Color(255, 0, 0))
end
end
end

and this is the function that runs it in GK7_motd
Code: [Select]
function GK7Motd:SetActive( active )
    if self.active ~= active then
        if active == true and LocalPlayer:GetWorld() ~= DefaultWorld then
            Chat:Print( "You are not in the main world!", Color( 255, 0, 0 ) )
            return
        end

if not active then
Game:FireEvent("ply.unpause")
                        --- Added for graphics display
self.ShowGraphics = "n"
--- Added Godmode for admins
self:GodMode()
end
        self.active = active
        Mouse:SetVisible( self.active )
    end
end