[QUOTE=Kidd;37985708]I'm probably missing something here but how do I send a bool via net lib?[/QUOTE]
I've yet to move onto Gmod 13 development, but [url=http://wiki.garrysmod.com/page/Libraries/net/WriteBit]net.WriteBit[/url]?
[QUOTE=Greetings;37985823]I've yet to move onto Gmod 13 development, but [url=http://wiki.garrysmod.com/page/Libraries/net/WriteBit]net.WriteBit[/url]?[/QUOTE]
Yeah I saw that but wanted to be sure because ReadBit is either 1 or 0 which I know is a boolean but I guess I was expecting a true or false version.
[QUOTE=.\\Shadow};37979603]I doubt it's the best way to do it, but you can look at the round system I made for a deathrun gamemode, it should give you the general idea: [url]http://pastebin.com/jV3PZE2V[/url]
Also, fretta was removed in GM13.[/QUOTE]
Sweet, thanks.
[QUOTE=daimoden;37985641]-snip-[/QUOTE]
Change the second statement to true, then use rp_restrictbuy 1 in your server console.
Cannot set model with ply:SetModel
I'm trying to force the player's model to ALWAYS be the player model prison (the combine prison guard player model)
they can still be anything else for some reason, maybe a way to force cl_playermodel in the console every time he spawns?
How do I make specific NPCs be friendly to players?(npc_turret_floor should be friendly to players reguardless >.<)
Also, when I do ply:Give or ply:GiveAmmo("weapon_frag") I can't have a team/class to have more than 1 at once. I also can't give them crossbow ammo, like 5 is not enough for my scout class.
How do you disable pvp dmg to teams? Since teams are technically classes in my gamemode.
How do I make the player emit a sound which has a distance via the console? for example, he could bind voice_help in the console and it would make his character say HELP!
This is the one I want most answered, HOW DO I CONTROL AN ENTITY for example an antlion npc for my antlion survival gamemode!
i actually watched tutorials now so im not really dumb anymore xD
[editline]10th October 2012[/editline]
oh and for some reason init.lua does NOT open automatically when I host my gamemode from listen server (i have to do lua_openscript)
I don't think shared or cl does either for some reason
the path to those files is is garrysmod/garrysmod/gamemodes/AntlionSurvival/gamemode/init.lua and shared.lua and cl_init.lua
[editline]10th October 2012[/editline]
O ye you think im dumb eh
Well maybe you should help me so i'm not dumb
also for my 6th team i get name expected got end or something near the end of the file
Why won't this work? No errors, "WE" spams console, idk what I'm doing but I need to create some beams to surround a certain part of the map.
[lua]
function DrawBox()
print( "WE" )
local Vector1 = LocalPlayer():LocalToWorld( Vector( 0, 0, -500 ) )
local Vector2 = LocalPlayer():LocalToWorld( Vector( 0, 0, 500 ) )
render.SetMaterial( Material( "cable/redlaser" ) )
render.DrawBeam( Vector1, Vector2, 5, 1, 1, Color( 255, 255, 255, 255 ) )
end
hook.Add("HUDPaint", "DrawBox", DrawBox)
[/lua]
I need some help with tables and concommands.
I need Lua to check the argument put in, see if it matches one of the things on the table, and if it does it uses it, but if it doesn't, it resets itself or just does nothing.
I'm shit with concommands. I can provide what I have as of now, if needed.
[QUOTE=find me;37987910]Why won't this work? No errors, "WE" spams console, idk what I'm doing but I need to create some beams to surround a certain part of the map.
[lua]
function DrawBox()
print( "WE" )
local Vector1 = LocalPlayer():LocalToWorld( Vector( 0, 0, -500 ) )
local Vector2 = LocalPlayer():LocalToWorld( Vector( 0, 0, 500 ) )
render.SetMaterial( Material( "cable/redlaser" ) )
render.DrawBeam( Vector1, Vector2, 5, 1, 1, Color( 255, 255, 255, 255 ) )
end
hook.Add("HUDPaint", "DrawBox", DrawBox)
[/lua][/QUOTE]
remove the LocalPlayer():LocalToWorld, it will convert the coords relative to the players position
[QUOTE=Marrub;37987992]I need some help with tables and concommands.
I need Lua to check the argument put in, see if it matches one of the things on the table, and if it does it uses it, but if it doesn't, it resets itself or just does nothing.
I'm shit with concommands.[/QUOTE]
use concommand.Add?
[QUOTE=G4MB!T;37988076]remove the LocalPlayer():LocalToWorld, it will convert the coords relative to the players position
use concommand.Add?[/QUOTE]
I can't into tables + concommands.
i dont get what you mean.
concommands pass the arguments as a table.
show me an example of how you want it to work (not in code)
[QUOTE=find me;37987910]Why won't this work? No errors, "WE" spams console, idk what I'm doing but I need to create some beams to surround a certain part of the map.
[lua]
function DrawBox()
print( "WE" )
local Vector1 = LocalPlayer():LocalToWorld( Vector( 0, 0, -500 ) )
local Vector2 = LocalPlayer():LocalToWorld( Vector( 0, 0, 500 ) )
render.SetMaterial( Material( "cable/redlaser" ) )
render.DrawBeam( Vector1, Vector2, 5, 1, 1, Color( 255, 255, 255, 255 ) )
end
hook.Add("HUDPaint", "DrawBox", DrawBox)
[/lua][/QUOTE]
Use the [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7e79.html"]PostDrawOpaqueRenderables [/URL]hook.
[QUOTE=G4MB!T;37988187]i dont get what you mean.
concommands pass the arguments as a table.
show me an example of how you want it to work (not in code)[/QUOTE]
Like I said, I'm terrible with concommands.
I need it to take a list of weapon names and limit the arguments possible to them, and if the argument is something other than those weapon names, it just does nothing.
i mean an example of the input
[QUOTE=G4MB!T;37988340]i mean an example of the input[/QUOTE]
As in?
[QUOTE=find me;37987910]Why won't this work? No errors, "WE" spams console, idk what I'm doing but I need to create some beams to surround a certain part of the map.
[lua]
function DrawBox()
print( "WE" )
local Vector1 = LocalPlayer():LocalToWorld( Vector( 0, 0, -500 ) )
local Vector2 = LocalPlayer():LocalToWorld( Vector( 0, 0, 500 ) )
render.SetMaterial( Material( "cable/redlaser" ) )
render.DrawBeam( Vector1, Vector2, 5, 1, 1, Color( 255, 255, 255, 255 ) )
end
hook.Add("HUDPaint", "DrawBox", DrawBox)
[/lua][/QUOTE]
The beam is probably just getting removed by the near clip plane, try drawing it a bit further away from the player.
[lua]
local Vector1 = LocalPlayer():LocalToWorld( Vector( 50, 0, -500 ) )
local Vector2 = LocalPlayer():LocalToWorld( Vector( 50, 0, 500 ) )
[/lua]
[QUOTE=Marrub;37987992]I need some help with tables and concommands.
I need Lua to check the argument put in, see if it matches one of the things on the table, and if it does it uses it, but if it doesn't, it resets itself or just does nothing.
I'm shit with concommands. I can provide what I have as of now, if needed.[/QUOTE]
If you're doing it in code, it's easier to use net messages
[lua]
if SERVER then
util.AdNetworkString( "Send Table" )
net.Receive( "Send Table", function(len)
local Table = net.ReadTable(0
end)
elseif CLIENT then
net.Start( "Send Table" )
net.WriteTable( Table )
net.SendToServer()
end[/lua]
[QUOTE=Marrub;37988268]Like I said, I'm terrible with concommands.
I need it to take a list of weapon names and limit the arguments possible to them, and if the argument is something other than those weapon names, it just does nothing.[/QUOTE]
This will find all weapons with the string you enter. It doesn't have to be written left to right like "weapon_rpg", instead just type "rpg". Good luck.
[lua]
//clientside
WEAPONS = {}
WEAPONS[1] = "weapon_357"
WEAPONS[2] = "weapon_smg1"
WEAPONS[3] = "weapon_rpg"
function CheckWeapons(ply,cmd,args)
if args[1] then
local v
local strfound = false
for i=1, #WEAPONS do
v = WEAPONS[i]
if string.find(v, args[1]) != nil then
print(v)
strfound = true
end
end
if !strfound then
print( "No matching weapons found.." )
end
else
print( "Usage: checkweapons [weaponname](String)" )
end
end
concommand.Add("checkweapons", CheckWeapons)
[/lua]
[editline]10th October 2012[/editline]
oh forgot to add how you use it:
[lua]
//in console\\
//input
checkweapons rpg
//output
"weapon_rpg"
[/lua]
[QUOTE=Marrub;37988268]Like I said, I'm terrible with concommands.
I need it to take a list of weapon names and limit the arguments possible to them, and if the argument is something other than those weapon names, it just does nothing.[/QUOTE]
[lua]
local weapons =
{
"weapon_smg1",
"weapon_ak47",
"weapon_bananaphone"
}
concommand.Add("iwunnagunz", function(ply, cmd, args)
if table.HasValue(weapons, args[1]) then
--do something
else
--do something else/nothing
end
end)
[/lua]
[editline]11th October 2012[/editline]
Ninja'd.
How can I get a derma menu to open and close on q instead of the spawnmenu? when I tried it I could only get it to open
[QUOTE=Stiveno;37988938]How can I get a derma menu to open and close on q instead of the spawnmenu? when I tried it I could only get it to open[/QUOTE]
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index0c91.html"]Open Spawn Menu[/URL]
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4c32.html"]Close Spawn Menu[/URL]
[QUOTE=M0dSe7en;37988691]This will find all weapons with the string you enter. It doesn't have to be written left to right like "weapon_rpg", instead just type "rpg". Good luck.
[lua]
//clientside
WEAPONS = {}
WEAPONS[1] = "weapon_357"
WEAPONS[2] = "weapon_smg1"
WEAPONS[3] = "weapon_rpg"
function CheckWeapons(ply,cmd,args)
if args[1] then
local v
local strfound = false
for i=1, #WEAPONS do
v = WEAPONS[i]
if string.find(v, args[1]) != nil then
print(v)
strfound = true
end
end
if !strfound then
print( "No matching weapons found.." )
end
else
print( "Usage: checkweapons [weaponname](String)" )
end
end
concommand.Add("checkweapons", CheckWeapons)
[/lua]
[editline]10th October 2012[/editline]
oh forgot to add how you use it:
[lua]
//in console\\
//input
checkweapons rpg
//output
"weapon_rpg"
[/lua][/QUOTE]
Thanks a bunch. This works quite well, however I have a question.
Is there any way to make it so that it just detects if it is on the player or not?
If so, could you post it?
-snip- using a new system.
[QUOTE=Marrub;37989184]Thanks a bunch. This works quite well, however I have a question.
Is there any way to make it so that it just detects if it is on the player or not?
If so, could you post it?[/QUOTE]
here ya go just use:
checkweapons (weapon name) (optional: playername)
[lua]
function CheckWeapons(ply,cmd,args)
if args[1] then
local wep
local strfound = false
for k,v in pairs(player.GetAll()) do
if args[2] then
if string.find(string.lower(v:Nick()), args[2]) != nil then
wep = v:GetWeapons()
for i=1, #wep do
if i == 1 then
print("==========================================================\n"..v:Nick())
end
local keywep = wep[i]:GetClass()
if string.find(string.lower(keywep), args[1]) != nil then
print(keywep)
strfound = true
end
if i == #wep then
print("----------------------------------------------------------")
end
end
end
else
wep = v:GetWeapons()
for i=1, #wep do
if i == 1 then
print("==========================================================\n"..v:Nick())
end
local keywep = wep[i]:GetClass()
if string.find(string.lower(keywep), args[1]) != nil then
print(keywep)
strfound = true
end
if i == #wep then
print("----------------------------------------------------------")
end
end
end
end
if !strfound then
print( "No matching weapons found.." )
end
else
print( "Usage: checkweapons [weaponname] [playername]" )
end
end
concommand.Add("checkweapons", CheckWeapons)
[/lua]
[QUOTE=M0dSe7en;37989586]here ya go just use:
checkweapons (weapon name) (optional: playername)
[lua]
function CheckWeapons(ply,cmd,args)
if args[1] then
local wep
local strfound = false
for k,v in pairs(player.GetAll()) do
if args[2] then
if string.find(string.lower(v:Nick()), args[2]) != nil then
wep = v:GetWeapons()
for i=1, #wep do
if i == 1 then
print("==========================================================\n"..v:Nick())
end
local keywep = wep[i]:GetClass()
if string.find(string.lower(keywep), args[1]) != nil then
print(keywep)
strfound = true
end
if i == #wep then
print("----------------------------------------------------------")
end
end
end
else
wep = v:GetWeapons()
for i=1, #wep do
if i == 1 then
print("==========================================================\n"..v:Nick())
end
local keywep = wep[i]:GetClass()
if string.find(string.lower(keywep), args[1]) != nil then
print(keywep)
strfound = true
end
if i == #wep then
print("----------------------------------------------------------")
end
end
end
end
if !strfound then
print( "No matching weapons found.." )
end
else
print( "Usage: checkweapons [weaponname] [playername]" )
end
end
concommand.Add("checkweapons", CheckWeapons)
[/lua][/QUOTE]
Whoa.
How do I set a player to observer mode upon first spawn?
My current code (which does not work)(using gmod 12)
[PHP]
ply:Spectate()
ply:PrintMessage( HUD_PRINTTALK, "Please set your team with team_1 or team_5 or inbetween. team_1 = default, team_2 ar2, team_3 = shotgun, team_4 = 357 team 5 = scout, team 6 = heavy., " .. ply:Nick() .. "!" )
end[/PHP]
i also tried it without the (), i tried putting true in the () and it does not work.
how do i set the player to spectate on inital spawn?
that is under an initialspawn function btw
[QUOTE=brandonj4;37988194]Use the [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7e79.html"]PostDrawOpaqueRenderables [/URL]hook.[/QUOTE]
Worked perfect Thank you.
[QUOTE=ralle105;37988626]The beam is probably just getting removed by the near clip plane, try drawing it a bit further away from the player.
local Vector1 = LocalPlayer():LocalToWorld( Vector( 50, 0, -500 ) ) local Vector2 = LocalPlayer():LocalToWorld( Vector( 50, 0, 500 ) ) [/QUOTE]
You're post made me curious, as I had no idea what near clip plane even meant. Just did a little research and learned some new stuff today, far clip plane and near clip plane. Puts a lot of really cool things I've thought about are now put in perspective. THANKS :D
[editline]11th October 2012[/editline]
[QUOTE=Marrub;37989184]Thanks a bunch. This works quite well, however I have a question.
Is there any way to make it so that it just detects if it is on the player or not?
If so, could you post it?[/QUOTE]
Isn't this what you wanted: Once someone uses the command "PlayerHasWeapon [Weapon] [Player Name]" it checks if the weapons table contains the weapon listed, then checks if the player has the weapon themselves? If so this is what you want.
[lua]
local Weapons = {
["SMG"] = "weapon_smg1",
["AK47"] = "weapon_ak47",
["Banana Phone..."] = "weapon_bananaphone"
}
function WeaponExistsInTable( Table, Weapon, ReturnName )
local Weapon = string.Trim( string.lower(Weapon) )
local FoundIt = false
for k, v in pairs( Table ) do
if string.lower(v) == Weapon || string.lower(k) == Weapon then
FoundIt = true
if ReturnName == 1 then
return k
elseif ReturnName == 2 then
return v
end
end
end
return FoundIt
end
function PlayerExists( Name )
local Name = string.Trim(string.lower(Name))
local FoundThem = false
for k, v in pairs( player.GetAll() ) do
if string.find( string.Trim(string.lower(v:Nick())), Name ) then
FoundThem = true
end
end
return FoundThem
end
function PlayerContainsWeapon( Weapon, pl )
local DoThey = false
for k, v in pairs( pl:GetWeapons() ) do
if v:GetClass() == WeaponExistsInTable( Weapons, Weapon, 2 ) then
DoThey = true
end
end
return DoThey
end
function Player( Name, ReturnName )
local Name = string.Trim(string.lower(Name))
for k, v in pairs( player.GetAll() ) do
if string.find( string.Trim(string.lower(v:Nick())), Name ) then
if ReturnName then
return v:Nick()
else
return v
end
end
end
end
function PlayerHasWeapon( pl, cmd, arg )
local Weapon = arg[1]
local Name = arg[2]
local ApplyToSelf = false
if Weapon == nil then
print( "\nUsage: PlayerHasWeapon [Weapon Name] [Player Name]\n" )
return
elseif Name == nil then
ApplyToSelf = true
end
if !WeaponExistsInTable( Weapons, Weapon, 0 ) then print( "\nSorry, the weapon '"..Weapon.."' does not exist in the selected list of weapons!\n" ) return end
if !PlayerExists( Name ) then print( "\nSorry, the player '"..Name.."' does not exist!\n" ) return end
if ApplyToSelf then
if PlayerContainsWeapon( Weapon, pl ) then
print( "You have a "..WeaponExistsInTable( Weapons, Weapon, 1 ).."!" )
end
else
if PlayerContainsWeapon( Weapon, Player(Name, false) ) then
print( Player(Name, true).. " has a "..WeaponExistsInTable( Weapons, Weapon, 1 ).."!" )
end
end
end
concommand.Add( "PlayerHasWeapon", PlayerHasWeapon )
[/lua]
I'm coding a BHop gamemode, and it's going pretty good so far. I'm only having trouble with one thing:
How the hell can I get the brick entities to stop going down when I jump on them, but instead teleport me back to the "safe-location"?
[QUOTE=Persious;37997065]I'm coding a BHop gamemode, and it's going pretty good so far. I'm only having trouble with one thing:
How the hell can I get the brick entities to stop going down when I jump on them, but instead teleport me back to the "safe-location"?[/QUOTE]
that has to be part of the map
I don't think so, as I've seen BHop gamemodes disabling it. Ex. Sassilization.
Is there anyone that can provide me with an example of applying a Player Colour if Player:IsAdmin() returns true, and if possible a check of the player color on player spawn? The example on the wiki wasn't very helpful in explaining to me how to call the function for a specific color, so any help would be appreciated!
Sorry, you need to Log In to post a reply to this thread.