• Print

Author Topic: Health Regeneration , Jump Gravity , Run Speed  (Read 9409 times)

0 Members and 1 Guest are viewing this topic.

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Health Regeneration , Jump Gravity , Run Speed
« on: June 15, 2012, 11:06:41 pm »
* Hi Ulysses Team ( I'm Like The Spammer of Ulysses Mod Forum , But i make This Thread Stay Alive )

-> Zombie Survival Mod Server Is Finally Open , Thanks For Your Help ! ( Mr.President )

   * Well I Make This Last/New Thread For The Last's Questions For Ulysses Team

[ THIS IS MY LAST THREAD ON THE FORUM FOR THIS MONTH HEHE ]



- A Few Days Ago I Found This Codes:

- Exp_Stuff_Server.lua

Code: Lua
  1.  
  2.  
  3. AddCSLuaFile("client/exp_pointsmenu.lua")
  4. AddCSLuaFile("client/exp_hud.lua")
  5.  
  6.  
  7. -- Start System Vars.
  8. local UpKeep = 50 -- How much added exp is added each level.
  9. local PointsGained = 3 -- How many skill points players get each level up.
  10. local ExpGained = 10 -- How much exp you get for killing an npc.
  11. local ExpGained_Player = 25 -- How much exp you get for killing an fellow player.
  12. -- End System Vars.
  13. -- Start Skill Vars.
  14. local MaxHpGain = 5 -- How much health is added onto players max hp when they buy 1 point of Max Hp Skill.
  15. local MaxArmorGain = 5 -- How much armor is added onto players max armor when they buy 1 point of Max Armor Skill.
  16. local RegTimeVar = 0.08 -- How fast the player regens hp, How much is given each buy of the skill, Higher = Faster, Lower = slower.
  17. local RegArmTimeVar = 0.05 -- How fast the player regens armor, How much is given each buy of the skill, Higher = Faster, Lower = slower.
  18. local ResistanceVar = 0.2 -- How much damage X is taken off the player for each resistance skill he/she has, dont set this higher than 0.09 or else players will be invincible at level 10 of this skill.
  19. local JumpPowerVar = 25 -- How much extra power is added to the players jump, Try not to exceed 50 for this.
  20.  
  21.  
  22. -- Start Spawn Functions
  23. function EXPSetVarsOnSpawn(pl)
  24. if pl:GetNWInt("Skill_HP") >= 1 then
  25. pl:SetMaxHealth(100 + MaxHpGain*pl:GetNWInt("Skill_HP"))
  26. pl:SetHealth(pl:GetMaxHealth())
  27. end
  28. if pl:GetNWInt("Skill_ARMOR") >= 1 then
  29. pl:SetArmor(0 + MaxArmorGain*pl:GetNWInt("Skill_ARMOR"))
  30. pl.MaxArmor = (100 + MaxArmorGain*pl:GetNWInt("Skill_ARMOR"))
  31. else
  32. pl.MaxArmor = 100
  33. end
  34. if pl:GetNWInt("Skill_REGEN") >= 1 then
  35. pl.RegTime = (RegTimeVar*pl:GetNWInt("Skill_REGEN"))
  36. else
  37. pl.RegTime = 0
  38. end
  39. if pl:GetNWInt("Skill_ARMREGEN") >= 1 then
  40. pl.RegArmTime = (RegArmTimeVar*pl:GetNWInt("Skill_ARMREGEN"))
  41. else
  42. pl.RegArmTime = 0
  43. end
  44. if pl:GetNWInt("Skill_JUMP") >= 1 then
  45. pl:SetJumpPower(160 + JumpPowerVar*pl:GetNWInt("Skill_JUMP"))
  46. end
  47. if pl:GetNWInt("Skill_RESISTANCE") >= 1 then
  48. pl.Resistance = (1 - ResistanceVar*pl:GetNWInt("Skill_RESIST"))
  49. else
  50. pl.Resistance = 1
  51. end
  52. end
  53. hook.Add( "PlayerSpawn", "Set Vars On Spawn", EXPSetVarsOnSpawn )
  54. -- End Spawn Functions
  55.  
  56.  
  57. -- Start Regen Function
  58.    function DoHPThink()
  59.       for k,v in pairs (player.GetAll()) do
  60.          if v.WaitTime == nil then v.WaitTime = 4 end
  61.          if v.lastHit == nil then v.lastHit = CurTime() end
  62.          if v.lastHeal == nil then v.lastHeal = CurTime() end
  63.          if CurTime() - v.lastHit > v.WaitTime then
  64.             if v:Health () != math.floor (math.ceil (v:Health () / v:GetMaxHealth()) * v:GetMaxHealth()) and CurTime() - v.lastHeal > 1/v.RegTime then
  65.                v:SetHealth (v:Health() + 1)
  66.                v.lastHeal = CurTime()
  67.             end
  68.          end
  69.          v.lastHealth = v:Health()
  70.       end
  71.    end
  72.    
  73.    hook.Add ("Think", "hB.T", DoHPThink)
  74.    
  75.    function MehFace (pl)
  76.       pl.lastHit = CurTime()
  77.    end
  78.    
  79.    hook.Add ("PlayerHurt", "hB.PH", MehFace)
  80. -- End Regen Function
  81.  
  82.  
  83. -- Start Resistance Function
  84. function ResistanceScale( ent, inflictor, attacker, amount, dmginfo )
  85.  
  86.    if ent:IsPlayer() then
  87.    dmginfo:ScaleDamage( ent.Resistance )
  88.    end
  89.  
  90. end
  91. hook.Add("EntityTakeDamage","ScaleResistanceDamage",ResistanceScale)
  92. -- End Resistance Function
  93.  
  94.  
  95. -- Start Armor Regen Function
  96.    function DoArmorThink()
  97.       for k,v in pairs (player.GetAll()) do
  98.          if v.WaitTimeA == nil then v.WaitTimeA = 4 end
  99.          if v.lastHitA == nil then v.lastHitA = CurTime() end
  100.          if v.lastHealA == nil then v.lastHealA = CurTime() end
  101.          if CurTime() - v.lastHitA > v.WaitTimeA then
  102.             if v:Armor() <= v.MaxArmor - 1 and CurTime() - v.lastHealA > 1/v.RegArmTime then
  103.                v:SetArmor (v:Armor() + 1)
  104.                v.lastHealA = CurTime()
  105.             end
  106.          end
  107.          v.lastArmor = v:Armor()
  108.       end
  109.    end
  110.    
  111.    hook.Add ("Think", "AB.T", DoArmorThink)
  112.    
  113.    function MehFace2(pl)
  114.       pl.lastHitA = CurTime()
  115.    end
  116.    
  117.    hook.Add ("PlayerHurt", "AB.PH", MehFace2)
  118. -- End Armor Regen Function
  119.  
  120.  
  121. -- Start Buy Commands
  122. function MaxHpBuy(pl)
  123. if pl:GetNWInt("SkillPoints") <= 0 then return false end
  124. if pl:GetNWInt("Skill_HP") >= 15 then return false end
  125. pl:SetNWInt("Skill_HP",pl:GetNWInt("Skill_HP") + 1)
  126. pl:SetMaxHealth(pl:GetMaxHealth() + MaxHpGain)
  127. pl:SetHealth(pl:Health() + MaxHpGain)
  128. pl:SetNWInt("SkillPoints",pl:GetNWInt("SkillPoints") - 1)
  129. file.Write("exp/"..pl:UniqueID().."_skill_hp.txt", pl:GetNWInt("Skill_HP"))
  130. file.Write("exp/"..pl:UniqueID().."_skillpoints.txt", pl:GetNWInt("SkillPoints"))
  131. end
  132. concommand.Add( "skill1buy",MaxHpBuy )
  133.  
  134.  
  135. function MaxArmorBuy(pl)
  136. if pl:GetNWInt("SkillPoints") <= 0 then return false end
  137. pl:SetNWInt("Skill_ARMOR",pl:GetNWInt("Skill_ARMOR") + 1)
  138. pl:SetArmor(pl:Armor() + MaxArmorGain)
  139. pl.MaxArmor = pl.MaxArmor + MaxArmorGain
  140. pl:SetNWInt("SkillPoints",pl:GetNWInt("SkillPoints") - 1)
  141. file.Write("exp/"..pl:UniqueID().."_skill_armor.txt", pl:GetNWInt("Skill_ARMOR"))
  142. file.Write("exp/"..pl:UniqueID().."_skillpoints.txt", pl:GetNWInt("SkillPoints"))
  143. end
  144. concommand.Add( "skill2buy",MaxArmorBuy )
  145.  
  146.  
  147. function RegenBuy(pl)
  148. if pl:GetNWInt("SkillPoints") <= 0 then return false end
  149. pl:SetNWInt("Skill_REGEN",pl:GetNWInt("Skill_REGEN") + 1)
  150. pl.RegTime = pl.RegTime + RegTimeVar
  151. pl:SetNWInt("SkillPoints",pl:GetNWInt("SkillPoints") - 1)
  152. file.Write("exp/"..pl:UniqueID().."_skill_regen.txt", pl:GetNWInt("Skill_REGEN"))
  153. file.Write("exp/"..pl:UniqueID().."_skillpoints.txt", pl:GetNWInt("SkillPoints"))
  154. end
  155. concommand.Add( "skill3buy",RegenBuy )
  156.  
  157.  
  158. function ArmRegenBuy(pl)
  159. if pl:GetNWInt("SkillPoints") <= 0 then return false end
  160. pl:SetNWInt("Skill_ARMREGEN",pl:GetNWInt("Skill_ARMREGEN") + 1)
  161. pl.RegArmTime = pl.RegArmTime + RegArmTimeVar
  162. pl:SetNWInt("SkillPoints",pl:GetNWInt("SkillPoints") - 1)
  163. file.Write("exp/"..pl:UniqueID().."_skill_armregen.txt", pl:GetNWInt("Skill_ARMREGEN"))
  164. file.Write("exp/"..pl:UniqueID().."_skillpoints.txt", pl:GetNWInt("SkillPoints"))
  165. end
  166. concommand.Add( "skill4buy",ArmRegenBuy )
  167.  
  168.  
  169. function JumpBuy(pl)
  170. if pl:GetNWInt("Skill_JUMP") >= 15 then return false end
  171. if pl:GetNWInt("SkillPoints") <= 0 then return false end
  172. pl:SetNWInt("Skill_JUMP",pl:GetNWInt("Skill_JUMP") + 1)
  173. pl:SetJumpPower( pl:GetJumpPower() + JumpPowerVar )
  174. pl:SetNWInt("SkillPoints",pl:GetNWInt("SkillPoints") - 1)
  175. file.Write("exp/"..pl:UniqueID().."_skill_jump.txt", pl:GetNWInt("Skill_JUMP"))
  176. file.Write("exp/"..pl:UniqueID().."_skillpoints.txt", pl:GetNWInt("SkillPoints"))
  177. end
  178. concommand.Add( "skill5buy",JumpBuy )
  179.  
  180.  
  181. function ResistanceBuy(pl)
  182. if pl:GetNWInt("Skill_RESIST") >= 15 then return false end
  183. if pl:GetNWInt("SkillPoints") <= 0 then return false end
  184. pl:SetNWInt("Skill_RESIST", pl:GetNWInt("Skill_RESIST") + 1)
  185. pl:SetNWInt("SkillPoints",pl:GetNWInt("SkillPoints") - 1)
  186. pl.Resistance = pl.Resistance - ResistanceVar
  187. file.Write("exp/"..pl:UniqueID().."_skill_resist.txt", pl:GetNWInt("Skill_RESIST"))
  188. file.Write("exp/"..pl:UniqueID().."_skillpoints.txt", pl:GetNWInt("SkillPoints"))
  189. end
  190. concommand.Add( "skill6buy",ResistanceBuy )
  191. -- End Buy Commands
  192.  
  193.  
  194. -- Start Killing Human EXP Gain
  195. function EXPGainPlayer(victim, weapon, killer)
  196. if killer:IsPlayer() and victim:IsPlayer() and GetConVarNumber("sbox_plpldamage") == 0 then
  197. if killer == victim then return false end
  198. killer:SetNWInt("EXP",killer:GetNWInt("EXP") + ExpGained_Player)
  199. -- Exp Gain Complete
  200. if killer:GetNWInt("EXP") >= (UpKeep*4*(killer:GetNWInt("Level") + 1) + killer:GetNWInt("Level")*UpKeep) then
  201. killer:SetNWInt("Level",killer:GetNWInt("Level") + 1)
  202. killer:SetNWInt("SkillPoints",killer:GetNWInt("SkillPoints") + PointsGained)
  203. killer:PrintMessage(HUD_PRINTTALK,"Level Up!")
  204. end
  205. end
  206. end
  207. hook.Add( "PlayerDeath", "PlayerExpGain", EXPGainPlayer )
  208. -- End Killing Human Exp Gain
  209.  
  210.  
  211. -- Start Killing NPC Exp Gain
  212. function EXPGainNpc(npc, killer, weapon)
  213. if killer:IsPlayer() and npc:IsNPC() then
  214. killer:SetNWInt("EXP",killer:GetNWInt("EXP") + ExpGained)
  215. -- Exp Gain Complete
  216. if killer:GetNWInt("EXP") >= (UpKeep*4*(killer:GetNWInt("Level") + 1) + killer:GetNWInt("Level")*UpKeep) then
  217. killer:SetNWInt("Level",killer:GetNWInt("Level") + 1)
  218. killer:SetNWInt("SkillPoints",killer:GetNWInt("SkillPoints") + PointsGained)
  219. killer:PrintMessage(HUD_PRINTTALK,"Level Up!")
  220. end
  221. end
  222. end
  223. hook.Add( "OnNPCKilled", "NpcExpGain", EXPGainNpc )
  224. -- End Killing NPC Exp Gain
  225.  
  226.  
  227. -- Start Save
  228. function SaveDataNPC(npc, killer, weapon)
  229. if npc:IsNPC() and killer:IsPlayer() then
  230. file.Write("exp/"..killer:UniqueID().."_exppoints.txt", killer:GetNWInt("EXP"))
  231. file.Write("exp/"..killer:UniqueID().."_level.txt", killer:GetNWInt("Level"))
  232. file.Write("exp/"..killer:UniqueID().."_skillpoints.txt", killer:GetNWInt("SkillPoints"))
  233. end
  234. end
  235. hook.Add( "OnNPCKilled", "SaveDataNPC", SaveDataNPC )
  236.  
  237.  
  238. function SaveDataPlayer(victim, weapon, killer)
  239. if victim:IsPlayer() and killer:IsPlayer() then
  240. file.Write("exp/"..killer:UniqueID().."_exppoints.txt", killer:GetNWInt("EXP"))
  241. file.Write("exp/"..killer:UniqueID().."_level.txt", killer:GetNWInt("Level"))
  242. file.Write("exp/"..killer:UniqueID().."_skillpoints.txt", killer:GetNWInt("SkillPoints"))
  243. end
  244. end
  245. hook.Add( "PlayerDeath", "SaveDataPlayer", SaveDataPlayer )
  246. -- End Save
  247.  
  248.  

There Is A Posibility To Add:

- Health Regeneration ; More Jump ; More Speed

Like This Command:

Code: Lua
  1. if ply:GetRank() == 20 then          ply:Give("weapon_crowbar")          ply:SetMaxHealth(250)
  2. end
  3.  

Like Add Lower Gravity , More Sprint Speed & Health Regeneration Like The Field Generator ( Recovery )

Again: Thanks Mr.President & Ulysses Team !

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #1 on: June 15, 2012, 11:21:21 pm »
Don't worry about it. It gives me something to do, and you are posting stuff that other people might find useful at some point and you're posting in the correct forum. We're here to help.

This is a sprint or regular speed script. Add this to any serverside script file. I'll work on the other 2 ideas here in a bit they are a bit more complex
Code: [Select]

function SprintIncrease(ply)
     if ply:GetRank() == 20 then
          GAMEMODE:SetPlayerSpeed(ply, 250, 500) --First number is default walk, second is default run
     end
end
hook.Add("PlayerSpawn", "SpeedInc", SprintIncrease)


Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #2 on: June 15, 2012, 11:40:57 pm »
When you said: Serverside , you mean ( autorun/server/whatever.lua ) ?

I Put This On: ( " Gamemode_Functions.lua ") ( I Dont Know If I'm Wrong )

Code: Lua
  1. function SprintIncrease(ply)
  2.  
  3.     if ply:GetRank() == 1 then
  4. GAMEMODE:SetPlayerSpeed(ply, 205, 305)
  5. end
  6.  
  7.         if ply:GetRank() == 2 then
  8. GAMEMODE:SetPlayerSpeed(ply, 210, 312)
  9. end
  10.  
  11.         if ply:GetRank() == 3 then
  12. GAMEMODE:SetPlayerSpeed(ply, 215, 324)
  13. end
  14.  
  15.         if ply:GetRank() == 4 then
  16. GAMEMODE:SetPlayerSpeed(ply, 220, 336)
  17. end
  18.  
  19.         if ply:GetRank() == 5 then
  20. GAMEMODE:SetPlayerSpeed(ply, 225, 348)
  21. end
  22.  
  23.         if ply:GetRank() == 6 then
  24. GAMEMODE:SetPlayerSpeed(ply, 230, 360)
  25. end
  26.  
  27.         if ply:GetRank() == 7 then
  28. GAMEMODE:SetPlayerSpeed(ply, 235, 372)
  29. end
  30.  
  31.         if ply:GetRank() == 8 then
  32. GAMEMODE:SetPlayerSpeed(ply, 240, 384)
  33. end
  34.  
  35.         if ply:GetRank() == 9 then
  36. GAMEMODE:SetPlayerSpeed(ply, 240, 384)
  37. end
  38.  
  39.     if ply:GetRank() == 10 then
  40. GAMEMODE:SetPlayerSpeed(ply, 240, 384)
  41. end
  42.  
  43.         if ply:GetRank() == 11 then
  44. GAMEMODE:SetPlayerSpeed(ply, 240, 384)
  45. end
  46.  
  47.         if ply:GetRank() == 12 then
  48. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  49. end
  50.  
  51.         if ply:GetRank() == 13 then
  52. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  53. end
  54.  
  55.         if ply:GetRank() == 14 then
  56. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  57. end
  58.  
  59.         if ply:GetRank() == 15 then
  60. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  61. end
  62.  
  63.         if ply:GetRank() == 16 then
  64. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  65. end
  66.  
  67.         if ply:GetRank() == 17 then
  68. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  69. end
  70.  
  71.         if ply:GetRank() == 18 then
  72. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  73. end
  74.  
  75.         if ply:GetRank() == 19 then
  76. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  77. end
  78.  
  79.      if ply:GetRank() == 20 then
  80. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  81. end
  82.  
  83.         if ply:GetRank() == 21 then
  84. GAMEMODE:SetPlayerSpeed(ply, 250, 400)
  85. end              
  86. end
  87. hook.Add("PlayerSpawn", "SpeedInc", SprintIncrease)
  88.  

Thanks ! =)

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #3 on: June 16, 2012, 12:15:24 am »
Jump Function


Code: [Select]
function JumpIncrease(ply)
     if ply:GetRank() == 20 then
          ply:SetJumpPower(210) --200 is normal.. play with the numbers to get it right.
     end
end
hook.Add("PlayerSpawn", "JumpInc", JumpIncrease)

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #4 on: June 16, 2012, 12:27:54 am »
This is your health regeneration script... I'll comment what i can so you can tweak it to your liking...


Code: [Select]
function HealthRegen()

     for k, v in pairs(player.GetAll()) do
          if v:GetRank() == "10" then
               local inc = 10 --AMOUNT OF HEALTH TO INCREASE EVERY TIME THE FUNCTION RUNS
               local pmax = v:GetMaxHealth()
               if ply:Health == pmax then return end
               if ( ply:Health() + inc ) < pmax then
                    ply:SetHealth( ply:Health() + inc )
               else
                    ply:SetHealth( pmax )
               end
          end
     end

end
timer.Create("regentimer", 60, 0, HealthRegen) --REGEN EVERY 60 seconds.. change that to suit your needs
 

There is a cleaner way to do this.. but this is the easiest.

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #5 on: June 16, 2012, 05:05:57 pm »
Thank's Mr.President For All Your Help :) Im Really Happy With That.

=D !


Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #6 on: June 16, 2012, 05:34:18 pm »
Did all 3 scripts work like you wanted?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #7 on: June 16, 2012, 08:10:31 pm »
Doesn't the '0' in the timer create script make it run forever?
You'd only need to run this once. It would then go forever.
Run it again, and it would just start the originally created timer over again, perhaps at a different minute timeframe.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #8 on: June 16, 2012, 08:34:55 pm »
You are correct Jam, but that is the intent. The timer is suppose to run that function every x seconds forever. that's how I choose to do the health regeneration.

no.. the timer is on the outside of the function. I could have put it on the inside and made the 0 a 1 and it would have accomplished the same idea only the function would have to be run at least once from an external source.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #9 on: June 17, 2012, 08:54:48 am »
Thought so.
Problem is, not every new lua coder knows this.
One might write other code to run the function more than once by default, but that wouldn't be needed. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #10 on: June 17, 2012, 11:25:14 am »
hi dude , about the RUN Function , i have a problem ( doesnt work )
It's like outdated D: !

and another question, today i found an error :S i dont know why happend but:

Code: Lua
  1.  
  2. function AntlionGuard(victim, killer)
  3. if victim:GetClass() == "npc_antlionguard" then
  4.    PrintMessage ( HUD_PRINTTALK, "* The Antlion Guard "  .. " was killed by " .. killer:GetName().. ".\n" )
  5.         killer:ChatPrint("$2500 For Killing a Antlion Guard")
  6.     killer:AddMoney(2500)
  7. end
  8. end
  9. hook.Add( "OnNPCKilled", "MyNPCKilledFunction", AntlionGuard )
  10.  
  11.  

Work Like 15 Minutes , and then stop doint the function , i dont know why happend that :S , no errors nothing , just stop making the function :S
For non reason , what can be the problem ?

Really THanks

Schiaffino
« Last Edit: June 17, 2012, 12:02:02 pm by Schiaffino »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #11 on: June 17, 2012, 12:56:21 pm »
Is another "OnNPCKilled" hook overwriting yours somewhere? (Whether you wrote it or not)
Though the code example you show should work fine no matter how many other  "OnNPCKilled" hooks are used..if any other hook has a "return <true||false>" in it...it would break others.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #12 on: June 17, 2012, 01:28:23 pm »
yes, other functions are using that...

can i change that ? to like AntlionKill ?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #13 on: June 17, 2012, 01:55:49 pm »
If another bit of code is using the same hook (hook type "OnNPCKilled"), but has a 'return <blah>', it breaks most other of the same hook.
The problem about one hook overwriting another is, in some gamemode situations, you might want it to.
Unfortunately in this case, it's overwriting and breaking yours.
Try removing, at the least, commenting out using "--", the "return" line in the other code.
If all else works after that, you/they that used it didn't need return.

If another bit of code uses the SAME unique identifier(2) or function name(3), you'll definitely have to rename the function or identifier
hook.Add( "OnNPCKilled", "2", 3 )
« Last Edit: June 17, 2012, 01:59:25 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Health Regeneration , Jump Gravity , Run Speed
« Reply #14 on: June 17, 2012, 03:18:15 pm »
Thanks JamminR :) !

  • Print