ULX

Author Topic: Does this code conflict with ULX?  (Read 2443 times)

0 Members and 1 Guest are viewing this topic.

Offline BrandonR

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Does this code conflict with ULX?
« on: May 25, 2007, 06:13:23 PM »
I was over at Facepunch asking for a script to only allow admins to noclip but let everyone else fly, and someone posted this code: http://xanthite.com/scripts/Scripts/Server%20Side/fly.lua
Code: [Select]
// ##################################################
// Fly Mode
// By RabidToaster
// ##################################################

// #########################
// Settings!
// #########################
local Speed = 60 // Speed of flight.

// #########################
// Don't change down here!
// #########################

// Called when the player tries to noclip.
local function PlayerNoClip( pPlayer )
// If the player isn't an admin...
if ( !pPlayer:IsAdmin() ) then
// Make sure the variable is there to be toggled, and toggle it.
pPlayer.Flying = pPlayer.Flying or false
pPlayer.Flying = not pPlayer.Flying

// If they're flying, set their gravity very low to stop them sinking down, otherwise put normal.
local iGravity = 1
if ( pPlayer.Flying ) then iGravity = 0.00001 end
pPlayer:SetGravity( iGravity )

// Stop them from noclipping.
return false
end
end
hook.Add( "PlayerNoClip", "Fly.PlayerNoClip", PlayerNoClip )

// Called before the engine processes movements.
local function SetupMove( pPlayer, mdData )
// If the player is flying...
if ( pPlayer.Flying ) then
// Get their velocity, and slow them a little, and get their aim vector.
local vlPlayer = mdData:GetVelocity() * 0.9
local aPlayer = pPlayer:GetAimVector():Angle()

// Add appropriate velocity for key presses.
if ( pPlayer:KeyDown( IN_FORWARD ) ) then
vlPlayer = vlPlayer + ( aPlayer:Forward() * Speed )
elseif ( pPlayer:KeyDown( IN_BACK ) ) then
vlPlayer = vlPlayer + ( aPlayer:Forward() * -Speed )
end

if ( pPlayer:KeyDown( IN_MOVERIGHT ) ) then
vlPlayer = vlPlayer + ( aPlayer:Right() * Speed )
elseif ( pPlayer:KeyDown( IN_MOVELEFT ) ) then
vlPlayer = vlPlayer + ( aPlayer:Right() * -Speed )
end

// Set their new velocity.
mdData:SetVelocity( vlPlayer )
end
end
hook.Add( "SetupMove", "Fly.SetupMove", SetupMove )

Now I noticed earlier in the Facepunch thread, Megiddo said code that interacts with PlayerNoClip may conflict with scripts like ULX. Anywho I installed this code and it works fine for admins but for other users it doesn't do anything. Is this a problem with that script/code or is it conflicting with ULX somehow? If the latter, any idea how to get it to un-conflict? Thanks so much. :)

Offline BrandonR

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Does this code conflict with ULX?
« Reply #1 on: May 28, 2007, 05:10:27 PM »
Okay well I confirmed that the code works independently without Ulx, so I guess my next question is how to best integrate this code with Ulx...? Perhaps as an additional module? I assume Ulx does some stuff to Noclip to prevent noclipping out of jail and whatnot. Help?  ;D

Offline BrandonR

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Does this code conflict with ULX?
« Reply #2 on: May 30, 2007, 08:09:25 PM »
Help? Anyone? Have I stumped the ULX gods?!  :-\

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Does this code conflict with ULX?
« Reply #3 on: May 30, 2007, 08:17:19 PM »
Any errors in console?
Experiencing God's grace one day at a time.