1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Reviving A Player

Discussion in 'Discussion' started by RJ, Jan 3, 2013.

  1. RJ

    RJ no pay Legend Clockwork Customer

    So I've got this code here and for some reason it's not working. I'm wondering if someone could take a look at it and maybe help me out with it.

    Code:
    sv_hooks.lua
     
    -- Called when a player takes damage.
    function Schema:PlayerTakeDamage(player, inflictor, attacker, hitGroup, damageInfo)
            if (player:Health() <= 55 and math.random() <= 0.75) then
                    if (player:GetAction(player) != "die") then
                            player:SetRagdollState( player, RAGDOLL_FALLENOVER, nil, nil, clockwork:ConvertForce( damageInfo:GetDamageForce() ) );
     
                            player:SetAction(player, "die", 60, 1, function()
                                    if ( IsValid(player) and player:Alive() ) then
                                            player:TakeDamage(99999, attacker, inflictor);
                                    end;
                            end);
                    end;
            end;
    end;
     
     
     
    -- Called when a player has been unragdolled.
    function Schema:PlayerUnragdolled(player, state, ragdoll)
            player:SetAction(player, "die", false);
    end;
     
    -- Called when a player has been ragdolled.
    function Schema:PlayerRagdolled(player, state, ragdoll)
            player:SetAction(player, "die", false);
    end;
     
     
    ------------------------------------------------------------------
     
    cl_hooks.lua
     
    -- Called when the post progress bar info is needed.
    function Schema:GetPostProgressBarInfo()
            if ( Clockwork.Client:Alive() ) then
                    local action, percentage = Clockwork.player:GetAction(Clockwork.Client, true);
     
                    if (action == "die") then
                            return {text = "You are slowly dying.", percentage = percentage, flash = percentage > 75};
                    end;
            end;
    end;
     
  2. connall

    connall Guest

    I can't tell why you're using the math.random() but you usually have to set the number it goes between.

    e.g math.random(1, 100) -- generates random number between 1 and 100.
     
  3. math.random with no arguments generates a random float number. I think that's what he wants because of the 0.75 next to it.
     

Previous Readers (Total: 0)