Changing jump boosts, fretta classes, and convars.

Hey. I’ve just started scripting Lua in GMod, and I have a few questions, and some things I’m confused about.

  1. How can I change/fine-tune the boost that happens when jumping while running in a single direction? I think it’s a bit too powerful. Ideally, I want something like CS:S (I’m trying to make the “physics” in my gamemode similar).

  2. I’m making a Fretta based gamemode, and I noticed on the wiki it said player classes must be shared, but I added debugging messages (if SERVER/CLIENT… ), and I could only ever notice the server responding. I’m not sure if it was a server only function I used, or if I need to add my class file to the client. Perhaps I just don’t understand shared files enough yet. Ideas/tips?

  3. What should I use to alter the value of a convar? I would have thought I could figure this one out by myself, but I really can only find get methods on the wiki. The only thing I can think, is that I should alter them by using CreateConVar, but then I’m a bit confused as to what the flags and such should be.

  4. Lastly, on the topic of CS:S physics, I noticed when jumping that it seems as though players can “step” mid-jump to get higher than they should be able to. I thought to remedy this by setting the players StepSize to “0” while a player is in the air. Regardless of if this would actually work or not, I was thinking to add, in the players Think(), some code to check when they jumped and when they landed. How would I go about saving the players state, should I use the player as a table index? What’s the preferred way of storing per player data?

Hopefully I explained things well enough, I’d appreciate help with any of these problems. Thanks~

How can I change the boost players receive with running jumps?
Are fretta classes (player_class) shared? Explain?
How can I modify the value of an existing convar?
Any advice/examples on storing per player data?

  1. Durrrr I know this but it is not coming to mind. I think what you have to do is override the default gamemode hooks that you use to move, like **[Gamemode.Move](**. For example
if pl:KeyPressed( IN_JUMP ) then
move:SetVelocity( pl:GetForward() * -100 )
Just an idea though. You can mess around with that.

  1. Yes, they are shared. The must be shared because you use IncludePlayerClasses in the shared.lua, so you should be able to access all that stuff on the client (assuming it’s global/the shared.lua is included).

  2. Another one of those things I know but cannot remember. As a last resort, you can run a console command to change it. If this is serverside, then use **[Game.ConsoleCommand](**. If it’s clientside, use **[G.RunConsoleCommand](**.

  1. **[Player.SetPData](** is your best bet. It saves the data between player sessions.

Good luck in your travels in to the GLua world. We can always use more coders like you (that is, the literate/IQ > 20 ones). Apologies if I’m being unclear/stupid.

Thanks for the response. I actually just switched to using srcds for testing and noticed that the jump is fixed/normal by default. I’ve no idea why it’s different for listen servers, or if that goes for every listen server. The reason I was confused about classes being shared was because I assumed the hooks used in my class template were shared by default, which was not the case. I used usermessages to do what I needed in those hooks, and I think I have a better understanding of it now. I just hope the Move()/Think() hooks are actually shared. Using a console command to change variables works perfect for me, I only need to change some server settings when my gamemode is launched. And SetPData looks good, and I’m sure I’ll make use of it with the upcoming things I’m working on, but I was thinking of temp storage for setting player states in a Think(), or similar function.

Anyway, my player class is pretty much fixed now, besides some minor things. I managed to get it pretty much unit-accurate for jumping, crouch jumping, crawling/walking under things etc, and of course, the view offsets. =3

To temporarily store data about a player you can simply do this :

ply.TempData = “Blah”

Where ply is a player object and TempData and it’s value can be anything you like.