If I use ply:Give("gmod_tool") is there any way for me to set which tool the player is using?
[B]EDIT:[/B] Ok, I've figured it out. In case anyone is wondering it's set through the gmod_toolmode convar
how do i make NPC fear on some entity?
-snip-
Help, i stuck so hard in this... need a sledgehammer.
I want to draw a recently created rendertarget in HUD. Like the Show in HUD function from RT Camera (which uses PP/RT material..)
thats what i got.. i cant get it working
[CODE]
local res = 256
local NewRT = GetRenderTarget( "rendertarget1", res, res, false )
local OldRT = render.GetRenderTarget()
render.SetRenderTarget( NewRT )
cam.Start2D()
-- Drawing stuff in here, squares circles and text..blah
cam.End2D()
render.SetRenderTarget( OldRT )
hook.Add("HUDPaint","sheeeiiit",function()
surface.SetTexture( surface.GetTextureID( "rendertarget1" ))
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawTexturedRect( 256 , 256, res, res )
end)[/CODE]
Hello everybody, so i'm intresded in how to change color of the model.
I have code:
[CODE]
local mdl = ClientsideModel(cur_model=="" and "models/props_phx/construct/metal_angle90.mdl" or cur_model, RENDERGROUP_OPAQUE)
mdl:SetPos(bone_pos)
mdl:SetAngles(bone_ang)
mdl:SetRenderOrigin(bone_pos)
mdl:SetRenderAngles(bone_ang)
mdl:SetupBones()
mdl:SetColor(Color(0,255,0,255))
mdl:DrawModel()
mdl:SetColor(Color(0,255,0,255))
mdl:Remove()
[/CODE]
variables bone_pos and bone_ang have valid values. But the color of this model... i need to change it. How i may do this?
[QUOTE=rebel1324;46383013]how do i make NPC fear on some entity?[/QUOTE]
[url]http://wiki.garrysmod.com/page/NPC/AddEntityRelationship[/url]
I've never used it but I did look into it when I was trying to make a TTT zombie that would only attack innocents, never got it to work...
I've created this for pointshop which prevents models the player does not have from being drawn.
[lua]
-- this is the only important bit, it's located in cl_init, in the loop that draws all the clientsidemodels in the PostPlayerDraw hook at the bottom.
model, pos, ang = ITEM:ModifyClientsideModel(ply, model, pos, ang)
local modelstr = model:GetModel()
if mdlexistscache[modelstr] == nil then
mdlexistscache[modelstr] = file.Exists(modelstr, "GAME")
elseif mdlexistscache[modelstr] == true then
model:SetPos(pos)
model:SetAngles(ang)
model:SetRenderOrigin(pos)
model:SetRenderAngles(ang)
model:SetupBones()
model:DrawModel()
model:SetRenderOrigin()
model:SetRenderAngles()
end
[/lua]
mdlexistscache is a local table created outside the hook.
I know that file.Exists in the "GAME" path can be expensive. I was wondering if this is a good way to go about it.
-snip-
How would I set the material of a model in my viewmodel? (Using SCK so it's a custom viewmodel)
PreViewModelDraw or PostViewModelDraw, can't quite remember the correct hook.
[QUOTE=LUModder;46385160]How would I set the material of a model in my viewmodel? (Using SCK so it's a custom viewmodel)[/QUOTE]
Use SCK's built in material functionality.
I have limited control with this tablet, but the server gives me something about bsetbodydata when using http.post, has worked fine in the past.
No errors in apache either. What's up with that?
So, there's this weird problem that when more than 1 person has this item equiped, only 1 of them will work.
[code] ITEM.Name = 'Kevlar (armor)'
ITEM.Price = 25000
//You don't need a model for something that won't be spawned in game!
ITEM.Material = ''
ITEM.OneUse = true
function ITEM:OnEquip(ply, modifications)
hook.Add("PlayerSpawn", "hp1", function()
timer.Simple(5, function()
ply:SetArmor(20)
end)
end)
end
function ITEM:OnHolster(ply)
end
function ITEM:OnSell(ply)
end
[/code]
For example: Player A bought this, round starts and he gets the armor. Then player B buys this too. Round starts and only player B has the armor.
[QUOTE=Scarface3353;46387384]So, there's this weird problem that when more than 1 person has this item equiped, only 1 of them will work.
[code] ITEM.Name = 'Kevlar (armor)'
ITEM.Price = 25000
//You don't need a model for something that won't be spawned in game!
ITEM.Material = ''
ITEM.OneUse = true
function ITEM:OnEquip(ply, modifications)
hook.Add("PlayerSpawn", "hp1", function()
timer.Simple(5, function()
ply:SetArmor(20)
end)
end)
end
function ITEM:OnHolster(ply)
end
function ITEM:OnSell(ply)
end
[/code][/QUOTE]
Change hook.Add("PlayerSpawn", "hp1", function()
to
hook.Add("PlayerSpawn", "hp1" .. ply:EntIndex( ), function()
The reason it does that is because the name is the same, and when a new one is equipped then hp1 overwrites the old hp1 in PlayerSpawn hook category. You can only use a unique name once per hook category, but you can use the hp1 name in PlayerSpawn, Think, etc and they'd work since those are different hook "categories".
-push- still need help
[url]http://facepunch.com/showthread.php?t=1411111&p=46383105&viewfull=1#post46383105[/url]
Ìn the material browser, "rendertarget1" is showing up. but i cant use it as vgui material.
[QUOTE=gamerpaddy;46387545]-push- still need help
[url]http://facepunch.com/showthread.php?t=1411111&p=46383105&viewfull=1#post46383105[/url]
Ìn the material browser, "rendertarget1" is showing up. but i cant use it as vgui material.[/QUOTE]
Create a material and set its $basetexture property to the render target.
[code]
local mat = CreateMaterial("my_mat", "UnlitGeneric", {
["$basetexture"] = <your texture/rt>
})
[/code]
Optionally use the pp/copy material, but that'll require you to constantly set the $basetexture property when you draw.
[QUOTE=Scarface3353;46387384]So, there's this weird problem that when more than 1 person has this item equiped, only 1 of them will work.
[code] ITEM.Name = 'Kevlar (armor)'
ITEM.Price = 25000
//You don't need a model for something that won't be spawned in game!
ITEM.Material = ''
ITEM.OneUse = true
function ITEM:OnEquip(ply, modifications)
hook.Add("PlayerSpawn", "hp1", function()
timer.Simple(5, function()
ply:SetArmor(20)
end)
end)
end
function ITEM:OnHolster(ply)
end
function ITEM:OnSell(ply)
end
[/code]
For example: Player A bought this, round starts and he gets the armor. Then player B buys this too. Round starts and only player B has the armor.[/QUOTE]
You are not required to have what you want to do in the OnEquip function. In fact for some stuff, it'll be better not to! As well as this, you can also do ply:PS_HasItemEquipped("filename"), which should be used on Spawn so the wrong people don't get it.
I wrote some very simple Pointshop Perks a while back, armouring being one of them if you want to take a look:
[url]https://github.com/NiandraL/Pointshop-Perks-1/blob/master/PointshopPerks/lua/autorun/server/armor_perk.lua[/url]
How can I get a string from an entity that's serversider clientside without net?
[QUOTE=LUModder;46388442]How can I get a string from an entity that's serversider clientside without net?[/QUOTE]
You mean like a variable saved to the entity? You can't.
Well, I'm making a CS-like gamemode on fretta based on a NiandraLades gamemode (thanks), and i want players to be able to press F1 to get weapons and armor. Is there any way to do that?
Yes. [URL="http://wiki.garrysmod.com/page/GM/ShowHelp"]Use this hook[/URL]. [lua]GM:ShowHelp( plr )[/lua]
is there anyway to get a line?
lets say if i typed "Hello everyone"
it would get "Hello everyone"?
[QUOTE=Invule;46389238]is there anyway to get a line?
lets say if i typed "Hello everyone"
it would get "Hello everyone"?[/QUOTE]
[url]http://wiki.garrysmod.com/page/GM/PlayerSay[/url]
[url]http://wiki.garrysmod.com/page/GM/OnPlayerChat[/url]
Is that what you mean?
[QUOTE=Sereni;46389252][url]http://wiki.garrysmod.com/page/GM/PlayerSay[/url]
[url]http://wiki.garrysmod.com/page/GM/OnPlayerChat[/url]
Is that what you mean?[/QUOTE]
No like,
in c++ you can do
std::string input = "";
std::cout << "Hello how was your day ";
then you can do getline which will get your input basically
getline(std::cin, input)
Then if i typed Hello, my day was fine thank you
and printed it, std::cout << input;
it would print "Hello, my day was fine thank you"
I have no idea how i can explain it otherwise :/
[QUOTE=Invule;46389288]-snip-[/QUOTE]
What are you trying to accomplish with this?
[QUOTE=Sereni;46389329]What are you trying to accomplish with this?[/QUOTE]
What do you mean, thats basically what i want just in Lua?
How do I force a player to shoot their gun from the server. I want it to be like they shot it, and i don't want to do +attack in console.
[QUOTE=AnonTakesOver;46389378]How do I force a player to shoot their gun from the server. I want it to be like they shot it, and i don't want to do +attack in console.[/QUOTE]
You could use the FireBullets command, although you shouldn't have an issue using _p:GetActiveWeapon( ):PrimaryAttack( );
You may need to network it though, call it on both server and network it to the client so the client code registers properly with the client.
[editline]2nd November 2014[/editline]
[QUOTE=Invule;46389288]No like,
in c++ you can do
std::string input = "";
std::cout << "Hello how was your day ";
then you can do getline which will get your input basically
getline(std::cin, input)
Then if i typed Hello, my day was fine thank you
and printed it, std::cout << input;
it would print "Hello, my day was fine thank you"
I have no idea how i can explain it otherwise :/[/QUOTE]
You could do it one of several ways... look into string.StartWith -- if you want to see if a string starts with something, string.sub if you want to grab the last character to see if it was a ? or so, you can use negative values to get the last char.
So, when a question was asked you want to receive an input. You can use PlayerSay ( serverside hook ) or OnPlayerChat ( clientside, but it is called every time someone chats, so if you want to have something activate for the client, compare the "speaker" with LocalPlayer( ) ).... to detect when the question is asked.
You can either open up a vgui window to receive the response, or you can force the chat window open ( and prevent it from closing until a response of x chars has been entered by re-opening if the player submits bad response, similar to using a do while ), or you can store the question and let the client respond when they have time ( depends on the type of game-mode you're creating.. )...
Is it supposed to be a sort of instant-death trivia where questions must be answered right away or something?
[editline]2nd November 2014[/editline]
[QUOTE=Scarface3353;46389211]Well, I'm making a CS-like gamemode on fretta based on a NiandraLades gamemode (thanks), and i want players to be able to press F1 to get weapons and armor. Is there any way to do that?[/QUOTE]
In addition to what WalkingZombie responded with... Since you're giving weapons and armor on F1 it is best to use the built in commands for F1-F4 on the server.
You could also use PlayerBindPress on the client and network it.
Here are the 2 examples in code ( for opening vgui window networked to client from server or just clientside ) which may or may not help down the road: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/open_vgui_based_on_keypress.lua.html[/url]
How come on my client, bots tell me their ammo count but no one else does.
[url]http://wiki.garrysmod.com/page/Player/GetAmmoCount[/url]
That only works on bots from the client, how do I get it to work with players without making it update everytime a bullet is fired with net.
Also, it's the same with Weapon:Clip1()
Sorry, you need to Log In to post a reply to this thread.