• Revive script help
    56 replies, posted
[QUOTE=LauScript;45718364][Author.;45718342]Oh, right, I forgot something. Full code: [lua] hook.Add("DoPlayerDeath", "CheckForHeadshot", function(ply, killer, dmginfo) if ply.lastHitGroup && ply.lastHitGroup == HITGROUP_HEAD then player.KilledByHeadshot = true end end) hook.Add("ScalePlayerDamage", "CheckHeadshot", function(ply, hitGroup) ply.lastHitGroup = hitGroup end) hook.Add("ScalePlayerDamage", "CheckHeadshot", function(ply, hitGroup) ply.lastHitGroup = hitGroup end) [/lua][/QUOTE] Terrible terrible way to do that. Sorry I can't just write it for you :/ For example. What if you don't want Poisoned players or something to be unrevivable, are you going to write an entirely different system for that two? Its 2-10 variables that change every time they take damage compared to one only when they die.[/QUOTE] I'm really not being rude here, but if this guy doesn't know how to make it himself, then a non-efficient code for him is better than no code
No it isn't, that is impossible. It is stored in the player object.
[QUOTE=LauScript;45718414]It is not needed. Why would it be.[/QUOTE] [QUOTE=Author.;45718406]I can't remember why[/QUOTE] What I do know, though, is that it works just fine. And if he wanted to do something like this with poison, he can just add that to the same hook? I don't get what your saying.
And while that may be true the efficient code is actually easier than the non efficient one.
[QUOTE=LauScript;45718460]No it isn't, that is impossible. It is stored in the player object.[/QUOTE] Well I spawned 2 bots. Shot 1 in the head. Great he can't be revived. I waited til he respawned, shot him in the body, he can be revived, great. I then shot 1 in the head and 1 in the body. Both of them can't be revived. I don't know how. It's why I came here in the first place.
Change player to ply in that guys snippet btw [editline]17th August 2014[/editline] Okay fuck it im gonna write it on my phone please wait a moment
[lua] hook.Add("DoPlayerDeath", "CheckForHeadshot", function(ply, killer, dmginfo) if ply.lastHitGroup && ply.lastHitGroup == HITGROUP_HEAD then ply.KilledByHeadshot = true end end) hook.Add("ScalePlayerDamage", "CheckHeadshot", function(ply, hitGroup) ply.lastHitGroup = hitGroup end) [/lua] Sorry about that mistake :v:
[QUOTE=Author.;45718526][lua] hook.Add("DoPlayerDeath", "CheckForHeadshot", function(ply, killer, dmginfo) if ply.lastHitGroup && ply.lastHitGroup == HITGROUP_HEAD then ply.KilledByHeadshot = true end end) hook.Add("ScalePlayerDamage", "CheckHeadshot", function(ply, hitGroup) ply.lastHitGroup = hitGroup end) [/lua] Sorry about that mistake :v:[/QUOTE] Ok well ply made the headshot detection screw up for some reason. I changed all player to ply. I made sure. Hmm..
[code] local _player = FindMetaTable("Player"); _player.revivable = true; function _player:IsRevivable() return self.revivable; end hook.Add ( "ScalePlayerDamage", "fuckmylife", function( player, hg, ctdi ) If ( hg == HITGROUP_HEAD and player:Health() <= ctdi:GetDamage() ) then player.revivable = false; end end) [/code] then use player:IsRevivable() as you wish Fuck phones
Ok lemme try that now.. Thx
make sure you update the code that does the reviving to use the player:isrevivable () func
[QUOTE=LauScript;45718609][code] local _player = FindMetaTable("Player"); _player.revivable = true; function _player:IsRevivable() return self.revivable; end hook.Add ( "ScalePlayerDamage", "fuckmylife", function( player, hg, ctdi ) If ( hg == HITGROUP_HEAD and player:Health() <= ctdi:GetDamage() ) then player.revivable = false; end end) [/code] then use player:IsRevivable() as you wish Fuck phones[/QUOTE] Give this man a medal
Hmm apparently health is a nil value. Wtf?
Lets not jump the gun - its a slim chance, but possible - that there is a glitch and ctakeddamage infos getdamage method returns a number that isn't the real damage amount. Thus making the players death undetected. It is very unlikely and will only happen in a poorly scripted environment ( people using bad methods they shouldnt [editline]17th August 2014[/editline] If the method health is showing up nil then you havent fucked up your gmod. Idk how that is possible. Print your health with lua run [editline]17th August 2014[/editline] Or do local health = player:Health() or 0; Then replace player:health () with health. They could be dead when its called
[QUOTE=LauScript;45718729]Lets not jump the gun - its a slim chance, but possible - that there is a glitch and ctakeddamage infos getdamage method returns a number that isn't the real damage amount. Thus making the players death undetected. It is very unlikely and will only happen in a poorly scripted environment ( people using bad methods they shouldnt [editline]17th August 2014[/editline] If the method health is showing up nil then you havent fucked up your gmod. Idk how that is possible. Print your health with lua run [editline]17th August 2014[/editline] Or do local health = player:Health() or 0; Then replace player:health () with health. They could be dead when its called[/QUOTE] How would I make the print pop up without putting in a function. CBA at the moment. [editline]17th August 2014[/editline] Nevermind. I put local health = Player:Health() but it says that Health is a nil value?
You testing in listen server? Lua_run print ( player.GetByID(1):Health()) Just do the safeguard i said in the above post. That way it csnt be nil, just 0
Ninja'd :v:
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2ed2.html[/url]
It says tried to use a null entity
Paste your exact script. Everything
I'm on mobile. PC internet cable is fucked so in using wi-fi on mobile. It will take like 15 mins if I do.. Not to meant ion the client side script
Can't help you until then. Take your time. You got an hour before im on a plane
Actually it will take way over 15 mins. Tell ya what. I'll try sort this bug myself. I'll update the thread too. Cya until then.
Thr only way a player entity can be null in this case is a spelling error and I havent made any
[lua] hook.Add("DoPlayerDeath", "CheckRevivable", function(ply, killer, dmginfo) if ply.lastHitGroup == HITGROUP_HEAD then ply.IsRevivable = false else ply.IsRevivable = true end end) hook.Add("ScalePlayerDamage", "CheckForHeadshot", function(ply, hitGroup) ply.lastHitGroup = hitGroup end) [/lua] This works. Feel free to make something better. Just threw it together in a minute or so. Now you would add an if ply.IsRevivable to your revive thingy, and it would return a true if revivable, and false if not.
I gaurantee my method works as well, and so should the aboves. It has to be something the op is doing. He said his player entity was null, which isn't possible without a typing mistake because the object passed HAS to be valid.
[QUOTE=LauScript;45720115]I gaurantee my method works as well, and so should the aboves. It has to be something the op is doing. He said his player entity was null, which isn't possible without a typing mistake because the object passed HAS to be valid.[/QUOTE] Your probably right. When I'm back from holiday ill try it on my gaming pc, Seeing as I'm on some old PC with no internet, there could have been an update I missed, seeing as I'm running steam in offline mode. I'll try authors method and hopefully when I'm back from holiday, lauScripts will probably work. I'm sure I typed it all correctly. [editline]18th August 2014[/editline] [QUOTE=Author.;45719244][lua] hook.Add("DoPlayerDeath", "CheckRevivable", function(ply, killer, dmginfo) if ply.lastHitGroup == HITGROUP_HEAD then ply.IsRevivable = false else ply.IsRevivable = true end end) hook.Add("ScalePlayerDamage", "CheckForHeadshot", function(ply, hitGroup) ply.lastHitGroup = hitGroup end) [/lua] This works. Feel free to make something better. Just threw it together in a minute or so. Now you would add an if ply.IsRevivable to your revive thingy, and it would return a true if revivable, and false if not.[/QUOTE] For some reason ply.IsRevivable is always false when it checks. I tried setting it to true on first spawn, it worked but now it's always set to true. It detects the headshot but never Changes the value. Update: I'm starting to think it's setting the killers ply.IsRevivable instead of the victims. How would we bypass this? [editline]18th August 2014[/editline] Ok here's my defibs code. Since I'm clueless maybe someone else can fix it. [code] function Defib_Shoot(ply,ent) if(ply.FireTime == nil ) then ply.FireTime = 0 end if((CurTime() - ply.FireTime) >= 5) then ply.FireTime = CurTime() if(ply:GetNWInt("DefibCharge") >= Kun_DefibChargeAmtNeed) then if(ent != nil and ent:IsValid() and ent:GetClass() == "prop_ragdoll") then ply:EmitSound(("ambient/energy/zap1.wav)) ply:SetNWInt("DefinCharge",0) local targ = ent.PlyGuy if(ent.PlyGuy != nil and ent.PlyGuy:IsValid() and targ.SleepRagdoll == nil) then targ:Spawn() targ:SetPos(ent:GetPos()) if(targ.PriorDeathJob == targ:Team()) then for k,v in pairs(targ.KunWepTbl) do targ:Give(v) end end end end ent:Remove() end else ply:EmitSound("buttons/combine_button_locked.wav) end end [/code] That's the core revive/defibs function. Now if you could please tell me where I place if ply.IsDead and how to check if defibs and being shot at players, I'd say we're done.
Sorry, you need to Log In to post a reply to this thread.