Author Topic: !up  (Read 132 times)

0 Members and 1 Guest are viewing this topic.

Offline sir snifflebutt

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
!up
« on: April 21, 2017, 01:25:40 AM »
so i would like if anyone could help me with making a !up command for those who play darkrp and you get weed pots and you drop it on its side and you know its a pain to make it face up i would like a command when you look at the entite and you do !up makes it face up.

Online MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2490
  • Karma: 382
    • View Profile
    • |G4P| Gman4President
Re: !up
« Reply #1 on: April 21, 2017, 09:50:17 AM »
That sounds like fun.. give me a few minutes and I'll see what I can do for you.

Online MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2490
  • Karma: 382
    • View Profile
    • |G4P| Gman4President
Re: !up
« Reply #2 on: April 21, 2017, 10:10:43 AM »
Code: Lua
  1. local CATEGORY_NAME = "Custom Commands"
  2.  
  3. ------------------------------ Up ------------------------------
  4. function ulx.up( calling_ply )
  5.    local ent = calling_ply:GetEyeTrace().Entity
  6.    if not IsValid( ent ) then return end
  7.    local y = ent:GetAngles().y
  8.    local pos = ent:GetPos()
  9.    ent:SetAngles( Angle(0, y, 0) )
  10.    ent:PhysWake()
  11. end
  12.  
  13. local up = ulx.command( CATEGORY_NAME, "ulx up", ulx.up, "!up" )
  14. up:defaultAccess( ULib.ACCESS_ADMIN )
  15. up:help( "Sets the looked at entity upright." )
  16.  

Here is a short video of it in action!
https://gfycat.com/WindingObedientAnhinga
« Last Edit: April 21, 2017, 07:51:39 PM by MrPresident »

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 711
  • Karma: 110
  • :)
    • View Profile
    • My Homepage
Re: !up
« Reply #3 on: April 21, 2017, 02:05:33 PM »
-snip-

You could use Entity.PhysWake() to clean up the code a little. Does pretty much exactly what you do at the end.
bw81@ulysses-forums ~ % whoami
Homepage

I have 10 more Keybase invites! PM me for more information or to request one!
An easy intro to PGP and public-key cryptography

Online MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2490
  • Karma: 382
    • View Profile
    • |G4P| Gman4President
Re: !up
« Reply #4 on: April 21, 2017, 07:51:20 PM »
I wonder if this function is new(ish) because I've only ever done it the other way.
Thanks for the info.