• Print

Author Topic: Server-side binding and velocity  (Read 7280 times)

0 Members and 1 Guest are viewing this topic.

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Server-side binding and velocity
« on: August 06, 2014, 07:20:56 pm »
There's two things I want to do and can't quite figure out

Firstly, I want to make it so whenever a player hits the F2 button, they'll run the console command "ulx thirdperson"

Here's the code I got on my own. Th problem is, there was only a few things I could put in that part where it says "IN_ALT1", and none of them were F2, according to the list I was looking at. So how would I do this?
Code: Lua
  1. function KeyPress( ply, key )
  2.     if ( key == IN_ALT1 ) then
  3.        ply:RunConsoleCommand( "ulx", "thirdperson" )
  4.     end
  5. end

Secondly, it became a problem on my DeathRun server where people could prespeed their way past traps and the deaths would never be able to catch up to them, so how would I set a max velocity? I wasn't able to figure this out on my own.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Server-side binding and velocity
« Reply #1 on: August 06, 2014, 08:18:06 pm »

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Server-side binding and velocity
« Reply #2 on: August 06, 2014, 09:23:24 pm »
Alright, so here's what I ended up with after using that hook
Code: Lua
  1. function ThirdpersonToggle( ply )
  2.         ply:RunConsoleCommand( "ulx", "thirdperson" )
  3. end
  4. hook.Add( "ShowTeam", "ToggleTP", ThirdpersonToggle )

That didn't work in lua/autorun/server (the page you showed me said it was serverside code)

What's wrong? Here's the error I got when running it

Code: Lua
  1. [ERROR] lua/autorun/server/mybinds.lua:2: attempt to call method 'RunConsoleCommand' (a nil value)
  2. 1. fn - lua/autorun/server/mybinds.lua:2
  3. 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183

and when I changed RunConsoleCommand to ConCommand (which is what the page you sent me used), nothing happened at all. There we no errors and no outcome

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Server-side binding and velocity
« Reply #3 on: August 06, 2014, 10:27:09 pm »
It's ply:ConCommand
http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8d04.html

ply:RunConsoleCommand isn't a thing.


With ConCommand you don't break the command into multiple arguements. It's a single string. so...
ply:ConCommand("ulx thirdperson")
« Last Edit: August 06, 2014, 10:28:46 pm by MrPresident »

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Server-side binding and velocity
« Reply #4 on: August 06, 2014, 10:52:36 pm »
Thanks, the bind works now
I still have two questions, though :P

When would RunConsoleCommand be used? http://wiki.garrysmod.com/page/Global/RunConsoleCommand

Secondly, what would I do about the max velocity?

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Server-side binding and velocity
« Reply #5 on: August 06, 2014, 11:29:54 pm »
Thanks, the bind works now
I still have two questions, though :P

When would RunConsoleCommand be used? http://wiki.garrysmod.com/page/Global/RunConsoleCommand

Secondly, what would I do about the max velocity?

RunConsoleCommand is used serverside.
Out of the Garry's Mod business.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Server-side binding and velocity
« Reply #6 on: August 07, 2014, 05:52:39 am »
Not sure if this still works, but:
Code: [Select]
physenv.SetPerformanceSettings( {
MaxVelocity = x
} )

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Server-side binding and velocity
« Reply #7 on: August 07, 2014, 10:33:45 am »
Thanks Neku

As for Cobalt, I tried that yesterday and it had absolutely no effect ingame. Thanks anyway

Any other ideas? :P
« Last Edit: August 07, 2014, 10:38:54 am by Zmaster »

Offline Dog

  • Newbie
  • *
  • Posts: 17
  • Karma: 1
Re: Server-side binding and velocity
« Reply #8 on: September 21, 2014, 09:15:11 pm »
This is the function called in Trouble in Terrorist Town(Idk if it'll help, was just an idea.)
Code: Lua
  1. function plymeta:SetSpeed(slowed)
  2.    local mul = hook.Call("TTTPlayerSpeed", GAMEMODE, self, slowed) or 1
  3.    if slowed then
  4.       self:SetWalkSpeed(120 * mul)
  5.       self:SetRunSpeed(120 * mul)
  6.       self:SetMaxSpeed(120 * mul)
  7.    else
  8.       self:SetWalkSpeed(225 * mul)
  9.       self:SetRunSpeed(350 * mul)
  10.       self:SetMaxSpeed(350 * mul)
  11.    end
  12. end

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Server-side binding and velocity
« Reply #9 on: September 22, 2014, 07:35:12 pm »
Thanks, Dog
I don't need this anymore but that could be useful for anyone who does need it :P

  • Print