ULX

Author Topic: Player.SetRunSpeed  (Read 3198 times)

0 Members and 1 Guest are viewing this topic.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Player.SetRunSpeed
« on: July 10, 2014, 06:52:53 AM »
Hey guys,

I am the "developer" for a new server. You can't really call me a developer. I google crap until I figure it out, and the server owner acts like I'm a god because he has no idea how to internet, let alone anything to do with technical stuff.

Anyways, he saw on another server they had a ULX mod that allowed you to set players walk and run speeds. There was a selection menu similar to the psay menu, and then there were to sliders, similar to the sliders for changing gravity.

There was a mod that did something like this called SuperPowers, but that was in 2010 and the download link is long gone. So I was wondering if anyone could give me some guidance as to how to make a mod of ULX. I know the very very basics such as functions and hooks, but I'm not really sure how to do the sliders and selection menus or really how to integrate it with ULX. I read the ULib docs, but that doesn't seem to help with ULX.



Okay, so I've looked around in my server files, and I think I've found the place where the "modules" are declared. addons/ulx/lua/ulx/modules is pretty intuitive. It seems that hp is the simplest example of what I want to do, just have you choose a player and set a variable. The problem I have is I can't seem to find the graphical side. I have looked in xgui and those modules, but I can't find a place where hp sets up it's client side.



Still haven't found the graphical stuff, but I'm just going to assume it is un-needed for now, as I just pretty much copy-pasted the hp code and changed it to work for Player.SetRunSpeed. No idea if this will majorly screw up the server, but I'm going to put it at the bottom of fun.lua and try it anyways.

Code: [Select]
------------------------------ Speed ------------------------------
function ulx.runspeed( calling_ply, target_plys, amount )
        for i=1, #target_plys do
                target_plys[ i ]:SetRunSpeed( amount )
        end
        ulx.fancyLogAdmin( calling_ply, "#A set the running speed for #T to #i", target_plys, amount )
end
local runspeed = ulx.command( CATEGORY_NAME, "ulx runspeed", ulx.runspeed, "!runspeed" )
runspeed:addParam{ type=ULib.cmds.PlayersArg }
runspeed:addParam{ type=ULib.cmds.NumArg, min=250, max=2000, hint="runspeed", ULib.cmds.round }
runspeed:defaultAccess( ULib.ACCESS_ADMIN )
run speed:help( "Sets the running speed for target(s)." )

Thanks,

roastchicken
« Last Edit: July 10, 2014, 07:51:59 AM by roastchicken »
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Fanney

  • Newbie
  • *
  • Posts: 44
  • Karma: 11
Re: Player.SetRunSpeed
« Reply #1 on: July 10, 2014, 07:37:40 AM »
Well, i just dig so far i needed too their git repo may help you too (https://github.com/Nayruden/Ulysses/blob/master/ulx/lua/ulx/xgui) there you seem how some things work.
But i didnt saw any XGUI Documentation, is there any ?

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Player.SetRunSpeed
« Reply #2 on: July 10, 2014, 10:44:06 AM »
Sorry, but I haven't gotten around to making docs for XGUI- It's been on my todo list forever, but finding the free time is very hard :P

I google crap until I figure it out, and the server owner acts like I'm a god because he has no idea how to internet, let alone anything to do with technical stuff.
Haha, I found this really funny ;D

XGUI does in fact have a menu of setting extra players via ULX's "uteams" module, as seen in this somewhat dated screenshot. You can access this by clicking the "Manage Teams" button on the groups tab. HOWEVER, UTeams only works on Sandbox, as it handles assigning teams and stuff that easily conflicts with non-sandbox gamemodes.

So, if you're not running sandbox, you will need to work your own solution. The magic happens in /ulx/lua/ulx/modules/uteam.lua, lines 32-37. Essentially, we store strings (see the list in the above screenshot" that match with a Player:Set<blah>, which you can find a full list on Garry's Mod wiki. So, going off of the screenshot, we have:
deaths = Player:SetDeaths
gravity = Player:SetGravity  (which has appeared to have been removed. uh-oh lol)
maxSpeed = Player:SetMaxSpeed
.. and so on.

The code creates a reference to the needed function via the variable "candidate_function", and then calls that function with the value that's assigned to it, which is all stored in the "team_data" table.

However, you'll probably want to just make a simpler approach that only uses the functions needed, and I'm sure members on our forums would be willing to help you out with any technical questions. :)

FYI, the graphical XGUI code for this can mostly be found here, although, I don't blame you if you don't feel like browsing through it. :P  *shudder* old code.
« Last Edit: July 10, 2014, 10:45:43 AM by Stickly Man! »
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Player.SetRunSpeed
« Reply #3 on: July 10, 2014, 05:35:50 PM »
Well Stickly, thanks for the heads up! I am running deathrun, so that stuff won't work, but my hacked together solutions works fine!
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline [WLG]TomAndTimmy

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Player.SetRunSpeed
« Reply #4 on: January 01, 2016, 12:56:41 PM »
I am new to how things work on the website where do I paste this?

Offline WispySkies

  • Full Member
  • ***
  • Posts: 144
  • Karma: 0
  • I make random commands and Lua errors.
Re: Player.SetRunSpeed
« Reply #5 on: January 02, 2016, 10:24:54 AM »
Hey guys,

I am the "developer" for a new server. You can't really call me a developer. I google crap until I figure it out, and the server owner acts like I'm a god because he has no idea how to internet, let alone anything to do with technical stuff.
Hey! That's like me!

I made something like this a while back, when I get time I'll put the code in an edit.