generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Server-side stamina

Previous Thread :: Next Thread 
Gentaurg is not online. Gentaurg
Joined: 19 Mar 2011
Total Posts: 8648
08 Mar 2016 02:21 PM
I want to make a server-side stamina system. It needs to regenerate at X stamina per second consistently. How would I go about making this?
Report Abuse
sonihi is not online. sonihi
Joined: 27 Jun 2009
Total Posts: 3655
08 Mar 2016 02:23 PM
You could make it so if the player spawns a stamina script with a value is added to his character.


Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
08 Mar 2016 02:24 PM
Regular script lol
Report Abuse
Gentaurg is not online. Gentaurg
Joined: 19 Mar 2011
Total Posts: 8648
08 Mar 2016 02:37 PM
I was thinking about doing that but I was wondering if there was some other clever way. Does it cause lag to have many scripts that do this?
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
08 Mar 2016 02:49 PM
have a table of all the players' staminas. Use a remotefunctions to tell the server that a client wants to use stamina, server checks if there's enough for the wanted action, if so return true, if not return false
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
08 Mar 2016 02:54 PM
I forgot the second part
I suppose you're wondering about efficiency. Firing an RF/RE multiple times in a short time shouldn't be too big of a problem but I bet you can make the delay a bit longer. I doubt it matters if a player can run for .3 secs longer in certain scenarios

also I swear I took the s in "remotefunctions" out
Report Abuse
RottenWraith is not online. RottenWraith
Joined: 16 Aug 2008
Total Posts: 1587
08 Mar 2016 02:56 PM
Have two stamina values per player. One is stored in local storage, the other in server storage. Whenever the player uses or gains stamina, update both the local and server values at the same time. Check only the server value when determining if the player has enough stamina to do a certain action, and periodically reset the client side value to the server side value.

The reasoning for this method is that you want any GUI's or other visuals to instantly reflect changes in stamina, providing feedback is an important trick in making a game not feel laggy.

There may be better ways to do it, but that's a method that I like.
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
08 Mar 2016 02:58 PM
with my method you also want to decrease the stamina as well as return the new stamina for GUIs though for those you want the smallest possible delay which again shouldn't be a big problem
Report Abuse
Gentaurg is not online. Gentaurg
Joined: 19 Mar 2011
Total Posts: 8648
08 Mar 2016 03:48 PM
what I'm most concerned about is the regeneration - wouldn't I have to run one while loop per player?
Report Abuse
sonihi is not online. sonihi
Joined: 27 Jun 2009
Total Posts: 3655
08 Mar 2016 04:33 PM
You could have them all in a table and add to them one after another


Report Abuse
RottenWraith is not online. RottenWraith
Joined: 16 Aug 2008
Total Posts: 1587
08 Mar 2016 04:33 PM
No, you can have them all regenerate at a set rate from one script
Report Abuse
Gentaurg is not online. Gentaurg
Joined: 19 Mar 2011
Total Posts: 8648
08 Mar 2016 04:40 PM
so every player would regenerate stamina at the exact same time?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image