• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
Anyone know much about PAS? Trying to emit a sound on an entity that is > 2500 distance from a player, but it is quiet unless the entity emits the sound below 2500 distance from the player.
Any way to centre text inside DTextEntry? Also any way to make DTextEntry only allow numbers to be typed into it?
[QUOTE=Mrkrabz;49807589]What's the easiest way to disable certain keys? I'm aware of how to disable jumping, however I tried a similar way to disable 'W' and 'S' keys. [lua] local TeamAllow = { [TEAM_HSW] = {IN_JUMP}, [TEAM_SIDEWAYS] = {IN_FORWARD, IN_BACK}, } hook.Add( "SetupMove", "DisableKeys", function( ply, mvd, cmd ) if TeamAllow[ply:Team()] then for k,v in pairs(TeamAllow[ply:Team()]) do if mvd:KeyDown( v ) then mvd:RemoveKeys( v ) end end end end )[/lua] No errors, but only jump is being removed from players. You are still able to move back and forward.[/QUOTE] If anyone get stuck with this also, I did it a pretty crude way: [lua] hook.Add( "StartCommand", "Disable Jumping", function( ply, ucmd ) if ply:Team() == TEAM_SIDEWAYS then ucmd:SetSideMove( 0 ) elseif ply:Team() == TEAM_WONLY then if ucmd:GetForwardMove() < 0 then ucmd:SetForwardMove( 0 ) end ucmd:SetSideMove( 0 ) elseif ply:Team() == TEAM_SONLY then if ucmd:GetForwardMove() > 0 then ucmd:SetForwardMove( 0 ) end ucmd:SetSideMove( 0 ) end end ) [/lua]
[QUOTE=naTlatsyrC;49807564][lua]--some code-- hook.Add("TTTBeginRound", "PS ReEquip", function() local self = player.GetAll() timer.Simple(1, function() if !IsValid(self) then return end if self:PS_HasItemEquipped(id) then end for item_id, item in pairs(self.PS_Items) do local ITEM = PS.Items[item_id] if item.Equipped then ITEM:OnEquip(self, item.Modifiers) end end end) end)[/lua] [/QUOTE] You might want to look in your console for errors, it's a really easy way to find out what you did wrong. self is defined as player.GetAll(), which is a table. However, you try to use the metafunction that is only defined for the "Player" metatable, PS_HasItemEquipped. Instead, loop through the player.GetAll() table (If you make "self" the value you won't have to change the code much)
I have this problem where some admin groups can not pick up cars, so I tried to fix it with this scrip. [CODE] function carFix(ply, ent) if ply:IsAdmin() and ent:GetClass():lower() == "prop_vehicle_jeep" then return true end print(ply:IsAdmin()) end hook.Add("PhysgunPickup", "Only allow admins to pick up cars", carFix) [/CODE] However when I ran this it didn't seem like it triggered the PhysgunPickup when I used it on a car (ply:IsAdmin() didn't print when using the physgun on a car). Any ideas what the problem might be or ideas for a fix?
[QUOTE=JasonMan34;49809284]You might want to look in your console for errors, it's a really easy way to find out what you did wrong. self is defined as player.GetAll(), which is a table. However, you try to use the metafunction that is only defined for the "Player" metatable, PS_HasItemEquipped. Instead, loop through the player.GetAll() table (If you make "self" the value you won't have to change the code much)[/QUOTE] And he helps once again. If I knew how to give you helpful I definitely would! Your help has been indispensable aswell as great tutor work, Thank you for your time!
What function would I use to find if a workshop file is on the client? file.Find()?
[QUOTE=Endor96;49809289]I have this problem where some admin groups can not pick up cars, so I tried to fix it with this scrip. [CODE] function carFix(ply, ent) if ply:IsAdmin() and ent:GetClass():lower() == "prop_vehicle_jeep" then return true end print(ply:IsAdmin()) end hook.Add("PhysgunPickup", "Only allow admins to pick up cars", carFix) [/CODE] However when I ran this it didn't seem like it triggered the PhysgunPickup when I used it on a car (ply:IsAdmin() didn't print when using the physgun on a car). Any ideas what the problem might be or ideas for a fix?[/QUOTE] Try returning false [editline]25th February 2016[/editline] [QUOTE=Splerge;49809453]What function would I use to find if a workshop file is on the client? file.Find()?[/QUOTE] Maybe [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/steamworks/IsSubscribed]steamworks.IsSubscribed[/url]?
[QUOTE=MPan1;49809461] Maybe [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/steamworks/IsSubscribed]steamworks.IsSubscribed[/url]?[/QUOTE] That would work if the player was subscribed, but we also have to consider if they downloaded the content as they joined the server and cached it, which doesn't require subscription
[QUOTE=MPan1;49809461]Try returning false[/QUOTE] Now that's strange o.O. That worked so that it made admins unable to pick up the cars even tho it didn't print that ply:IsAdmin() was true. So I changed the code to this and tried with the group that didn't work [CODE] function carFix(ply, ent) if ply:IsAdmin() and ent:GetClass():lower() == "prop_vehicle_jeep" then return true else return false end print(ply:IsAdmin()) end hook.Add("PhysgunPickup", "Only allow admins to pick up cars", carFix) [/CODE] What happened was that the superadmin rank could lift cars and nothing else, and the group with the problem could lift nothing(not even cars). EDIT: ply:IsAdmin() returns true for the affected group Apparently the affected group can't touch anything under the Vehicles tab.
[QUOTE=Endor96;49809504]Now that's strange o.O. That worked so that it made admins unable to pick up the cars even tho it didn't print that ply:IsAdmin() was true. So I changed the code to this and tried with the group that didn't work [CODE] function carFix(ply, ent) if ply:IsAdmin() and ent:GetClass():lower() == "prop_vehicle_jeep" then return true else return false end print(ply:IsAdmin()) end hook.Add("PhysgunPickup", "Only allow admins to pick up cars", carFix) [/CODE] What happened was that the superadmin rank could lift cars and nothing else, and the group with the problem could lift nothing(not even cars).[/QUOTE] It didn't print anything because when you return within a function the function is done, it doesn't continue down the function code because the function did what it was meant to do and returned. Also I wouldn't do the else statement and returning false because then it'd break any other hooks that rely on it to be called.
[QUOTE=bigdogmat;49809552]It didn't print anything because when you return within a function the function is done, it doesn't continue down the function code because the function did what it was meant to do and returned. Also I wouldn't do the else statement and returning false because then it'd break any other hooks that rely on it to be called.[/QUOTE] Oh fak, that's right -.- ... And I did the return false for testing. Also see EDIT EDIT: NVM... I solved it, apparently a cardealer script I had disabled it.
[QUOTE=Splerge;49809487]That would work if the player was subscribed, but we also have to consider if they downloaded the content as they joined the server and cached it, which doesn't require subscription[/QUOTE] Perhaps you could check if a certain global variable exists, or a hook if the other mod doesn't have any global variable.
[QUOTE=DarthTealc;49809918]I'm trying to code a Nextbot that will only chase you if you can't see it. I'm using [url]http://wiki.garrysmod.com/page/Entity/Visible[/url] but it doesn't work the way I'd expect it. I'm using self:Visible(self:GetEnemy()) self is the nextbot, GetEnemy returns the player. The way I'd expect this to work is that it'd return true (and I'd prevent it from chasing) if any part of the entity's model is visible on my screen. How it seems to work is it returns true if the npc's origin and player's origin are within the same area (possibly visleaf?). This means it's moving at times I can see the upper part of the model, and it refuses to move at times when I've turned around or put a prop up to stop me seeing it. Is there a different function I should be using? Essentially I just want to be able to detect if the model is visible on the screen or not.[/QUOTE] Try [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/IsLineOfSightClear]Entity:IsLineOfSightClear[/url]. [B]Edit:[/B] You can also try to create your own function. Something like this: WARNING UNTESTED! [lua] function ENT:InFieldOfView( pos ) local fov = math.rad( math.cos( 110 ) ) local v = ( Vector( pos.x, pos.y, 0 ) - Vector( self:GetPos().x, self:GetPos().y, 0 ) ):GetNormalized() if self:GetAimVector():Dot( v ) > fov then return true end return false end [/lua]
Is Entity:SetModel() networked? If I apply a new model this way to an entity on server-side, it does change what the model looks like, but the physics of the entity stay the same (if it was a small model originally and you set it to a large model you can now clip/walk inside it). Any idea how to update the physics too, or why this is happening?
[QUOTE=101kl;49810976]Is Entity:SetModel() networked? If I apply a new model this way to an entity on server-side, it does change what the model looks like, but the physics of the entity stay the same (if it was a small model originally and you set it to a large model you can now clip/walk inside it). Any idea how to update the physics too, or why this is happening?[/QUOTE] I'm pretty sure you can update the physics at the same time as updating the model. Either that or I'm a dumbass.
[QUOTE=Tupac;49810985]I'm pretty sure you can update the physics at the same time as updating the model. Either that or I'm a dumbass.[/QUOTE] I figured as much, but I must be blind since I can't for the life of me find any information about it on the wiki.
[QUOTE=101kl;49810976]Is Entity:SetModel() networked? If I apply a new model this way to an entity on server-side, it does change what the model looks like, but the physics of the entity stay the same (if it was a small model originally and you set it to a large model you can now clip/walk inside it). Any idea how to update the physics too, or why this is happening?[/QUOTE] Try calling Spawn() on it after you set the model. if it work, DON'T USE THIS IN PRODUCTION!!!!! Because I don't remember how to destroy physic object (and you will create another one).
[QUOTE=101kl;49810976]Is Entity:SetModel() networked? If I apply a new model this way to an entity on server-side, it does change what the model looks like, but the physics of the entity stay the same (if it was a small model originally and you set it to a large model you can now clip/walk inside it). Any idea how to update the physics too, or why this is happening?[/QUOTE] You will have to network the new player hull. I do something similar here: [url]https://github.com/lolleko/guesswho/blob/master/lua/weapons/weapon_gw_prophunt.lua[/url] client side receive: [url]https://github.com/lolleko/guesswho/blob/master/gamemodes/guesswho/gamemode/cl_init.lua#L142[/url]
Anybody know of a way to rescale an entity and have its collision box scale as well? I'm trying to shrink the phx gumball to use as a golf ball. (models/XQM/Rails/gumball_1.mdl) I've googled around and can't seem to find anything that works.
[QUOTE=Deathbypwnage;49813287]Anybody know of a way to rescale an entity and have its collision box scale as well? I'm trying to shrink the phx gumball to use as a golf ball. (models/XQM/Rails/gumball_1.mdl) I've googled around and can't seem to find anything that works.[/QUOTE] entity setsize?
[QUOTE=keeperman;49813472]entity setsize?[/QUOTE] doesnt exist
:snip: you saw nothing
[QUOTE=Endor96;49809289]I have this problem where some admin groups can not pick up cars, so I tried to fix it with this scrip. [CODE] function carFix(ply, ent) if ply:IsAdmin() and ent:GetClass():lower() == "prop_vehicle_jeep" then return true end print(ply:IsAdmin()) end hook.Add("PhysgunPickup", "Only allow admins to pick up cars", carFix) [/CODE] However when I ran this it didn't seem like it triggered the PhysgunPickup when I used it on a car (ply:IsAdmin() didn't print when using the physgun on a car). Any ideas what the problem might be or ideas for a fix?[/QUOTE] What admin addons do you have installed? ULX? Evolve? Exsto? Maestro? FAdmin? (FAdmin comes installed with DarkRP by default) You should probably try to fix the problem at the source (likely cause by an admin mod) instead of trying to override it with some of your own lua.
Can anyone tell me why some of my workshop thumbnails do this: [IMG]https://i.gyazo.com/e6dfb497808946afe05ec5f61952abfa.png[/IMG] The images are 512x512 .jpg files, but it seems random when it happens to me.
Need help on fixing this script i'm trying to make. I want to make it so players that are wanted go to jail when they are killed. I started off with this [CODE]WantedDeathMessage = "You have been arrested upon death due to your wanted status." function GM:PlayerDeath( victim, inflictor, attacker ) if victim:isWanted() then victim:Arrest() victim:PrintMessage( HUD_PRINTCENTER, ..WantedDeathMessage.. ) end end[/CODE] Then I was told to add a hook and get rid of the double dots. I was given this: [CODE]local WantedDeathMessage = "You have been arrested upon death due to your wanted status." hook.Add( 'PlayerDeath', 'ArrestDeadPlayers', function( victim, inflictor, attacker ) if victim:isWanted() then victim:Arrest() victim:PrintMessage( HUD_PRINTCENTER, WantedDeathMessage ) end end )[/CODE] I tried using it, but it ends up not working/doing nothing in my server. I have the file under garrysmod/lua/autorun. Anyone have any ideas?
Is there a way I could load raw .jpg data as an [URL="https://wiki.garrysmod.com/page/Category:IMaterial"]IMaterial[/URL] (such as the data created by [URL="https://wiki.garrysmod.com/page/render/Capture"]render.Capture[/URL]) rather than having to save it, then load it again?
[QUOTE=Deathbypwnage;49813287]Anybody know of a way to rescale an entity and have its collision box scale as well? I'm trying to shrink the phx gumball to use as a golf ball. (models/XQM/Rails/gumball_1.mdl) I've googled around and can't seem to find anything that works.[/QUOTE] Try [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetCollisionBounds]Entity:SetCollisionBounds[/url] or [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetCollisionBoundsWS]Entity:SetCollisionBoundsWS[/url] [editline]26th February 2016[/editline] [QUOTE=DarthTealc;49816361]IsLineOfSightClear acts exactly the same as Visible (at least for me), and adapting your example does work for fov-testing but the entity still thinks it is being seen when there's a prop in the way. Was hoping there would be a function that takes that into account but I can't find one. Thanks anyway.[/QUOTE] Add a traceline to the FOV check aswell, if the trace hits anything (like a prop) you know that the line of sight is blocked.
Is there any way to override a player spawn point without an Entity? I looked at [url]https://wiki.garrysmod.com/page/GM/PlayerSelectSpawn[/url] but this functions wants an entity as return and not pos/angles.
[QUOTE=P4sca1;49817620]Is there any way to override a player spawn point without an Entity? I looked at [url]https://wiki.garrysmod.com/page/GM/PlayerSelectSpawn[/url] but this functions wants an entity as return and not pos/angles.[/QUOTE] You could always just move them when they spawn, e.g. [CODE] hook.Add( 'PlayerSpawn', 'moveplayer', function( ply ) ply:SetPos( Vector( 0, 0, 0 ) ) end ) [/CODE] I think there was another way to do this though
Sorry, you need to Log In to post a reply to this thread.