Facepunch / garrysmod-requests

Feature requests for Garry's Mod
83 stars 24 forks source link

CUserCmd:IsWorldClicking() and CUserCmd:GetWorldClickingAngles() #2396

Closed wrefgtzweve closed 3 weeks ago

wrefgtzweve commented 1 month ago

Details

Currently Player:IsWorldClicking() exists but it requires getting the player entity and you wont be able to get the angle. Having a direct way of getting these from usercmds would allow for some simpler checks/logic for those who use Player:IsWorldClicking. It's internally already stored inside the usercmd so it should be rather easy to implement.

For reference, i know this issue exists https://github.com/Facepunch/garrysmod-requests/issues/2111 but the issue regarding not being able to get the angle wasn't answer so i figured i'd open an issue for it alongside a direct usercmd implementation.

Player:IsWorldClicking() also seems to be inconsistent compared to getting it directly from the usercmd Example:

hook.Add( "CreateMove", "test", function( cmd )
    if cmd:CommandNumber() == 0 then return end
    print( "CreateMove", cmd:TickCount(), LocalPlayer():IsWorldClicking(), cmd:GetWorldClicking() )
end )

cmd:GetWorldClicking() is a feature added by a DLL, as you can see it somehow returns true despite it not being set at that moment. image

robotboy655 commented 4 weeks ago

At what point do you not have access to a player object, but have access to CUserCmd?

The angles are provided for you via https://wiki.facepunch.com/gmod/Player:GetAimVector

The UserCmd:GetWorldClicking var is not set during CreateMove, it will always be false. It is set just after that hook is called.