[QUOTE=kaliii;52138406]why does my function to detect even numbers lag? :frown:
[url]https://pastebin.com/6VM92i4H[/url][/QUOTE]
You forgot to make it local obviously
[CODE]
local function isEven(num)
return num % 2 == 0
end
[/CODE]
What would be the easiest way to "ragdollify" a player? (i.e. make them disappear and spawn a ragdoll with their playermodel at the exact location and with the same bone locations and angles)
[QUOTE=Fillipuster;52139658]What would be the easiest way to "ragdollify" a player? (i.e. make them disappear and spawn a ragdoll with their playermodel at the exact location and with the same bone locations and angles)[/QUOTE]
Check [CW code]([url]https://github.com/CloudSixteen/Clockwork/blob/b37e43e1aa7718d02f3a68070e00850432030e32/Clockwork/garrysmod/gamemodes/clockwork/framework/libraries/sh_player.lua#L3315[/url]), it apply player's velocity to the ragdoll
[QUOTE=Fillipuster;52139658]What would be the easiest way to "ragdollify" a player? (i.e. make them disappear and spawn a ragdoll with their playermodel at the exact location and with the same bone locations and angles)[/QUOTE]
I'm guessing that [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/CreateRagdoll]Player:CreateRagdoll[/url] is a great starting point.
Why can't I use SetColor on a dmodel entity? I can only use SetSkin.
EDIT: Yay 900 posts
[QUOTE=SkitZz;52135386]How do i center text around a certain point?
As you can see here, some of the text on my scoreboard is not centered to the label above it. If i change the length of the text underneath the label, it's no longer centered:
[IMG]https://puu.sh/vsl0j/5e3ec56bc0.png[/IMG]
Here i changed the name of the "Gang", now the text is no longer centered:
[IMG]https://puu.sh/vslcC/f4ce8e0f8c.png[/IMG]
How do i go about fixing that?[/QUOTE]
[url]https://wiki.garrysmod.com/page/surface/GetTextSize[/url]
Use the surface.GetTextSize function and set your position according to that.
[QUOTE=bilbasio;52141569]Why can't I use SetColor on a dmodel entity? I can only use SetSkin.
EDIT: Yay 900 posts[/QUOTE]
I believe you may have to do that in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DModelPanel/LayoutEntity]DModelPanel:LayoutEntity[/url]
[lua]
function modelPanel:LayoutEntity( ent )
ent:SetColor( Color( 255, 0, 0, 255 ) )
end[/lua]
However for Playermodels you should use SetPlayerColor so you don't ignore the masks
[QUOTE=kpjVideo;52141698]I believe you may have to do that in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DModelPanel/LayoutEntity]DModelPanel:LayoutEntity[/url]
[lua]
function modelPanel:LayoutEntity( ent )
ent:SetColor( Color( 255, 0, 0, 255 ) )
end[/lua]
However for Playermodels you should use SetPlayerColor so you don't ignore the masks[/QUOTE]
Thank you I'm going to try this. Pretty strange that you can use SetSkin but not SetColor. I don't know how I'm going to make this work since I wanted it in a think hook.
[editline]23rd April 2017[/editline]
Bonus question, is there a OnValueChanged equivalent for [url=http://wiki.garrysmod.com/page/Category:DColorMixer]DColorMixer[/url] ?
[editline]23rd April 2017[/editline]
Just tried without success so I guess you just can't change the color of a dmodel ent.
Apparently the DModelPanel itself has a [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/DModelPanel/SetColor"]SetColor[/URL] function. Have you tried that?
[QUOTE=bilbasio;52141715]
Bonus question, is there a OnValueChanged equivalent for [url=http://wiki.garrysmod.com/page/Category:DColorMixer]DColorMixer[/url] ?
[/QUOTE]
There appears to be a `ValueChanged`, so
[code]
function mixer:ValueChanged(color)
end
[/code]
[QUOTE=zoox;52141753]Apparently the DModelPanel itself has a [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/DModelPanel/SetColor"]SetColor[/URL] function. Have you tried that?[/QUOTE]
Yes unfortunately it just made the dmodel entity disappear .
Try this:
[CODE]
modelpanel.Entity:SetColor( whatever color )
[/CODE]
[QUOTE=MPan1;52141830]Try this:
[CODE]
modelpanel.Entity:SetColor( whatever color )
[/CODE][/QUOTE]
I tried with modelpanel.Entity and modelpanel:GetEntity() but both didn't work. Also tried on multiple models to make sure and nothing worked.
I just tried the example from the DModelPanel:SetColor page and it seems to work fine for me. Maybe post parts of your code?
Here's my [url=https://pastebin.com/i9Htmt7F]code[/url].
I'm using a LW car as model. Strangely enough :SetSkin works but not :SetColor.
[QUOTE=bilbasio;52142822]Here's my [URL="https://pastebin.com/i9Htmt7F"]code[/URL].
I'm using a LW car as model. Strangely enough :SetSkin works but not :SetColor.[/QUOTE]
Replace
[CODE]self.dmodel.Entity:SetColor(self.choosecolor:GetColor())[/CODE]
with
[CODE]self.dmodel:SetColor(self.choosecolor:GetColor())[/CODE]
[URL="https://gist.github.com/zooxy/8fd3f5c46049869278fff976ec416ec8"]full [/URL][URL="https://gist.github.com/zooxy/8fd3f5c46049869278fff976ec416ec8"]code[/URL][URL="https://gist.github.com/zooxy/8fd3f5c46049869278fff976ec416ec8"] I used for testing[/URL]
Whats the best hook to re-map player controls? I'm trying to make a side scroller and am trying to set up controls like D = Move forward, A = Move Backwards, W = Jump, S = Crouch. Player aim angles are based on your mouse (x,y) so you look relative towards where your mouse is on screen.
I've tried the [URL="https://wiki.garrysmod.com/page/GM/StartCommand"]GM:StartCommand[/URL] hook but there is limited documentation and I can't seem to get anything to work.
[QUOTE=RenTec;52143574]Whats the best hook to re-map player controls? I'm trying to make a side scroller and am trying to set up controls like D = Move forward, A = Move Backwards, W = Jump, S = Crouch. Player aim angles are based on your mouse (x,y) so you look relative towards where your mouse is on screen.
I've tried the [URL="https://wiki.garrysmod.com/page/GM/StartCommand"]GM:StartCommand[/URL] hook but there is limited documentation and I can't seem to get anything to work.[/QUOTE]
Modify the sent IN enums with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CUserCmd/SetButtons]CUserCmd:SetButtons[/url] in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/CreateMove]GM:CreateMove[/url]
I have an issue.
I am using calcview to create a thirperson view. While in thirdperson, I want to have the playermodel angles to be static, so that the angles of the playermodel stays in a direction. While having the angle locked I still want to be able to turn the angles in calcview (thirdperson) using the angle argument.
Does anybody have a solution for this problem or any idea? I have been experimenting with the :Lock and :Freeze method, but it disables game input. Updating the angles to one direction didn't help neither.
[QUOTE=zoox;52143416]Replace
[CODE]self.dmodel.Entity:SetColor(self.choosecolor:GetColor())[/CODE]
with
[CODE]self.dmodel:SetColor(self.choosecolor:GetColor())[/CODE]
[URL="https://gist.github.com/zooxy/8fd3f5c46049869278fff976ec416ec8"]full [/URL][URL="https://gist.github.com/zooxy/8fd3f5c46049869278fff976ec416ec8"]code[/URL][URL="https://gist.github.com/zooxy/8fd3f5c46049869278fff976ec416ec8"] I used for testing[/URL][/QUOTE]
Thank you that worked, oddly enough the first time I tried SetColor directly on the dmodel the entity disappeared but it seems to work now.
[QUOTE=victi;52144069]I have an issue.
I am using calcview to create a thirperson view. While in thirdperson, I want to have the playermodel angles to be static, so that the angles of the playermodel stays in a direction. While having the angle locked I still want to be able to turn the angles in calcview (thirdperson) using the angle argument.
Does anybody have a solution for this problem or any idea? I have been experimenting with the :Lock and :Freeze method, but it disables game input. Updating the angles to one direction didn't help neither.[/QUOTE]
Store the angle upon entering the concommand with a callback, and always use that static angle in the calcview return struct
[QUOTE=RenTec;52143574]Whats the best hook to re-map player controls? I'm trying to make a side scroller and am trying to set up controls like D = Move forward, A = Move Backwards, W = Jump, S = Crouch. Player aim angles are based on your mouse (x,y) so you look relative towards where your mouse is on screen.
I've tried the [URL="https://wiki.garrysmod.com/page/GM/StartCommand"]GM:StartCommand[/URL] hook but there is limited documentation and I can't seem to get anything to work.[/QUOTE]
use startcommand. use a Vector(cmd:GetForwardMove(), cmd:GetSideMove()) then rotate it as much as you want, then SetForwardMove(x) and SetSideMove(y)
[QUOTE=victi;52144069]I have an issue.
I am using calcview to create a thirperson view. While in thirdperson, I want to have the playermodel angles to be static, so that the angles of the playermodel stays in a direction. While having the angle locked I still want to be able to turn the angles in calcview (thirdperson) using the angle argument.
Does anybody have a solution for this problem or any idea? I have been experimenting with the :Lock and :Freeze method, but it disables game input. Updating the angles to one direction didn't help neither.[/QUOTE]
In [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/CreateMove]GM:CreateMove[/url], you can read the input (I think GetViewAngles), change the calcview angle according to that, then set the command's angle to the original one so it doesn't rotate the real player.
Hey everyone, thank you for your time if you decide to help me out, I appreciate it a lot.
My issue is that I'm having trouble with a TTT server, more specifically the spykr donation weapons addon. [url]https://www.gmodstore.com/scripts/view/378/weapon-selection-menu-for-ttt[/url]
Basically, I'm trying to make it so that default users ( Users / Members ) have no option to spawn with a secondary, as they currently do.
Here is the part of the lua that I believe controls this.
[url]https://pastebin.com/Z6vY0N5z[/url]
So basically, the only solution that I thought would work was adding this
[CODE]
function CanPlayerSpawnWith(ply)
if not ply:IsValid() then return end
if ply:GetDonationAmount()>=10 then
return true
elseif ( ply:IsAdmin() )then
return true
elseif ( ply:IsUser() )then
return false
elseif ( ply:IsMember() )then
return false
else
return false
end
end
[/CODE]
What i've added is the ply:IsUser and ply:IsMember then return false, but I've been told Garrys mod classes people differently, so I'm curious how I set this.
I'm not very experienced with lua, so I'm sorry if it seems dumb.
Thank you
EDIT: I've fixed it, thanks everyone for helping :)
[QUOTE=Caaiin;52147593]Hey everyone, thank you for your time if you decide to help me out, I appreciate it a lot.
My issue is that I'm having trouble with a TTT server, more specifically the spykr donation weapons addon. [url]https://www.gmodstore.com/scripts/view/378/weapon-selection-menu-for-ttt[/url]
Basically, I'm trying to make it so that default users ( Users / Members ) have no option to spawn with a secondary, as they currently do.
Here is the part of the lua that I believe controls this.
[url]https://pastebin.com/Z6vY0N5z[/url]
So basically, the only solution that I thought would work was adding this
[CODE]
function CanPlayerSpawnWith(ply)
if not ply:IsValid() then return end
if ply:GetDonationAmount()>=10 then
return true
elseif ( ply:IsAdmin() )then
return true
elseif ( ply:IsUser() )then
return false
elseif ( ply:IsMember() )then
return false
else
return false
end
end
[/CODE]
What i've added is the ply:IsUser and ply:IsMember then return false, but I've been told Garrys mod classes people differently, so I'm curious how I set this.
I'm not very experienced with lua, so I'm sorry if it seems dumb.
Thank you[/QUOTE]
Did you define IsUser and IsMember? If not, use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/IsUserGroup]Player:IsUserGroup[/url] instead (Or CheckGroup if you're using ULX)
[QUOTE=JasonMan34;52147683]Did you define IsUser and IsMember? If not, use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/IsUserGroup]Player:IsUserGroup[/url] instead (Or CheckGroup if you're using ULX)[/QUOTE]
I haven't defined it... frankly I don't know how.
If I were to use Player:IsUserGroup would this work?
And are default users or 'new' users classed us UserGroup( "User" ) ?
[CODE]
function CanPlayerSpawnWith(ply)
if not ply:IsValid() then return end
if ply:GetDonationAmount()>=10 then
return true
elseif ( ply:IsAdmin() )then
return true
elseif ( ply:IsUserGroup( "User" ) )then
return false
elseif ( ply:IsUserGroup( "Member" ) )then
return false
else
return false
end
end
[/CODE]
Thanks for your help, slowly i'm learning how lua works.
EDIT: Using the above code didn't fix it, thank you though.
I'm guessing I need to define usergroups? If so... how?
E2: I added Member and User to users.txt and I'll see if it works.
Didn't work. Kill me
So let us see.
How you do define "User" and "Member"?
Are you using an Admin Mod like ULX, Exsto, ASSMod, Anus or fAdmin?
[lua]
function CanPlayerSpawnWith(ply)
if not ply:IsValid() then return end
if ply:GetDonationAmount()>=10 then
return true
elseif ( ply:IsAdmin() )then
return true
elseif ( ply:IsUserGroup( "User" ) )then
return false -- It's an unneeded check, since if they arent anything above, it will default to false (since its the else)
elseif ( ply:IsUserGroup( "Member" ) )then
return false -- see above.
else
return false
end
end[/lua]
ULX for instance is using [URL="http://ulyssesmod.net/docs/files/lua/ulib/shared/sh_ucl-lua.html#Player:GetUserGroup"]ply:GetUserGroup("groupname")[/URL] Also they are overwriting IsAdmin and IsSuperAdmin to work with their Admin Mod instead.
If you aren't using an Admin Mod and you want to define the Member Group, you should look into [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetUserGroup]Player:SetUserGroup[/url]
[QUOTE=Caaiin;52147593]Hey everyone, thank you for your time if you decide to help me out, I appreciate it a lot.
My issue is that I'm having trouble with a TTT server, more specifically the spykr donation weapons addon. [url]https://www.gmodstore.com/scripts/view/378/weapon-selection-menu-for-ttt[/url]
Basically, I'm trying to make it so that default users ( Users / Members ) have no option to spawn with a secondary, as they currently do.
Here is the part of the lua that I believe controls this.
[url]https://pastebin.com/Z6vY0N5z[/url]
So basically, the only solution that I thought would work was adding this
[CODE]
function CanPlayerSpawnWith(ply)
if not ply:IsValid() then return end
if ply:GetDonationAmount()>=10 then
return true
elseif ( ply:IsAdmin() )then
return true
elseif ( ply:IsUser() )then
return false
elseif ( ply:IsMember() )then
return false
else
return false
end
end
[/CODE]
What i've added is the ply:IsUser and ply:IsMember then return false, but I've been told Garrys mod classes people differently, so I'm curious how I set this.
I'm not very experienced with lua, so I'm sorry if it seems dumb.
Thank you[/QUOTE]
This should work
[CODE]function CanPlayerSpawnWith(ply)
if not ply:IsValid() then return end
if ply:GetDonationAmount() >= 10 or ply:IsAdmin() then
return true
else
return false
end
end[/CODE]
[QUOTE=NeatNit;52147304]In [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/CreateMove]GM:CreateMove[/url], you can read the input (I think GetViewAngles), change the calcview angle according to that, then set the command's angle to the original one so it doesn't rotate the real player.[/QUOTE]
[QUOTE=code_gs;52144527]Store the angle upon entering the concommand with a callback, and always use that static angle in the calcview return struct[/QUOTE]
Thank to both of you. The connection between the calcview and createmove has done the job for me. The tips helped alot too.
This may be stupid, but what's the situation on custom shaders? I have an already compiled shader, but am unsure if Garry's Mod will register it.
Sorry, you need to Log In to post a reply to this thread.