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. Arbiter329

    Arbiter329 Owner of Arc-Factory Roleplay

    Name: Primary Needs

    Version: 1.1

    Compatibility: All Schemas

    Install Instructions: To install Primary Needs, simply drop the Zipped folder into your Schema's plugin's Directory.

    Pictures: [Coming Soon]

    Description: Expanding on my initial Hunger/Thirst plugin, Primary Needs adds Sleep along with slower Hunger/Thirst gain. The Primary features are as follow;

    Hunger: Over time, a Character will get hungry. When maximum hunger is reached you will get Blurred vision, lowered stats, and Stamina won't regenerate. Hunger is lowered by eating food items.

    Thirst: A character will become thirsty quicker than they will become hungry. When maximum thirst is reached, a player will suffer blurred vision, and lowered attributes. Thirst is lowered by drinking fluids such as water.

    Sleep: Sleep is the slowest to come into effect, however once it does you will suffer slightly reduced Attributes, blurred vision, and will get KO's at random times, due to your inability to stay awake. Sleep is staved off with Stimulants such as coffee, or by Sleeping with /Sleep.

    Secondary features include several admin commands for modifying Hunger, thirst, or sleep. (/CharSetHunger, /CharSetThirst, /CharSetSleep respectively).

    There is also a /Sleep command that will Ragdoll the player for 30 Seconds, and removes 50 points from their overall Sleep. /Sleep can ONLY be used if your sleep level Exceeds 70 points.

    Extra: There is also an Items Plugin that includes a small selection of items that will lower your Hunger/Thirst/Sleep. (Vanilla Clockwork items will NOT Remove hunger, thirst, or sleep. So if you want them to remove points from either, look at my items plugin to see how to make Food and drink usable.)

    Also, any food or drink made to work with the my old Hunger Plugin will still work. So no need for Rewriting your items if you used my old Hunger system.

    Downloads:

    [Primary Needs Download]

    [Items Download]
     
  2. Soret

    Soret derp

    Re: [Clockwork]Primary Needs v1.0

    You could try expand on your idea, and make it visible to everyone else, that way you basically create a dynamic system that not just excludes third parties from interacting with a character.

    It has a lot of roleplay potential.
     
  3. sants1

    sants1 I'm an asshole. That's all.

    Re: [Clockwork]Primary Needs v1.0

    This is now being used on HeroZGaming.

    Thanks.
     
  4. xXlogatorXx

    xXlogatorXx Guest

    Re: [Clockwork]Primary Needs v1.0

    Would it be possible to make it a HUD thing instead of in the F1 menu, great job anyways :)
     
  5. xXlogatorXx

    xXlogatorXx Guest

    Re: [Clockwork]Primary Needs v1.0

    That would be awesome, thank you :D
     
  6. Re: [Clockwork]Primary Needs v1.0

    Hey, I'm a little new to LUA so if you guys could help me that'd be greatly appreciated.
    I tried adding a little code snippet to this in order to get bars to display with this information but they show up like this:

    [​IMG]

    Here's my cl_hooks:
    Code:
    local PLUGIN = PLUGIN;
    
    -- Called when the local player's motion blurs should be adjusted.
    function PLUGIN:PlayerAdjustMotionBlurs(motionBlurs)
    	if ( Clockwork.Client:HasInitialized() ) then
    		local hunger = Clockwork.Client:GetSharedVar("hunger");
    		local thirst = Clockwork.Client:GetSharedVar("thirst");
    		local sleep = Clockwork.Client:GetSharedVar("sleep");
    		local data = math.max(hunger);
    		local data2 = math.max(thirst);
    		local data3 = math.max(sleep);
    		
    		if (data >= 90 or data2 >= 90 or data3 >= 85) then
    			motionBlurs.blurTable["needs"] = 1 - ( (0.25 / 10) * ( 10 - (100 - data) ) );
    		end;
    	end;
    end;
    
    function PLUGIN:GetBars(bars)
    	local hunger = Clockwork.Client:GetSharedVar("hunger");
    	local thirst = Clockwork.Client:GetSharedVar("thirst");
    	local sleep = Clockwork.Client:GetSharedVar("sleep");
    	
    	if (!self.hunger) then
    		self.hunger = hunger;
    	else
    		self.hunger = math.Approach(self.hunger, hunger, 1);
    	end;
    	
    	if (!self.thirst) then
    		self.thirst = thirst;
    	else
    		self.thirst = math.Approach(self.thirst, thirst, 1);
    	end;
    	
    	if (!self.sleep) then
    		self.sleep = sleep;
    	else
    		self.sleep = math.Approach(self.sleep, sleep, 1);
    	end;
    	
    	local text,color = "Unknown", Color(255,255,255,255);
    	
    	if ( thirst <= 30 ) then
    		text = "Hydrated";
    		color = Color(34,139,34,255); -- green
    	elseif( thirst <= 50 ) then
    		text = "Satisfied";
    		color = Color(102,255,51,255); -- lime green
    	elseif( thirst <= 70 ) then
    		text = "Thirsty";
    		color = Color(255,255,0,255); -- yellow
    	elseif( thirst <= 80 ) then
    		text = "Very Thirsty"; -- orange
    		color = Color(255,140,0,255);
    	elseif( thirst <= 100 ) then
    		text = "Dehydrated"; -- red
    		color = Color(255,0,0,255);
    	end;
    	
    	if ( hunger <= 30 ) then
    		text = "Well Fed";
    		color = Color(34,139,34,255); -- green
    	elseif( hunger <= 50 ) then
    		text = "Satisfied";
    		color = Color(102,255,51,255); -- lime green
    	elseif( hunger <= 70 ) then
    		text = "Hungry";
    		color = Color(255,255,0,255); -- yellow
    	elseif( hunger <= 80 ) then
    		text = "Very Hungry"; -- orange
    		color = Color(255,140,0,255);
    	elseif( hunger <= 100 ) then
    		text = "Starving"; -- red
    		color = Color(255,0,0,255);
    	end;
    	
    	if ( sleep <= 30 ) then
    		text = "Well Rested";
    		color = Color(34,139,34,255); -- green
    	elseif( sleep <= 50 ) then
    		text = "Rested";
    		color = Color(102,255,51,255); -- lime green
    	elseif( sleep <= 70 ) then
    		text = "Tired";
    		color = Color(255,255,0,255); -- yellow
    	elseif( sleep <= 80 ) then
    		text = "Very Tired"; -- orange
    		color = Color(255,140,0,255);
    	elseif( sleep <= 100 ) then
    		text = "Exhausted"; -- red
    		color = Color(255,0,0,255);
    	end;
    	
    	Clockwork.bars:Add("HUNGER", color, text, self.hunger, 100, self.hunger < 90);
    	Clockwork.bars:Add("THIRST", color, text, self.thirst, 100, self.thirst < 90);
    	Clockwork.bars:Add("SLEEP", color, text, self.sleep, 100, self.sleep < 90);
    end;
    
    -- Called when the F1 Text is needed.
    function PLUGIN:GetPlayerInfoText(playerInfoText)
    	local hunger = tonumber(Clockwork.Client:GetSharedVar("hunger"));
    	local thirst = tonumber(Clockwork.Client:GetSharedVar("thirst"));
    	local sleep = tonumber(Clockwork.Client:GetSharedVar("sleep"));
    	
    	if (!self.hunger) then
    		self.hunger = hunger;
    	else
    		self.hunger = math.Approach(self.hunger, hunger, 1);
    	end;
    	
    	if (!self.thirst) then
    		self.thirst = thirst;
    	else
    		self.thirst = math.Approach(self.thirst, thirst, 2);
    	end;
    	
    	if (!self.sleep) then
    		self.sleep = sleep;
    	else
    		self.sleep = math.Approach(self.sleep, sleep, 3);
    	end;
    	
    	local text = "Unknown";
    	local thirstText = "Unknown";
    	local sleepText = "Unknown";
    	
    	if ( hunger <= 30 ) then
    		text = "Well Fed";
    	elseif( hunger <= 50 ) then
    		text = "Satisfied";
    	elseif( hunger <= 70 ) then
    		text = "Hungry";
    	elseif( hunger <= 80 ) then
    		text = "Very Hungry";
    	elseif( hunger <= 100 ) then
    		text = "Starving";
    	end;
    	
    	if ( thirst <= 30 ) then
    		thirstText = "Hydrated";
    	elseif( thirst <= 50 ) then
    		thirstText = "Satisfied";
    	elseif( thirst <= 70 ) then
    		thirstText = "Thirsty";
    	elseif( thirst <= 80 ) then
    		thirstText = "Very Thirsty";
    	elseif( thirst <= 100 ) then
    		thirstText = "Dehydrated";
    	end;
    	
    	if ( sleep <= 30 ) then
    		thirstText = "Well Rested";
    	elseif( sleep <= 50 ) then
    		thirstText = "Rested";
    	elseif( sleep <= 70 ) then
    		thirstText = "Tired";
    	elseif( sleep <= 80 ) then
    		thirstText = "Very Tired";
    	elseif( sleep <= 100 ) then
    		thirstText = "Exhausted";
    	end;
    	
    	if (hunger > -1 or thirst > -1 or sleep > -1) then
    		playerInfoText:Add("Header", "[Physical Needs]");
    	end;
    	if (hunger > -1) then
    		playerInfoText:Add("HUNGER", "Hunger Level: "..text);
    	end;
    	if (thirst > -1) then
    		playerInfoText:Add("THIRST", "Thirst Level: "..thirstText);
    	end;
    	if (sleep > -1) then
    		playerInfoText:Add("SLEEP", "Sleep Level: "..tostring(sleep).."%");
    	end;
    	if (hunger > -1 or thirst > -1 or sleep > -1) then
    		playerInfoText:Add("Header2", " ");
    	end;
    	if (hunger > -1 and thirst > -1 and sleep > -1) then
    		playerInfoText:Add("Header3", "[Other]");
    	end;
    end;
    
    Any help is greatly appreciated here, thanks!
     
  7. Arbiter329

    Arbiter329 Owner of Arc-Factory Roleplay

    Re: [Clockwork]Primary Needs v1.0

    You're using the same Variable for the Text/Color of the Bars. Since they Progress at different rates, you need to use different Variables. (Otherwise, they will all have the Same text and Color.)

    Here, this should fix your problem.

    Code:
    function PLUGIN:GetBars(bars)
    	local hunger = Clockwork.Client:GetSharedVar("hunger");
    	local thirst = Clockwork.Client:GetSharedVar("thirst");
    	local sleep = Clockwork.Client:GetSharedVar("sleep");
    	
    	if (!self.hunger) then
    		self.hunger = hunger;
    	else
    		self.hunger = math.Approach(self.hunger, hunger, 1);
    	end;
    	
    	if (!self.thirst) then
    		self.thirst = thirst;
    	else
    		self.thirst = math.Approach(self.thirst, thirst, 1);
    	end;
    	
    	if (!self.sleep) then
    		self.sleep = sleep;
    	else
    		self.sleep = math.Approach(self.sleep, sleep, 1);
    	end;
    	
    	local text,color = "Unknown", Color(255,255,255,255);
    	
    	if ( thirst <= 30 ) then
    		text = "Hydrated";
    		color = Color(34,139,34,255); -- green
    	elseif( thirst <= 50 ) then
    		text = "Satisfied";
    		color = Color(102,255,51,255); -- lime green
    	elseif( thirst <= 70 ) then
    		text = "Thirsty";
    		color = Color(255,255,0,255); -- yellow
    	elseif( thirst <= 80 ) then
    		text = "Very Thirsty"; -- orange
    		color = Color(255,140,0,255);
    	elseif( thirst <= 100 ) then
    		text = "Dehydrated"; -- red
    		color = Color(255,0,0,255);
    	end;
    	
    	if ( hunger <= 30 ) then
    		hungerText = "Well Fed";
    		hungerColor = Color(34,139,34,255); -- green
    	elseif( hunger <= 50 ) then
    		hungerText = "Satisfied";
    		color = Color(102,255,51,255); -- lime green
    	elseif( hunger <= 70 ) then
    		hungerText = "Hungry";
    		hungerColor = Color(255,255,0,255); -- yellow
    	elseif( hunger <= 80 ) then
    		hungerText = "Very Hungry"; -- orange
    		hungerColor = Color(255,140,0,255);
    	elseif( hunger <= 100 ) then
    		hungerText = "Starving"; -- red
    		hungerColor = Color(255,0,0,255);
    	end;
    	
    	if ( sleep <= 30 ) then
    		sleepText = "Well Rested";
    		sleepColor = Color(34,139,34,255); -- green
    	elseif( sleep <= 50 ) then
    		sleepText = "Rested";
    		sleepColor = Color(102,255,51,255); -- lime green
    	elseif( sleep <= 70 ) then
    		sleepText = "Tired";
    		sleepColor = Color(255,255,0,255); -- yellow
    	elseif( sleep <= 80 ) then
    		sleepText = "Very Tired"; -- orange
    		sleepColor = Color(255,140,0,255);
    	elseif( sleep <= 100 ) then
    		sleepText = "Exhausted"; -- red
    		sleepColor = Color(255,0,0,255);
    	end;
    	
    	Clockwork.bars:Add("HUNGER", hungerColor, hungerText, self.hunger, 100, self.hunger < 90);
    	Clockwork.bars:Add("THIRST", color, text, self.thirst, 100, self.thirst < 90);
    	Clockwork.bars:Add("SLEEP", sleepColor, sleepText, self.sleep, 100, self.sleep < 90);
    end;
    
     
  8. Re: [Clockwork]Primary Needs v1.0

    Thank you it served me well. 'Arbiter329'

    But how does one change the speed ? Example: for the sleep goes faster ?
     
  9. Arbiter329

    Arbiter329 Owner of Arc-Factory Roleplay

    Re: [Clockwork]Primary Needs v1.0

    I'll be adding a Config for hunger rates in the next version, but for now, go to sv_hooks.lua and find this:

    Code:
    if (!player.nextHunger or curTime >= player.nextHunger) then
    			player:SetCharacterData( "hunger", math.Clamp(player:GetCharacterData("hunger") + 1, 0, 100) );
    			player.nextHunger = curTime + 206;
    		end;
    		if (!player.nextThirst or curTime >= player.nextThirst) then
    			player:SetCharacterData( "thirst", math.Clamp(player:GetCharacterData("thirst") + 1, 0, 100) );
    			player.nextThirst = curTime + 103;
    		end;
    		if (!player.nextSleep or curTime >= player.nextSleep) then
    			player:SetCharacterData( "sleep", math.Clamp(player:GetCharacterData("sleep") + 1, 0, 100) );
    			player.nextSleep = curTime + 411;
    		end;
    
    Where you see the curTime + <Number here> the number is how many seconds it will take until the next point is added to their Hunger, Thirst, or Sleep. Raise or lower the number as you wish.
     
  10. Re: [Clockwork]Primary Needs v1.0

    Thank you dude. ;D
     
  11. Martinerrr

    Martinerrr Guest

  12. Arbiter329

    Arbiter329 Owner of Arc-Factory Roleplay

    Re: [Clockwork]Primary Needs v1.0

    Thanks for linking that thread, I'll be sure to keep some of those complaints in mind for the Next version.
     
  13. Cz.robeson

    Cz.robeson Guest

  14. Professorial Mister Man

    Professorial Mister Man I don&#039;t know what I&#039;m doing.

    Re: [Clockwork]Primary Needs v1.0

    Is there possibly a way to make it so combine don't need to sleep, like specific ranks? I'd imagine that the combine don't sleep when they reach a specific point of (following most servers use of augmentation) transhumanism they just sort of... stop being people?
     
  15. Nezahk

    Nezahk w0t is c0kwurk?

    Re: [Clockwork]Primary Needs v1.0

    Sorry for bump but, hes right. Is there any fix for this? I'd love to have Primary Needs running on my server.
     
  16. Kezter

    Kezter Certified Old Fag

    Re: [Clockwork]Primary Needs v1.0

    -snip-
     
  17. Faoeoa

    Faoeoa Bored as shit, will do simple devving.

    Re: [Clockwork]Primary Needs v1.0

    Danke, Kezter.
     
  18. Tommy

    Tommy Guest

    Re: [Clockwork]Primary Needs v1.0

    Just an idea, I don't know if it's possible; but I think it would be cool to add.

    As they get hungrier, thirstier, or sleepier, maybe it could add onto their physical description, or below it, a default saying. Such as, "Growling Stomach", "Parched Lips", or "Eyes Half-Closed".

    Just an idea, but I like this plugin nevertheless.
     
  19. Re: [Clockwork]Primary Needs v1.0

    What code and where should i put it for makeing the bars?
     

Previous Readers (Total: 0)