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!

[Clockwork]Primary Needs v1.1

Discussion in 'Plugins' started by Arbiter329, Apr 10, 2013.

  1. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    Okey seems people dont know how to read.

    Updated and has No Bars
    Click Here!

    Updated and has Bars
    Click Here!

    Updated Items
    Click Here!
     
  2. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    That doesnt relate to you but the people who want the bars and plugin but adding those into it is very easy.
     
  3. Arbiter329

    Arbiter329 Owner of Arc-Factory Roleplay

    Re: [Clockwork]Primary Needs v1.0

    Quick Tutorial

    Step 1: Take the item you want to modify, and open the code in your preferred Editor. Below is the code for HL2RP's Breen's Water.

    Code:
    --[[
    	? 2013 CloudSixteen.com do not share, re-distribute or modify
    	without permission of its author ([email protected]).
    --]]
    
    local ITEM = Clockwork.item:New();
    ITEM.name = "Breen's Water";
    ITEM.cost = 10;
    ITEM.model = "models/props_junk/popcan01a.mdl";
    ITEM.weight = 0.5;
    ITEM.access = "1";
    ITEM.useText = "Drink";
    ITEM.business = true;
    ITEM.category = "Consumables";
    ITEM.description = "A blue aluminium can, it swishes when you shake it.";
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
    	player:SetCharacterData("stamina", 100);
    	player:SetHealth(math.Clamp(player:Health() + 4, 0, player:GetMaxHealth()));
    	
    	player:BoostAttribute(self.name, ATB_AGILITY, 1, 120);
    	player:BoostAttribute(self.name, ATB_STAMINA, 1, 120);
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position) end;
    
    -- Called when the item's functions should be edited.
    function ITEM:OnEditFunctions(functions)
    	if (Schema:PlayerIsCombine(Clockwork.Client, false)) then
    		for k, v in pairs(functions) do
    			if (v == "Drink") then functions[k] = nil; end;
    		end;
    	end;
    end;
    
    ITEM:Register();
    
    Step 2: Now, we'll want to add another line in the ITEM:OnUse function, we want that line to use this Code:

    Code:
    player:SetCharacterData( "thirst", math.Clamp(player:GetCharacterData("thirst") - 55, 0, 100) );
    Our Code should now look like this:

    Code:
    --[[
    	? 2013 CloudSixteen.com do not share, re-distribute or modify
    	without permission of its author ([email protected]).
    --]]
    
    local ITEM = Clockwork.item:New();
    ITEM.name = "Breen's Water";
    ITEM.cost = 10;
    ITEM.model = "models/props_junk/popcan01a.mdl";
    ITEM.weight = 0.5;
    ITEM.access = "1";
    ITEM.useText = "Drink";
    ITEM.business = true;
    ITEM.category = "Consumables";
    ITEM.description = "A blue aluminium can, it swishes when you shake it.";
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
    	player:SetCharacterData("stamina", 100);
    	player:SetHealth(math.Clamp(player:Health() + 4, 0, player:GetMaxHealth()));
    	
    	player:BoostAttribute(self.name, ATB_AGILITY, 1, 120);
    	player:BoostAttribute(self.name, ATB_STAMINA, 1, 120);
    
    	player:SetCharacterData( "thirst", math.Clamp(player:GetCharacterData("thirst") - 55, 0, 100) );
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position) end;
    
    -- Called when the item's functions should be edited.
    function ITEM:OnEditFunctions(functions)
    	if (Schema:PlayerIsCombine(Clockwork.Client, false)) then
    		for k, v in pairs(functions) do
    			if (v == "Drink") then functions[k] = nil; end;
    		end;
    	end;
    end;
    
    ITEM:Register();
    
    Step 3:

    Now, in that line of code, Replace thirst with either Sleep or Hunger if you want it to remove Sleep or Hunger instead of thirst.

    You can also Alter 55 to whatever number you want. That number is how much is deducted from the Player's Hunger, Thirst, or Sleep. Remember, Maximum Hunger is 100, Minimum is 0.

    _____________________________________________________________________

    You can also stack up effects on an item, for example the following item will lower Thirst, Hunger, and Sleep.

    Code:
    --[[
    	? 2013 CloudSixteen.com do not share, re-distribute or modify
    	without permission of its author ([email protected]).
    --]]
    
    local ITEM = Clockwork.item:New();
    ITEM.name = "Magical Popcan";
    ITEM.cost = 1337;
    ITEM.model = "models/props_junk/popcan01a.mdl";
    ITEM.weight = 0.5;
    ITEM.access = "1";
    ITEM.useText = "Eat";
    ITEM.business = true;
    ITEM.category = "Consumables";
    ITEM.description = "A magic can that makes you feel good when you eat it.";
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
    	player:SetCharacterData("stamina", 100);
    	player:SetHealth(math.Clamp(player:Health() + 4, 0, player:GetMaxHealth()));
    	
    	player:BoostAttribute(self.name, ATB_AGILITY, 1, 120);
    	player:BoostAttribute(self.name, ATB_STAMINA, 1, 120);
    
    	player:SetCharacterData( "thirst", math.Clamp(player:GetCharacterData("thirst") - 100, 0, 100) );
    	player:SetCharacterData( "hunger", math.Clamp(player:GetCharacterData("hunger") - 100, 0, 100) );
    	player:SetCharacterData( "sleep", math.Clamp(player:GetCharacterData("sleep") - 100, 0, 100) );
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position) end;
    
    ITEM:Register();
    
    For more examples, take a look at the code for items in the Items plugin.

    _____________________________________________________________________

    You can also make it add to the player's thirst/sleep/hunger. If, for example, you wanted to make Salty peanuts.

    Example:

    Code:
    player:SetCharacterData( "thirst", math.Clamp(player:GetCharacterData("thirst") + 25, 0, 100) );
     
  4. Re: [Clockwork]Primary Needs v1.0

    Can someone tell me how to add the bars in details
     
  5. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    *Face desk*

    I made a post

     
  6. Re: [Clockwork]Primary Needs v1.0

    Lol.. (I AM A RETARD)
     
  7. Re: [Clockwork]Primary Needs v1.0

    How do i make it so combines don't need to sleep, drink and eat?
     
  8. Mobious

    Mobious O.L.D.fag - I never asked for this.

    Re: [Clockwork]Primary Needs v1.0

    Can you reupload or give code here? :c
     
  9. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    1 second mate.
     
  10. Re: [Clockwork]Primary Needs v1.0

    I too would like to see a fixed version of the HUD. <3
     
  11. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    Its not hard but k I totaly forgot earlier. 1 sec.

    Edit:

    Heres my dropboxfolder with the updated ones.

    Click here!

    Theres two versions 'PrimaryNeedsBars' Which has the bars and 'PrimaryNeeds' Which is the default plugin.
     
  12. Mobious

    Mobious O.L.D.fag - I never asked for this.

    Re: [Clockwork]Primary Needs v1.0

    I allready make it by myself D: And I revers system for good view (from 100 to 0).
    [​IMG]
     
  13. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    Do you mean you just read the first few posts and copied the cl_hooks cut out over?
     
  14. Mobious

    Mobious O.L.D.fag - I never asked for this.

    Re: [Clockwork]Primary Needs v1.0

    Yes, and changed system (from 100 to 0). Also.. I have a new problem: how to make player die, if hunger/thirst = 1?

    Code:
     if ( hunger >= 80 ) then
      hungerText = "Well Fed";
      hungerColor = Color(255,209,98,255); -- green
     elseif( hunger >= 60 ) then
      hungerText = "Satisfied";
      color = Color(255,250,85,255); -- lime green
     elseif( hunger >= 40 ) then
      hungerText = "Hungry";
      hungerColor = Color(255,200,68,255); -- yellow
     elseif( hunger >= 20 ) then
      hungerText = "Very Hungry"; -- orange
      hungerColor = Color(102,194,48,255);
     elseif( hunger >= 0 ) then
      hungerText = "Starving"; -- red
      hungerColor = Color(189,134,24,255);
     elseif( hunger = 1 ) then
      player:TakeDamage(100, true);
     end;
     
    - Doesn't work. Bars just disapeare.
     
  15. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    Code:
    if ( hunger >= 80 ) then
      hungerText = "Well Fed";
      hungerColor = Color(255,209,98,255); -- green
     elseif( hunger >= 60 ) then
      hungerText = "Satisfied";
      color = Color(255,250,85,255); -- lime green
     elseif( hunger >= 40 ) then
      hungerText = "Hungry";
      hungerColor = Color(255,200,68,255); -- yellow
     elseif( hunger >= 20 ) then
      hungerText = "Very Hungry"; -- orange
      hungerColor = Color(102,194,48,255);
     elseif( hunger >= 0 ) then
      hungerText = "Starving"; -- red
      hungerColor = Color(189,134,24,255);
      player:TakeDamage(100, true);
      end;
    Try that.

    1000 POSTS BABY
     
  16. Re: [Clockwork]Primary Needs v1.0

    Because it's supposed to be == not =

    = means setting a variable.
    == means reading a variable.
     
  17. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    To solve that all you need to do is make it read it so if hunger less than or equal too 0 ( hunger <= 0) then it kills you. I wouldn't recommend instant death tho. I'd make it trigger-hurt the player.
     
  18. Mobious

    Mobious O.L.D.fag - I never asked for this.

    Re: [Clockwork]Primary Needs v1.0

    Code:
     if ( hunger >= 80 ) then
      hungerText = "Well Fed";
      hungerColor = Color(255,209,98,255); -- green
     elseif( hunger >= 60 ) then
      hungerText = "Satisfied";
      color = Color(255,250,85,255); -- lime green
     elseif( hunger >= 40 ) then
      hungerText = "Hungry";
      hungerColor = Color(255,200,68,255); -- yellow
     elseif( hunger >= 20 ) then
      hungerText = "Very Hungry"; -- orange
      hungerColor = Color(102,194,48,255);
     elseif( hunger >= 2 ) then
      hungerText = "Starving"; -- red
      hungerColor = Color(189,134,24,255);
     elseif( hunger <= 1 ) then
      player:TakeDamage(300, true);
     end;
    Doesn't work.. And player:TakeDamage(300, player, player) doesn't work too.

    I want so, but I don't know how to do that.. Even radiation doesn't kill, I don't have example.

    Code:
     elseif( hunger >= 0 ) then
      hungerText = "Starving"; -- red
      hungerColor = Color(189,134,24,255);
      player:TakeDamage(3, true);
     end;
    Doesn't work. Bars disapeares..
     
  19. Mobious

    Mobious O.L.D.fag - I never asked for this.

    Re: [Clockwork]Primary Needs v1.0

    Guys? :c Anyone? :c How to make player die, if his hunger/thirst <= 1?
    .........
    My friend helped me. Thanks, Garry.
    Code:
    -- Called when a player's character data should be restored.
    function PLUGIN:PlayerRestoreCharacterData(player, data)
    	if ( !data["hunger"] ) then
    		data["hunger"] = 100;
    	end;
    	if ( !data["thirst"] ) then
    		data["thirst"] = 100;
    	end;
    	if ( !data["sleep"] ) then
    		data["sleep"] = 100
    	end;
    end;
    
    -- Called when a player's shared variables should be set.
    function PLUGIN:PlayerSetSharedVars(player, curTime)
    	player:SetSharedVar( "hunger", math.Round( player:GetCharacterData("hunger") ) );
    	player:SetSharedVar( "thirst", math.Round( player:GetCharacterData("thirst") ) );
    	player:SetSharedVar( "sleep", math.Round( player:GetCharacterData("sleep") ) );
    	local position = player:GetPos();
    	
    	if (player:Alive() and !player:IsRagdolled() and player:GetVelocity():Length() > 0) then
    		
    		if (player:GetCharacterData("thirst") == 1) then
    		    player:Kill();
    			player:SetCharacterData("thirst", 40);
    			player:SetCharacterData("hunger", 20);
    		elseif (player:GetCharacterData("thirst") <= 10) then
    			player:BoostAttribute("Thirst", ATB_ACROBATICS, -50);
    			player:BoostAttribute("Thirst", ATB_ENDURANCE, -50);
    			player:BoostAttribute("Thirst", ATB_STRENGTH, -50);
    			player:BoostAttribute("Thirst", ATB_AGILITY, -50);
    			player:BoostAttribute("Thirst", ATB_DEXTERITY, -50);
    			player:BoostAttribute("Thirst", ATB_MEDICAL, -50);
    		else
    			player:BoostAttribute("Thirst", ATB_ACROBATICS, false);
    			player:BoostAttribute("Thirst", ATB_ENDURANCE, false);
    			player:BoostAttribute("Thirst", ATB_STRENGTH, false);
    			player:BoostAttribute("Thirst", ATB_AGILITY, false);
    			player:BoostAttribute("Thirst", ATB_DEXTERITY, false);
    			player:BoostAttribute("Thirst", ATB_MEDICAL, false);
    		end;
    	end;
    	if (player:Alive() and !player:IsRagdolled() and player:GetVelocity():Length() > 0) then
    		
    		if (tonumber(player:GetCharacterData("hunger")) == 1) then
    		    player:Kill();
    			player:SetCharacterData("hunger", 20);
    			player:SetCharacterData("thirst", 40);
    		elseif (tonumber(player:GetCharacterData("hunger")) <= 10) then
    			player:BoostAttribute("Hunger", ATB_ACROBATICS, -30);
    			player:BoostAttribute("Hunger", ATB_ENDURANCE, -30);
    			player:BoostAttribute("Hunger", ATB_STRENGTH, -30);
    			player:BoostAttribute("Hunger", ATB_AGILITY, -30);
    			player:BoostAttribute("Hunger", ATB_DEXTERITY, -30);
    			player:BoostAttribute("Hunger", ATB_MEDICAL, -30);
    		elseif (tonumber(player:GetCharacterData("hunger")) <= 20) then
    			player:BoostAttribute("Hunger", ATB_ACROBATICS, -25);
    			player:BoostAttribute("Hunger", ATB_ENDURANCE, -25);
    			player:BoostAttribute("Hunger", ATB_STRENGTH, -25);
    			player:BoostAttribute("Hunger", ATB_AGILITY, -25);
    			player:BoostAttribute("Hunger", ATB_DEXTERITY, -25);
    			player:BoostAttribute("Hunger", ATB_MEDICAL, -25);
    		elseif (tonumber(player:GetCharacterData("hunger")) <= 30) then
    			player:BoostAttribute("Hunger", ATB_ACROBATICS, -10);
    			player:BoostAttribute("Hunger", ATB_ENDURANCE, -10);
    			player:BoostAttribute("Hunger", ATB_STRENGTH, -10);
    			player:BoostAttribute("Hunger", ATB_AGILITY, -10);
    			player:BoostAttribute("Hunger", ATB_DEXTERITY, -10);
    			player:BoostAttribute("Hunger", ATB_MEDICAL, -10);
    		else
    			player:BoostAttribute("Hunger", ATB_ACROBATICS, false);
    			player:BoostAttribute("Hunger", ATB_ENDURANCE, false);
    			player:BoostAttribute("Hunger", ATB_STRENGTH, false);
    			player:BoostAttribute("Hunger", ATB_AGILITY, false);
    			player:BoostAttribute("Hunger", ATB_DEXTERITY, false);
    			player:BoostAttribute("Hunger", ATB_MEDICAL, false);
    		end;
    	end;
    end;
    
    -- Called at an interval while a player is connected.
    function PLUGIN:PlayerThink(player, curTime, infoTable)
    	local alive = player:Alive();
    	local faction = player:GetFaction();
    	local curTime = CurTime();
    	
    	if ( player:Alive() ) then
    		if (tonumber(player:GetCharacterData("sleep")) <= 5) then
    			if (!player:IsRagdolled() and !player:IsNoClipping()) then
    				if (!player.nextSleepKO or curTime >= player.nextSleepKO) then
    					if (math.random(1, 100) == 100) then
    						Clockwork.player:SetRagdollState(player, RAGDOLL_KNOCKEDOUT, math.random(5, 15));
    						Clockwork.chatBox:Add(player, nil, "sleep", "** Your lack of sleep catches up to you, and you can nolonger keep your eyes open.");
    						player.nextSleepKO = curTime + 25;
    					end;
    				end;
    			end;
    		end;
    		if (!player.nextHunger or curTime >= player.nextHunger) then
    			player:SetCharacterData( "hunger", math.Clamp(player:GetCharacterData("hunger") - 1, 0, 100) );
    			player.nextHunger = curTime + 36;
    		end;
    		if (!player.nextThirst or curTime >= player.nextThirst) then
    			player:SetCharacterData( "thirst", math.Clamp(player:GetCharacterData("thirst") - 1, 0, 100) );
    			player.nextThirst = curTime + 18;
    		end;
    		if (!player.nextSleep or curTime >= player.nextSleep) then
    			player:SetCharacterData( "sleep", math.Clamp(player:GetCharacterData("sleep") - 1, 0, 100) );
    			player.nextSleep = curTime + 108;
    		end;
    	end;
    end;
    
    function PLUGIN:PlayerShouldStaminaRegenerate(player)
    	local faction = player:GetFaction();
    	if ( tonumber(player:GetCharacterData("hunger")) <= 30 ) then
    		return false;
    	end;
    end;
    sv_hooks.lua

    Don't forget, that this is for revers system (from 100 to 0).
     
  20. Garrus

    Garrus I like dragons, yargh.

    Re: [Clockwork]Primary Needs v1.0

    Would be annoying to AFKers who sit on the server and idle.. Not sure if this is a good idea... Then there is also the fact that when you die with the Damage over time... and it killed you (assuming it did), then it would affect you when you respawn and just kill you again. (Assuming it killed you... and didn't just PK you..)
     

Previous Readers (Total: 0)