• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
If you only want it to send to one client, then use net.Send( ply ).. Why broadcast to everyone if you only want one person to see it? LocalPlayer( ):EntIndex( ) == net.ReadInt( 24 ) ( player EntIndex will be anywhere from 1 to game.MaxPlayers( ) up to the limit of 128 )
I'm not entirely sure that you understand what I meant, but I solved the problem myself. Thankyou for your help :)
[QUOTE=coolcat99;45510836]I'm not entirely sure that you understand what I meant, but I solved the problem myself. Thankyou for your help :)[/QUOTE] Yeah, I am a bit confused by the wording. What exactly were you trying to accomplish, and how did you resolve it ( for the next person that may have a similar question )?
Another question, where do files from server download to? And Acecool, my solution is too long and pretty badly made to post here.
Here's my code for a VIP printer, but when the customCheck line is added, it creates lua errors. I just don't know what I'm doing wrong :S [CODE]AddEntity("A-Grade Money Printer", { ent = "money_printer_platinum", model = "models/props_c17/consolebox01a.mdl", price = 3000, max = 2, cmd = "/buyamoneyprinter" customCheck = function(ply) return CLIENT or ply:IsUserGroup("vip") or ply:IsUserGroup("mod") or ply:IsAdmin() or ply:IsSuperAdmin() end, CustomCheckFailMsg = "You must be a VIP to buy this!" })[/CODE] Can someone please correct me? It'd be very appreciated!
add a comma at the end of the cmd line
[QUOTE=PortalGod;45511816]add a comma at the end of the cmd line[/QUOTE] Woops, there we go lol Thank you for your help, PortalGod
[QUOTE=camer0n;45504674]Possible to alert the player clientside even if they are alt-tabbed? An actual pop-up window? Currently I'm just making the client make a beeping noise but that's only useful if you want to listen to all the ambient sounds on GM.[/QUOTE] [URL="http://wiki.garrysmod.com/page/system/FlashWindow"]system.FlashWindow()[/URL] Makes the game in the taskbar flash for a moment, to indicate something. Only works on Windows for now. Yes I know this is a late reply but this might also help other people, I feel nobody knows about this function.
How can I make an entity spawn where my weapons' barrel attachment is rather than the centre of my head? Some effects seem to be using this "GetTracerShootPos" function which I can't find a single bit of documentation about.
When you get the muzzle-attachment, the position should be the world-position. If not, use self:LocalToWorld( AttachmentPos ) and spawn the entity there.
Is using HTML panels efficient when displaying images?
[QUOTE=Acecool;45513788]When you get the muzzle-attachment, the position should be the world-position. If not, use self:LocalToWorld( AttachmentPos ) and spawn the entity there.[/QUOTE] I was meaning as in I have no idea how to start using it. This is what I have now: [code] function SWEP:ShootUnchargedBeam() if SERVER then local tr = util.QuickTrace( self.Owner:GetShootPos(), self.Owner:GetAimVector() * 32768+Vector(math.random(-100,100)/50,math.random(-100,100)/50,math.random(-100,100)/50), self.Owner ) local worldpos1 = tr.HitPos + tr.HitNormal // Set worldpos 1. Add to the hitpos the world normal. local worldpos2 = tr.HitPos - tr.HitNormal // Set worldpos 2. Subtract from the hitpos the world normal. local random = math.random(0,80) for i=1,3 do local pos = self.Owner:GetShootPos() local ang = self.Owner:GetAimVector():Angle() local offsety = math.sin(i*2*math.pi/3) local offsetx = math.cos(i*2*math.pi/3) local offsetangle = i*120 pos = pos +ang:Forward() *1 +ang:Right() * 1 + ang:Right() * 2*offsety + ang:Up() *-5 + ang:Up() *2*offsetx local entPlasma = ents.Create("wavebeam_wavelet") entPlasma:SetAngles(ang+ Angle(0,0,offsetangle+random-40)) entPlasma:SetPos(pos) entPlasma:SetOwner(self.Owner) entPlasma:Spawn() entPlasma:Activate() entPlasma:NextThink( CurTime() + 0.01 ) local phys = entPlasma:GetPhysicsObject() if IsValid(phys) then phys:SetVelocity(ang:Forward() *1000) end end end end [/code] Should I do something like [code] function SWEP:ShootUnchargedBeam() if SERVER then local tr = util.QuickTrace( self.Owner:GetShootPos(), self.Owner:GetAimVector() * 32768+Vector(math.random(-100,100)/50,math.random(-100,100)/50,math.random(-100,100)/50), self.Owner ) local worldpos1 = tr.HitPos + tr.HitNormal // Set worldpos 1. Add to the hitpos the world normal. local worldpos2 = tr.HitPos - tr.HitNormal // Set worldpos 2. Subtract from the hitpos the world normal. local random = math.random(0,80) for i=1,3 do local pos = self.Owner:GetShootPos() local ang = self.Owner:GetAimVector():Angle() local offsety = math.sin(i*2*math.pi/3) local offsetx = math.cos(i*2*math.pi/3) local offsetangle = i*120 pos = self:GetTracerShootPos( self.Owner:GetShootPos(), self.Weapon, self.Weapon:GetAttachment(1) ) local wavelet = ents.Create("wavebeam_wavelet") wavelet:SetAngles(ang+ Angle(0,0,offsetangle+random-40)) wavelet:SetPos(pos) wavelet:SetOwner(self.Owner) wavelet:Spawn() wavelet:Activate() wavelet:NextThink( CurTime() + 0.01 ) local phys = wavelet:GetPhysicsObject() if IsValid(phys) then phys:SetVelocity(ang:Forward() *1000) end end end end [/code] ?
Whenever a player dies in my gamemode, they don't move after spawning again. They just spawn wherever they died, or where they're spectating, and half the time the viewmodels are invisible, too.
We can't do anything if you just say the problem, Window. What game mode are you running? Are you getting any errors?
[QUOTE=crazyscouter;45516734]We can't do anything if you just say the problem, Window. What game mode are you running? Are you getting any errors?[/QUOTE] Oh, sorry. It's a gamemode I'm working on. I get no error, and I assume it's in here: [code] function GM:PlayerDeathThink(pl) if ST.Values.GameState == ROUND_INGAME and pl:Team() != TEAM_SPECTATOR then pl:ScreenFade(1, Color(0,0,0), 1, 2) pl:SpectatorMode() end end function GM:PlayerDeath( victim, infl, attacker) self:PlayerSilentDeath(victim) if victim:Team() != TEAM_SPECTATOR && ST.Values.GameState == ROUND_INGAME then victim:SetTeam(TEAM_SPECTATOR) net.Start("Death") net.Send(victim) else timer.Simple(1, function() victim:UnSpectate() victim:Spawn() end) end end [/code] [editline]27th July 2014[/editline] Spectator mode works fine, too.
[QUOTE=HumbleTH;45514074]Is using HTML panels efficient when displaying images?[/QUOTE] Come to think about it, the question might not have been clear, what I meant was if it's more efficient to have a player download around 50 images and use those or upload those images somewhere on the internet and use HTML panels to display them?
How can I populate a panel with spawnicons without having to position each one separately?
[QUOTE=Garrison;45517374]How can I populate a panel with spawnicons without having to position each one separately?[/QUOTE] [url=http://wiki.garrysmod.com/page/VGUI/Elements/DIconLayout]DIconLayout[/url]
-holy shit I am late-
Hello there! First time poster. Eitherway I have a current problem with my code. Here it is: [LUA] hook.Add("!ranks", "listranks", OnPlayerChat(strText)) if ( text == "!ranks" ) then print("The system has detected the text '!ranks' and returns true. That\'s why you can see this message now") chat.AddText( Color( 255, 255, 255 ), "Welcome! You are going to see the Ranking System") chat.AddText( Color( 77, 255, 0),"Automated Ranking as it follows:") chat.AddText( Color( 0, 255, 10),"Regular", Color( 255, 255, 255)," at 7 Hours",Color( 255, 255, 255)," then,", Color( 51, 102, 0),"Extreme Regular", Color ( 255, 255, 255)," at 15 hours") chat.AddText( Color( 0, 255, 10),"Trusted", Color( 255, 178, 102)," at 29 Hours",Color( 255, 255, 255)," then,", Color( 127, 0, 255),"Veteran", Color ( 255, 255, 255)," at 56 hours") chat.AddText( Color( 76, 0, 153),"Extreme Veteran", Color( 255, 255, 255)," at 112 Hours",Color( 255, 255, 255)," then,", Color( 255, 51, 51),"Hit Man", Color ( 255, 255, 255)," at 224 hours") chat.AddText( Color( 255, 255, 0),"Time Lord", Color( 255, 255, 255)," at 448 Hours",Color( 255, 255, 255)," then,", Color( 192, 51, 0),"Bean's Elite", Color ( 255, 255, 255)," at 1337 hours") end function OnPlayerChat(strText) print("The PlayerChat Hook Has Been Called and Is Working") if ( text == "!ranks" ) then print("The system has detected the text '!ranks' and returns true. That\'s why you can see this message now") chat.AddText( Color( 255, 255, 255 ), "Welcome! You are going to see the Ranking System") chat.AddText( Color( 77, 255, 0),"Automated Ranking as it follows:") chat.AddText( Color( 0, 255, 10),"Regular", Color( 255, 255, 255)," at 7 Hours",Color( 255, 255, 255)," then,", Color( 51, 102, 0),"Extreme Regular", Color ( 255, 255, 255)," at 15 hours") chat.AddText( Color( 0, 255, 10),"Trusted", Color( 255, 178, 102)," at 29 Hours",Color( 255, 255, 255)," then,", Color( 127, 0, 255),"Veteran", Color ( 255, 255, 255)," at 56 hours") chat.AddText( Color( 76, 0, 153),"Extreme Veteran", Color( 255, 255, 255)," at 112 Hours",Color( 255, 255, 255)," then,", Color( 255, 51, 51),"Hit Man", Color ( 255, 255, 255)," at 224 hours") chat.AddText( Color( 255, 255, 0),"Time Lord", Color( 255, 255, 255)," at 448 Hours",Color( 255, 255, 255)," then,", Color( 192, 51, 0),"Bean's Elite", Color ( 255, 255, 255)," at 1337 hours") end end [/LUA] [I]I know this code works because when I go in console it prints this part of the code:[/I] [LUA] print("The PlayerChat Hook Has Been Called and Is Working") [/LUA] But then, there is this error that comes up. Images: [IMG]http://cloud-4.steampowered.com/ugc/584658202522307141/B9562352C0F3198A53B238EE840EC6393B2A3B30/[/IMG] I want to essentially make a command that displays the ranks and times for auto promotion when any player regardless of team chat, class, alive or dead types !ranks I'm like 100% sure I got the code right, but I made a typographical error somewhere. I also assume that most of my syntax is positioned incorrectly. Think of my problem in this analogy: [B][U]Example Sentence in English:[/U][/B] [I]The grumpy dog went out for a walk with grumpy cat.[/I] [B][U]My Writing of The Same Sentence in English:[/U][/B] [I]The Cat and Dog grumpy went walk out.[/I]
Ew. You need to hook the OnPlayerChat function. Redo your code so this line [code]function OnPlayerChat(strText)[/code] so it looks like [code]hook.Add("OnPlayerChat", "DetectRanks", function(ply, strText)[/code] and put a parenthesis on your last "end". And then, remove your entire first code block as it's useless.
[QUOTE=crazyscouter;45518181]Ew. You need to hook the OnPlayerChat function. Redo your code so this line [code]function OnPlayerChat(strText)[/code] so it looks like [code]hook.Add("OnPlayerChat", "DetectRanks", function(ply, strText)[/code] and put a parenthesis on your last "end". And then, remove your entire first code block as it's useless.[/QUOTE] Thanks for the help and I did just that. However there is one problem. The !ranks command doesnt work and everytime a player types anything into the chat. [LUA] print("The PlayerChat Hook Has Been Called and Is Working") [/LUA] This above gets spammed printed everytime a user types something. Only that code above runs. The rest is completly ignored including the second print function. [IMG]http://cloud-4.steampowered.com/ugc/584658202522902308/EEFAA25564FFE1268E33361107D1C1FC3ECB42D9/[/IMG] Now I am currently thinking that its defintely the wrong syntax used for if ( text == !ranks ). That if then statement isn't getting called, so the add.chat doesnt run either. However, I'm also doubting that the chat.addtext is even the correct syntax. Isn't it uiprint() ? My goal is at when any user types !rank the server chat prints back a clientside only response with the ranks at the times of promotion. Note that the ranks are colored in the chat. I'm very very very sure the syntax is off.
Change text to strText since that's what's being passed.
[QUOTE=Instant Mix;45513698]How can I make an entity spawn where my weapons' barrel attachment is rather than the centre of my head? Some effects seem to be using this "GetTracerShootPos" function which I can't find a single bit of documentation about.[/QUOTE] Hopefully this isn't too late. [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/entities/effects/base.lua"]GetTracerShootPos[/URL] is a helper function that checks if the weapon the effect is on is the local players weapon. If it is, it gets the attachment position from the players viewmodel entity. If it isn't the local players weapon, it gets the attachment position on the weapon entity's world model. To answer [quote]How can I make an entity spawn where my weapons' barrel attachment[/quote] if its for spawning an entity just use their weapon and GetAttachment
[QUOTE=crazyscouter;45518465]Change text to strText since that's what's being passed.[/QUOTE] Thanks for the help on the code, but when someone types the !ranks command, the server prints it to everyone at once. How can the code be re-written so the ranks list gets printed to client-side chat? Just tell me the code and usage and Ill work it out. You helped enough already :P
-SNIP-
I'm trying to change a job so that, upon death, he/she will be demoted. I have seen a lot of different codes about this, but they only seem to work when the player is propkilled/suicides. How do I change it so that a player kill will work as well? Thanks.
*Fixed* I recently added a prefixes script to display your rank in the chat. However, when I add this, ULX resets your rank when you leave the server. Can someone please point out what went wrong here and how to fix it? It would be very appreciated! [CODE]-- DarkRP ULX Prefixes originally created by Warlock, fixed and recoded by Tabrune and modify by men232. -- rank_str is the prefix shown before the players name, rank_col and bracket_col are colors obviously (RGB). if SERVER then AddCSLuaFile(); return; end; local stored = {}; local meta = FindMetaTable( "Player" ); local haveNiceFunc = meta.GetUserGroup != nil; local function AddPrefix( group, name, color, bracket_col ) if (group and name and color) then stored[group] = { name = name, color = color, bracket_col = bracket_col }; end; end; local function AddToChat(msg) local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local name = msg:ReadString() local ply = msg:ReadEntity() ply = IsValid(ply) and ply or LocalPlayer() if name == "" or not name then name = ply:Nick() name = name ~= "" and name or ply:SteamName() end local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local text = msg:ReadString() local rank_str, rank_col, bracket_col if (IsValid(ply) and ply:IsPlayer()) then if (!haveNiceFunc) then for group, v in pairs(stored) do if (ply:IsUserGroup(group)) then rank_str = v.name; rank_col = v.color; bracket_col = v.bracket_col or v.color; break; end; end; else local group = ply:GetUserGroup(); local v = stored[group]; if (v) then rank_str = v.name; rank_col = v.color; bracket_col = v.bracket_col or v.color; else rank_str = ""; rank_col = Color( 255, 255, 255 ); end; end; else rank_str = ""; rank_col = Color( 255, 255, 255 ); end; if text and text ~= "" then chat.AddText(bracket_col, bracket_col and " [" or "", rank_col, rank_str, bracket_col, bracket_col and "] " or "", col1, name, col2, ": "..text) if IsValid(ply) then hook.Call("OnPlayerChat", nil, ply, text, false, not ply:Alive()) end else chat.AddText(col1, name) hook.Call("ChatText", nil, "0", name, name, "none") end chat.PlaySound() end timer.Simple(1, function() usermessage.Hook("DarkRP_Chat", AddToChat); end); -- Add Prefixes (group, print name, rank color, bracket color). AddPrefix( "owner", "Owner", Color(0, 0, 232), Color(0, 0, 232) ); AddPrefix( "superadmin", "Admin", Color(25, 25, 112), Color(25, 25, 112) ); AddPrefix( "moderator", "Mod", Color(0, 101, 0), Color(0, 101, 0) ); AddPrefix( "vip", "VIP", Color(128, 128, 128), Color(255, 215, 0) ); AddPrefix( "regular", "Regular", Color(219, 169, 18), Color(219, 169, 18) ); AddPrefix( "user", "User", Color(255, 255, 255), Color(255, 255, 255) );[/CODE]
-SNIP- late :suicide:
[QUOTE='[NLG] Wrath;45520782']I'm trying to change a job so that, upon death, he/she will be demoted. I have seen a lot of different codes about this, but they only seem to work when the player is propkilled/suicides. How do I change it so that a player kill will work as well? Thanks.[/QUOTE] [code] hook.Add("PlayerDeath", "demote", function( ply ) ply:SetTeam( TEAM_CITIZEN ) end) [/code] ?
Sorry, you need to Log In to post a reply to this thread.