• Print

Author Topic: Gmod Nutscript Server How To Set Factions Health  (Read 11065 times)

0 Members and 1 Guest are viewing this topic.

Offline Capin

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Gmod Nutscript Server How To Set Factions Health
« on: May 31, 2016, 02:33:23 pm »
I have no idea how I'm supposed to setup the health that a faction spawns with, could someone please tell me what kind of function I need to put in that factions lua file?

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #1 on: May 31, 2016, 03:15:52 pm »
I don't know exactly what you're talking about, but I believe the Entity:SetMaxHealth line might help you here.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Capin

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #2 on: May 31, 2016, 03:34:59 pm »
That doesn't work

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #3 on: May 31, 2016, 03:36:30 pm »
Can I see the code that you have right now? Please post it using the (code=lua) tag (with brackets [] not parentheses)
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #4 on: May 31, 2016, 04:56:37 pm »
Can I see the code that you have right now? Please post it using the (code=lua) tag (with brackets [] not parentheses)
[offtopic]
You can use [nobbc][/nobbc] tags to disable BBCode parsing for anything between them.
Example:
[b]bold[/b]                ---> bold
[nobbc][b]bold[/b][/nobbc] ---> [b]bold[/b]

[/offtopic]
bw81@ulysses-forums ~ % whoami
Homepage

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #5 on: May 31, 2016, 04:59:04 pm »
[offtopic]
You can use [nobbc][/nobbc] tags to disable BBCode parsing for anything between them.
Example:
[b]bold[/b]                ---> bold
[nobbc][b]bold[/b][/nobbc] ---> [b]bold[/b]

[/offtopic]

I was looking how to do that, thanks lol
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Capin

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #6 on: May 31, 2016, 05:14:50 pm »
FACTION.name = "Deathwatch"
FACTION.desc = "Space Marine battle brother of the Sons of Dorn"
FACTION.color = Color(85,85,85)
FACTION.models = {
"models/player/group01/female_01.mdl",
"models/player/group01/female_02.mdl",
"models/player/group01/female_03.mdl",
"models/player/group01/female_04.mdl",
"models/player/group01/female_05.mdl",
"models/player/group01/female_06.mdl",
"models/player/group01/male_01.mdl",
"models/player/group01/male_02.mdl",
"models/player/group01/male_03.mdl",
"models/player/group01/male_04.mdl",
"models/player/group01/male_05.mdl",
"models/player/group01/male_06.mdl",
"models/player/group01/male_07.mdl",
"models/player/group01/male_08.mdl",
"models/player/group01/male_09.mdl",
}
FACTION.isDefault = false
SetMaxHealth(1000)
FACTION_DEATHWATCH = FACTION.index

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #7 on: May 31, 2016, 05:30:26 pm »
That's not how you would do it. I don't know exactly how these things "factions" work, but try putting in
Code: Lua
  1. Deathwatch:SetMaxHealth( 1000 )
instead. I don't know if that's considered an entity, so if that doesn't work try putting in something like
Code: Lua
  1. PlayerSpawn = function( ply )
  2.     ply:SetMaxHealth( 1000 )
  3.     ply:SetHealth( 1000 )
  4.     return CLIENT
  5. end
  6.  


(PS, I stole that from here and it seems to be different from what you're doing, so I don't know for sure if it will work)
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Capin

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #8 on: May 31, 2016, 05:59:58 pm »
sorry that didn't work

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #9 on: May 31, 2016, 06:03:14 pm »
Can you tell me exactly what didn't work except "that didn't work"? It's kind of hard to fix things if you don't give what happens.

Are you getting any errors? If so, what are they?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Capin

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #10 on: June 01, 2016, 02:52:47 pm »

[ERROR] gamemodes/warhammer40krp/schema/factions/sh_deathwatch.lua:21: attempt to index global 'Deathwatch' (a nil value)
  1. unknown - gamemodes/warhammer40krp/schema/factions/sh_deathwatch.lua:21
   2. include - [C]:-1
    3. include - gamemodes/nutscript/gamemode/core/sh_util.lua:17
     4. loadFromDir - gamemodes/nutscript/gamemode/core/libs/sh_faction.lua:39
      5. load - gamemodes/nutscript/gamemode/core/libs/sh_plugin.lua:34
       6. initialize - gamemodes/nutscript/gamemode/core/libs/sh_plugin.lua:163
        7. Call - gamemodes/nutscript/gamemode/shared.lua:77
         8. unknown - lua/includes/modules/gamemode.lua:38
          9. DeriveGamemode - [C]:-1
           10. unknown - gamemodes/warhammer40krp/gamemode/cl_init.lua:1


[ERROR] gamemodes/warhammer40krp/schema/factions/sh_deathwatch.lua:21: attempt to index global 'Deathwatch' (a nil value)
  1. unknown - gamemodes/warhammer40krp/schema/factions/sh_deathwatch.lua:21
   2. include - [C]:-1
    3. include - gamemodes/nutscript/gamemode/core/sh_util.lua:17
     4. loadFromDir - gamemodes/nutscript/gamemode/core/libs/sh_faction.lua:39
      5. load - gamemodes/nutscript/gamemode/core/libs/sh_plugin.lua:34
       6. initialize - gamemodes/nutscript/gamemode/core/libs/sh_plugin.lua:163
        7. Call - gamemodes/nutscript/gamemode/shared.lua:77
         8. unknown - lua/includes/modules/gamemode.lua:33

the first one gives me these two errors while the second one gives me no errors but it still doesn't work.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #11 on: June 01, 2016, 02:53:49 pm »
Please use the  tag when you are posting errors.


Can you post the entirety of the "Deathwatch" file using the [code] *put all your stuff here [/code] tag, please?


Also, if you have any other factions that have altered health, you could look at the code and copy paste it. I'm looking for some documentation about it, but I can't seem to find much as I'm not very familiar with NutScript.
« Last Edit: June 01, 2016, 03:04:35 pm by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #12 on: June 01, 2016, 03:11:04 pm »
I may have found something. Try putting in this into a server file (or, if in shared, do
Code: Lua
  1.  if SERVER then

Code: Lua
  1. function SCHEMA:PostPlayerLoadout( client )
  2.  
  3.   if ( client:Team() == FACTION_DEATHWATCH ) then
  4.  
  5.     for k, v in ipairs(nut.class.list) do
  6.  
  7.       if ( client:getChar():joinClass( k ) ) then
  8.  
  9.       break
  10.       end
  11.   end
  12.  
  13. hook.Run( "PlayerRankChanged", client )
  14.  
  15.   client:SetMaxHealth( 1000 )
  16.   client:SetHealth( 1000 )
  17.  
  18. end


(stole code from here so it may or may not work).
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Capin

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Gmod Nutscript Server How To Set Factions Health
« Reply #13 on: June 01, 2016, 03:23:54 pm »
thanks so much it works

  • Print