maybe you could try something like this
[code]
surface.SetAlphaMultiplier( o/255 )
for i = 0, s, s/d do
surface.SetDrawColor( 0, 0, 0, 255 * (1 - i/s) ) -- this bit here, o/d is the thing I want to fix
surface.DrawRect( -i, -i, w+(i*2), h+(i*2) )
end
surface.SetAlphaMultiplier( 1 )
[/code]
[QUOTE=MysticLlama;49729575]So, this code, which runs for a Nextbot:
If my Bot has an enemy.
Even though my code works exactly like i want it to, errors be spammed.
What am i missing?[/QUOTE]
NEXTBOT:Think runs on the client now too, and i don't think GetRangeTo is a clientside function.
If I am starting a net message from a clientside menu and I wanted to write who was sending it is writing the LocalPlayer safe? Is there another way to get the player who is actually viewing the menu?
[CODE]
net.Start("Revoke")
net.WriteEntity(LocalPlayer()) // Sending the player who clicked the button
net.WriteString(user) //Sending the user he selected
net.WriteInt(3,4)
net.SendToServer()[/CODE]
[QUOTE=dence47;49730913]If I am starting a net message from a clientside menu and I wanted to write who was sending it is writing the LocalPlayer safe? Is there another way to get the player who is actually viewing the menu?
[CODE]
net.Start("Revoke")
net.WriteEntity(LocalPlayer()) // Sending the player who clicked the button
net.WriteString(user) //Sending the user he selected
net.WriteInt(3,4)
net.SendToServer()[/CODE][/QUOTE]
net.Receive serverside has a second argument passed to it, which is the player that sent the message.
[code]
local function ReceiveSomething(size,ply)
--code
end
net.Receive("SomeMessage",ReceiveSomething)
[/code]
[QUOTE=dence47;49730913]If I am starting a net message from a clientside menu and I wanted to write who was sending it is writing the LocalPlayer safe? Is there another way to get the player who is actually viewing the menu?
[CODE]
net.Start("Revoke")
net.WriteEntity(LocalPlayer()) // Sending the player who clicked the button
net.WriteString(user) //Sending the user he selected
net.WriteInt(3,4)
net.SendToServer()[/CODE][/QUOTE]
nononononono
when you receive the net message on the server you are passed the player that sent it, never network the local player
from the wiki:
[code]net.Receive( "my_message", function( len, pl )
if ( IsValid( pl ) and pl:IsPlayer() ) then
print( "Message from " .. pl:Nick() .. " received. Its length is " .. len .. "." )
else
print( "Message from server received. Its length is " .. len .. "." )
end
end )[/code]
[QUOTE=dence47;49730913]If I am starting a net message from a clientside menu and I wanted to write who was sending it is writing the LocalPlayer safe? Is there another way to get the player who is actually viewing the menu?
[CODE]
net.Start("Revoke")
net.WriteEntity(LocalPlayer()) // Sending the player who clicked the button
net.WriteString(user) //Sending the user he selected
net.WriteInt(3,4)
net.SendToServer()[/CODE][/QUOTE]
Did you read this? [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Receive]net.Receive[/url]
[editline]asdasdsa[/editline]
ninja'd again
I don't suppose it would be easy to bonemerge a ragdoll onto a player, would it?
I've never done things with bonemerging before, and from some of the things I've tried, it doesn't want to cooperate.
How could I make a DButton move away from the user's mouse so they can't easily click it? I tried some SetPos stuff in the DButton:Think hook, but I can't really think of a good way to do it
[editline]13th February 2016[/editline]
Oh yeah, and I was trying to not just make the button teleport away, but move away in a fairly smooth way
[QUOTE=MPan1;49731507]How could I make a DButton move away from the user's mouse so they can't easily click it? I tried some SetPos stuff in the DButton:Think hook, but I can't really think of a good way to do it
[editline]13th February 2016[/editline]
Oh yeah, and I was trying to not just make the button teleport away, but move away in a fairly smooth way[/QUOTE]
Best I can think of would be to get the normal vector between the 2 and then move it away in that direction until it's a certain distance away from the mouse. Add a few millisecond delay to how often it updates so it's not impossible to hit it.
Okay, I'll try that
Also: How could I make a DTextEntry's text get aligned to the right or the middle rather than the left?
I've set a variable in gamemode settings to have the default value of 100 but it reverts to the default value when I look at the settings ingame
[QUOTE=MPan1;49732028]Okay, I'll try that
Also: How could I make a DTextEntry's text get aligned to the right or the middle rather than the left?[/QUOTE]
could always override paint and draw the text manually. other than that, there's no way that i know of.
I'm trying to create a server ragdoll when an NPC dies and Keep Corpses is off (to replace the clientside one). I change its position, angle and velocity to match the NPC, but it spawns in T pose, and it doesn't get pushed by the weapon like the clientside ragdoll. Is there a way to make it look more like a real corpse? I tried duplicator.DoGeneric but it didn't work.
[QUOTE=keeperman;49732105]I've set a variable in gamemode settings to have the default value of 100 but it reverts to the default value when I look at the settings ingame[/QUOTE]
Print the variable directly from your core gamemode file.
If it prints 100, the problem is with the display of settings
[editline]august[/editline]
When making a function, a variable created within it will disappear after the function has ended.
But what happens if I define the variable as local within the function itself? Is it in any way different or ill-advised?
[QUOTE=JasonMan34;49733033]When making a function, a variable created within it will disappear after the function has ended.
But what happens if I define the variable as local within the function itself? Is it in any way different or ill-advised?[/QUOTE]
If you define a variable with out putting 'local' in front of it, it will be a global variable. As far as I know, global variables will persist out of their scope (well, really their scope is just always global). They're called global for a reason. If you define a variable as local inside a function, it will 'disappear' after the function has ended.
[QUOTE=MaxShadow;49732907]I'm trying to create a server ragdoll when an NPC dies and Keep Corpses is off (to replace the clientside one). I change its position, angle and velocity to match the NPC, but it spawns in T pose, and it doesn't get pushed by the weapon like the clientside ragdoll. Is there a way to make it look more like a real corpse? I tried duplicator.DoGeneric but it didn't work.[/QUOTE]
it sounds like the model doesn't exist on the server.
[QUOTE=skullorz;49733120]it sounds like the model doesn't exist on the server.[/QUOTE]
No, I mean that the ragdoll spawns in T pose at the NPC position. I want to know if theres a way to spawn it with the same pose as the NPC, and to push it like a normal corpse would. Basicly, I want to have the same result as having Keep Corpses on, but with Keep Corpses off. I need a serverside corpse no matter if KC is enabled or not.
[QUOTE=roastchicken;49733096]If you define a variable with out putting 'local' in front of it, it will be a global variable. As far as I know, global variables will persist out of their scope (well, really their scope is just always global). They're called global for a reason. If you define a variable as local inside a function, it will 'disappear' after the function has ended.[/QUOTE]
Actually a variable will disappear if defined inside a function (Defined - Not getting its value changed)
[QUOTE=JasonMan34;49733550]Actually a variable will disappear if defined inside a function (Defined - Not getting its value changed)[/QUOTE]
[code]function PrintX( )
print( tostring( x ) )
end
function DoSomething( )
x = 5
PrintX( )
end
PrintX( )
DoSomething( )
PrintX( )[/code]
[code]nil
5
5
[/code]
There isn't an assumed encapsulation beyond the global namespace.
In order for x to become nil again, x needs to leave scope, which it can't in the above code.
If I made x local to one of those functions, then you would be correct.
[QUOTE=skullorz;49730878]NEXTBOT:Think runs on the client now too, and i don't think GetRangeTo is a clientside function.[/QUOTE]
If i have the GetRangeTo inside the "if HaveEnemy() then" section, it works just fine.
[QUOTE=Kogitsune;49733675][code]function PrintX( )
print( tostring( x ) )
end
function DoSomething( )
x = 5
PrintX( )
end
PrintX( )
DoSomething( )
PrintX( )[/code]
[code]nil
5
5
[/code]
There isn't an assumed encapsulation beyond the global namespace.
In order for x to become nil again, x needs to leave scope, which it can't in the above code.
If I made x local to one of those functions, then you would be correct.[/QUOTE]
Oh :c
Thanks, answered my question (Also I got burned hard x.x)
[QUOTE=skullorz;49732825]could always override paint and draw the text manually. other than that, there's no way that i know of.[/QUOTE]
Well this is going to be bloody great fun isn't it Garry
[editline]13th February 2016[/editline]
Anyone know if there's a derma skinhook list somewhere with the code that actually makes the functions work, or is that built in or something?
[editline]13th February 2016[/editline]
Nevermind, [URL="https://github.com/garrynewman/garrysmod/blob/3e138636eb1b0ad6ed785dedf350020755cff5f1/garrysmod/lua/skins/default.lua"]found it[/URL]
[editline]13th February 2016[/editline]
Nope, that wasn't what I needed...
Anyone know the code that [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/DrawTextEntryText]Panel:DrawTextEntryText[/url] runs?
[QUOTE=GGG KILLER;49683309]Not really a problem but more of trying to understand some unknown behavior of net library.
Some days ago I was making a code that made use of net.WriteInt and net.ReadInt, some time later I realized that I hadn't but a bitCount parameter on net.WriteInt neither on net.ReadInt, but the script still worked perfectly.
So, does net.Read/WriteInt REQUIRES a bitCount parameter or is it an optional parameter?[/QUOTE]
Bump
-snip codens, didn't read net.WriteFloat documentation-
I know that the bitCount parameter is not needed now, but what are the pros and cons of this?
[QUOTE=GGG KILLER;49735469]Bump with a piece of code from DarkRP's Pocket SWEP:
[lua]
net.Start("DarkRP_spawnPocket")
net.WriteFloat(k)
net.SendToServer()
[/lua]
[editline]13th February 2016[/editline]
More code:
[lua]
net.Receive("DarkRP_spawnPocket", function(len, ply)
local item = net.ReadFloat()
if not ply.darkRPPocket or not ply.darkRPPocket[item] then return end
ply:dropPocketItem(item)
end)
[/lua]
I know from this it is pretty much obvious that the bitCount parameter is not needed, but what are the pros and cons of this?[/QUOTE]
It's required since the second parameter is the player.
[QUOTE=Kevlon;49735486]It's required since the second parameter is the player.[/QUOTE]
What are you talking about? (Read [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/WriteInt]net.WriteInt[/url] to know what the bitCount parameter is)
[editline]adssada[/editline]
Edited my post, I misread the code and saw writeint instead of writefloat, code snippets removed from my bump.
For some reason my env_projectedtexture (when parented to a vehicle) looks like this (fairly pixelated):
[t]http://162.243.255.203/files/dpshmj.png[/t]
And here's my code:
[code]
local fuk = ents.Create("env_projectedtexture")
fuk:SetParent(Player:GetVehicle())
fuk:SetLocalPos(Vector(0, 35, 5))
fuk:SetKeyValue("lightcolor", 255 .. " " .. 255 .. " " .. 255 .. " " .. 255)
fuk:SetKeyValue("enableshadows", 0)
fuk:SetKeyValue("farz", 512)
fuk:SetKeyValue("nearz", 64)
fuk:SetKeyValue("lightfov" 100)
fuk:Input("SpotlightTexture", NULL, NULL, "effects/flashlight001")
fuk:Spawn()
[/code]
Anyone know of a fix for this?
[QUOTE=kpjVideo;49737064]For some reason my env_projectedtexture (when parented to a vehicle) looks like this (fairly pixelated):
[t]http://162.243.255.203/files/dpshmj.png[/t]
And here's my code:
[code]
local fuk = ents.Create("env_projectedtexture")
fuk:SetParent(Player:GetVehicle())
fuk:SetLocalPos(Vector(0, 35, 5))
fuk:SetKeyValue("lightcolor", 255 .. " " .. 255 .. " " .. 255 .. " " .. 255)
fuk:SetKeyValue("enableshadows", 0)
fuk:SetKeyValue("farz", 512)
fuk:SetKeyValue("nearz", 64)
fuk:SetKeyValue("lightfov" 100)
fuk:Input("SpotlightTexture", NULL, NULL, "effects/flashlight001")
fuk:Spawn()
[/code]
Anyone know of a fix for this?[/QUOTE]
You didn't put a comma after "lightfov"
[QUOTE=MPan1;49735232]Well this is going to be bloody great fun isn't it Garry
[editline]13th February 2016[/editline]
Anyone know if there's a derma skinhook list somewhere with the code that actually makes the functions work, or is that built in or something?
[editline]13th February 2016[/editline]
Nevermind, [URL="https://github.com/garrynewman/garrysmod/blob/3e138636eb1b0ad6ed785dedf350020755cff5f1/garrysmod/lua/skins/default.lua"]found it[/URL]
[editline]13th February 2016[/editline]
Nope, that wasn't what I needed...
Anyone know the code that [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/DrawTextEntryText]Panel:DrawTextEntryText[/url] runs?[/QUOTE]
Have you looked through [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/derma/derma_utils.lua"]github[/URL]?
- Snip -
My server doesn't seem to create any crash dumps. Do I need to add a start-up parameter? I'm on ubuntu
Sorry, you need to Log In to post a reply to this thread.