Been trying to do a ULX command to allow forcing a player to a zombie class in Zombie Survival but no matter what the StringArgs is null everytime, I have no idea why
[code]local zombieclasses = gmod.GetGamemode().ZombieClasses
function ulx.forceclass( calling_ply, target_plys, class )
local affected_plys = {}
for i=1, #target_plys do
local v = target_plys[ i ]
if v:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
elseif v:Team() == TEAM_HUMAN then
ULib.tsayError( calling_ply, v:Nick() .. " is a human!", true )
else
local zombieclass = GAMEMODE.ZombieClasses[class]
if not zombieclass then return end
local curclass = v.DeathClass or v:GetZombieClass()
local zombieindex = zombieclass.Index
v:SetZombieClass(zombieindex)
v:DoHulls(zombieindex, TEAM_UNDEAD)
if GAMEMODE:GetWaveActive() then
v:UnSpectateAndSpawn()
v.DeathClass = curclass
end
table.insert( affected_plys, v )
end
end
ulx.fancyLogAdmin( calling_ply, "#A forced #T to a #s.", affected_plys, class )
end
local forceclass = ulx.command( "Zombie Survival", "ulx forceclass", ulx.forceclass, "!forceclass" )
forceclass:addParam{ type=ULib.cmds.PlayersArg }
forceclass:addParam{ type=ULib.cmds.StringArg, completes=zombieclasses, hint="Class", error="invalid class \"%s\" specified", ULib.cmds.restrictToCompletes }
forceclass:defaultAccess(ULib.ACCESS_ADMIN)
forceclass:help( "Sets target(s) zombie class." )[/code]
Does anyone know any tutorials on how to pimp out your Derma?
I am tired of the old grey boxes, I want something new. But I have no idea how to even change the color of it... :/
[QUOTE=Fillipuster;47022060]Does anyone know any tutorials on how to pimp out your Derma?
I am tired of the old grey boxes, I want something new. But I have no idea how to even change the color of it... :/[/QUOTE]
Look up GWEN skins. The default is in garrysmod/lua/skins/default.lua, and it uses a texture map called materials/gwenskin/gmoddefault.png, which you can modify using this .psd document included in the game's files:
[url]https://www.dropbox.com/s/hkvjz2rekmt2d2e/gmoddefault.psd?dl=1[/url]
Force your elements to use a skin with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetSkin]Panel:SetSkin[/url] and they will assuredly become quite [I]pimped out[/I].
I'm working on my DarkRP server, and I'm running into an issue. On my Police job, [URL="http://i.imgur.com/XbJUQpv.png"]the first five models show as errors on the F4 menu[/URL] (I'm only showing the last two to show that not all of the models appear as errors), but appear just fine if you spawn the ragdoll or become the model and view yourself in a camera. Additionally, I can view the icon preview just fine in the spawnmenu, it's only in the F4 menu where this occurs. I'm using the NYPD 1940's Model Pack from the workshop for these models, and the code for this particular job is below;
[code]
TEAM_POLICE = DarkRP.createJob("Police", {
color = Color(25, 25, 170, 255),
model = {
"models/humans/nypd1940/male_01.mdl",
"models/humans/nypd1940/male_02.mdl",
"models/humans/nypd1940/male_03.mdl",
"models/humans/nypd1940/male_04.mdl",
"models/humans/nypd1940/male_05.mdl",
"models/humans/nypd1940/male_06.mdl",
"models/humans/nypd1940/male_07.mdl",
"models/humans/nypd1940/male_08.mdl",
"models/humans/nypd1940/male_09.mdl"
},
description = [[The protector of every citizen that lives in the city.
You have the power to arrest criminals and protect innocents.
Hit a player with your arrest baton to put them in jail.
Bash a player with a stunstick and they may learn to obey the law.
The Battering Ram can break down the door of a criminal, with a warrant for their arrest.
The Battering Ram can also unfreeze frozen props (if enabled).
Type /wanted <name> to alert the public to the presence of a criminal.]],
weapons = {"rphands", "arrest_stick", "unarrest_stick", "weapon_glock2", "stunstick", "door_ram", "weaponchecker"},
command = "cp",
max = 4,
salary = GAMEMODE.Config.normalsalary * 1.45,
admin = 0,
vote = true,
hasLicense = true,
ammo = {
["pistol"] = 60,
}[/code]
I've actually been working to try to solve this issue with Cake on the DarkRP forum, which you can see [URL="http://forum.darkrp.com/threads/models-that-are-on-the-server-and-client-appear-as-an-error-in-the-f4-menu.3840/"]here[/URL], but to save time, I'll quote some posts that had some worthwhile discoveries regarding this problem.
[quote=Rhapsody]Yes, I can spawn all nine models, including the five that are erroring on the F4 menu. They all show up with no problem. To reiterate, if I choose the error model when I pick the Police job and view myself in a camera, the model also shows up just fine. Is it possible that this is just an error on my side and I should get someone else to check?[/QUOTE]
[quote=Rhapsody]I got someone to test it, and they saw everything as an error. Understandable, because I forgot to AddWorkshop all of the custom models. I did that and we downloaded them. The main thing we've learned here is that downloading them like that didn't get rid of those five errors for me and it didn't get rid of any of the errors in the F4 menu for the person helping me test, but the person helping me test could see the actual world models just fine, once I chose one of those classes. That is, only after downloading the content (obviously).
In other words, the issue still exists and it's not just for me, and for some reason only five of the models are errors in the F4 menu for me, while all of the custom models are an error in the F4 menu for another person.[/QUOTE]
[QUOTE=WitheredPyre;47024583]I'm working on my DarkRP server, and I'm running into an issue. On my Police job, [URL="http://i.imgur.com/XbJUQpv.png"]the first five models show as errors on the F4 menu[/URL] (I'm only showing the last two to show that not all of the models appear as errors), but appear just fine if you spawn the ragdoll or become the model and view yourself in a camera. Additionally, I can view the icon preview just fine in the spawnmenu, it's only in the F4 menu where this occurs. I'm using the NYPD 1940's Model Pack from the workshop for these models, and the code for this particular job is below;
[code]
TEAM_POLICE = DarkRP.createJob("Police", {
color = Color(25, 25, 170, 255),
model = {
"models/humans/nypd1940/male_01.mdl",
"models/humans/nypd1940/male_02.mdl",
"models/humans/nypd1940/male_03.mdl",
"models/humans/nypd1940/male_04.mdl",
"models/humans/nypd1940/male_05.mdl",
"models/humans/nypd1940/male_06.mdl",
"models/humans/nypd1940/male_07.mdl",
"models/humans/nypd1940/male_08.mdl",
"models/humans/nypd1940/male_09.mdl"
},
description = [[The protector of every citizen that lives in the city.
You have the power to arrest criminals and protect innocents.
Hit a player with your arrest baton to put them in jail.
Bash a player with a stunstick and they may learn to obey the law.
The Battering Ram can break down the door of a criminal, with a warrant for their arrest.
The Battering Ram can also unfreeze frozen props (if enabled).
Type /wanted <name> to alert the public to the presence of a criminal.]],
weapons = {"rphands", "arrest_stick", "unarrest_stick", "weapon_glock2", "stunstick", "door_ram", "weaponchecker"},
command = "cp",
max = 4,
salary = GAMEMODE.Config.normalsalary * 1.45,
admin = 0,
vote = true,
hasLicense = true,
ammo = {
["pistol"] = 60,
}[/code]
I've actually been working to try to solve this issue with Cake on the DarkRP forum, which you can see [URL="http://forum.darkrp.com/threads/models-that-are-on-the-server-and-client-appear-as-an-error-in-the-f4-menu.3840/"]here[/URL], but to save time, I'll quote some posts that had some worthwhile discoveries regarding this problem.[/QUOTE]
I think it's a bug, not your code. Your code it's just fine.
When I had a darkrp server I had the same police models and had the same error
models/humans/ is the NPC model directory... See if the same mod has any models in the players/ directory.
[QUOTE=Acecool;47025956]models/humans/ is the NPC model directory... See if the same mod has any models in the players/ directory.[/QUOTE]
Weird, given that I was copying directly from the spawn menu. I'll extract the GMA and look for the filepaths there in a bit, and I'll update you guys.
You're missing a ) at the end.
[QUOTE=Acecool;47025956]models/humans/ is the NPC model directory... See if the same mod has any models in the players/ directory.[/QUOTE]
I extracted the .GMA and that's the only model path, there's no players/ directory. There is, however, an autorun file in /autorun called 1940nypd_player.lua, which contains this;
[code]player_manager.AddValidModel( "NYPD1940_1", "models/humans/nypd1940/male_01.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_1", "models/humans/nypd1940/male_01.mdl" )
player_manager.AddValidModel( "NYPD1940_2", "models/humans/nypd1940/male_02.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_2", "models/humans/nypd1940/male_02.mdl" )
player_manager.AddValidModel( "NYPD1940_3", "models/humans/nypd1940/male_03.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_3", "models/humans/nypd1940/male_03.mdl" )
player_manager.AddValidModel( "NYPD1940_4", "models/humans/nypd1940/male_04.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_4", "models/humans/nypd1940/male_04.mdl" )
player_manager.AddValidModel( "NYPD1940_5", "models/humans/nypd1940/male_05.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_5", "models/humans/nypd1940/male_05.mdl" )
player_manager.AddValidModel( "NYPD1940_6", "models/humans/nypd1940/male_06.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_6", "models/humans/nypd1940/male_06.mdl" )
player_manager.AddValidModel( "NYPD1940_7", "models/humans/nypd1940/male_07.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_7", "models/humans/nypd1940/male_07.mdl" )
player_manager.AddValidModel( "NYPD1940_8", "models/humans/nypd1940/male_08.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_8", "models/humans/nypd1940/male_08.mdl" )
player_manager.AddValidModel( "NYPD1940_9", "models/humans/nypd1940/male_09.mdl" )
list.Set( "PlayerOptionsModel", "NYPD1940_9", "models/humans/nypd1940/male_09.mdl" )[/code]
[QUOTE=Carlton Dance;47026829]You're missing a ) at the end.[/QUOTE]
I must've missed it in my paste, but it is in my code.
Why does this return null?
[code]
hook.Add("PlayerSpawnedProp", "playerSpawnedProp", function(ply,model,ent)
for k, v in pairs(ents.GetAll()) do
if v:GetClass() == "prop_physics" then
print(v:GetOwner())
end
end
end )
[/code]
[QUOTE=Lizart;47027120]Why does this return null?
[code]
hook.Add("PlayerSpawnedProp", "playerSpawnedProp", function(ply,model,ent)
for k, v in pairs(ents.GetAll()) do
if v:GetClass() == "prop_physics" then
print(v:GetOwner())
end
end
end )
[/code][/QUOTE]
Because in that code you're not returning nothing? Please think with logic
[QUOTE=geferon;47027160]Because in that code you're not returning nothing? Please think with logic[/QUOTE]
Im trying to get the owner of the prop but it prints[NULL Entity] to the console.
[QUOTE=Lizart;47027120]Why does this return null?
[code]
hook.Add("PlayerSpawnedProp", "playerSpawnedProp", function(ply,model,ent)
for k, v in pairs(ents.GetAll()) do
if v:GetClass() == "prop_physics" then
print(v:GetOwner())
end
end
end )
[/code][/QUOTE]
You should be looking at [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetCreator]Entity:GetCreator[/url] instead, Set/GetOwner is for disabling collisions.
[QUOTE=Jvs;47027177]You should be looking at [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetCreator]Entity:GetCreator[/url] instead, Set/GetOwner is for disabling collisions.[/QUOTE]
doing this
[code]
hook.Add("PlayerSpawnedProp", "playerSpawnedProp", function(ply,model,ent)
print(ent:GetCreator())
end )
[/code]
just prints out NILL
edit: setting the creator first and then printing it obviously works, but is that required?
[code]
ent:SetCreator(ply)
print(ent:GetCreator())
[/code]
My bad, sandbox doesn't set the creator of entity spawned with the spawnmenu at all, so yeah you're gonna have to do that on your own.
I have no experience with Dark RP at all, I'm out.
[QUOTE=Jvs;47027223]My bad, sandbox doesn't set the creator of entity spawned with the spawnmenu at all, so yeah you're gonna have to do that on your own.[/QUOTE]
im currently testing it in darkrp but it works fine if i set the creator before running my code.
With prop protection you can do ent:CPPIGetOwner()
How would I go about ensuring the first letter of a string is upper case?
And in case it's not, make it upper case.
[lua]local str = "hello there"
if (not str:sub(0,1):match("%u")) then
str = str:gsub("^%l", string.upper)
end[/lua]
[editline]n[/editline]
Hell, you dont even need the if check, but meh
how do i make big hackes? like mad hackes for big playes?
[QUOTE=TheMotherFuck;47028818]how do i make big hackes? like mad hackes for big playes?[/QUOTE]
What do you mean? Hacks?
[QUOTE=Author.;47028832]What do you mean? Hacks?[/QUOTE]
yes mad hackes so that i make big play for all other to see and go "omg!!! big play!!!"
dont rate fucknig funny i am serious
[highlight](User was permabanned for this post ("alt of permabanned user" - postal))[/highlight]
[QUOTE=TheMotherFuck;47028884]yes mad hackes so that i make big play for all other to see and go "omg!!! big play!!!"[/QUOTE]
Look, considering this is the official forum for Garry's Mod it's not a very good idea to ask for "hackes" to make you a "big play"
[QUOTE=ZombieWizzard;47028898]Look, considering this is the official forum for Garry's Mod it's not a very good idea to ask for "hackes" to make you a "big play"[/QUOTE]
oh sorry, i take it back
Is it possible to display an image (png etc...) as a part of a HUD?
Not a PNG, etc as I know. But you can make it a model or like that to display it in the HUD
Outside of hook;
[lua]local pictureMat = Material("picture.png") -- garrysmod/materials/picture.png[/lua]
Inside the hook;
[lua]surface.SetMaterial( pictureMat ) -- Set the material we cached above (Important dont do that in the hook)
surface.SetDrawColor( 255, 255, 255 ) -- White so all colors are the same as the picture.
surface.DrawTexturedRect( 0, 0, 100, 100 ) -- Not DrawRect, but DrawTexturedRect. Has the same arguments.[/lua]
I need someone to help me with my circle creating function, this is the code:
[lua]
local function Circle(centerX, centerY, radius, width, clr)
surface.SetDrawColor( clr )
for i=1, width do
surface.DrawLine( centerX, centerY, centerX+(math.cos(i)*radius), centerY+(math.sin(i)*radius) )
end
end
hook.Add("HUDPaint","CircularCircle",function()
Circle(ScrW()*0.5,ScrH()*0.5,70,360,color_white)
end)
[/lua]
The problem now, is that the width only changes the density of the lines while still making a full circle, when I wanted it to change the circle, like 1/2 of a circle, 3/4 of a circle, etc.
[QUOTE=WitheredPyre;47026588]Weird, given that I was copying directly from the spawn menu. I'll extract the GMA and look for the filepaths there in a bit, and I'll update you guys.[/QUOTE]
You can also look through the contents using file.Find( "*", title_of_addon );
[QUOTE=WitheredPyre;47026969]I extracted the .GMA and that's the only model path, there's no players/ directory. There is, however, an autorun file in /autorun called 1940nypd_player.lua, which contains this;
I must've missed it in my paste, but it is in my code.[/QUOTE]
Make sure the addon isn't described as being "Ragdolls" or whatever. If they were compiled with the player animations then they should work fine but these may not have been...
[QUOTE=GGG KILLER;47030669]The problem now, is that the width only changes the density of the lines while still making a full circle, when I wanted it to change the circle, like 1/2 of a circle, 3/4 of a circle, etc.[/QUOTE]
[lua]
local step = math.pi/180 --360 steps for a circle
local function Circle(centerX, centerY, radius, width, clr)
surface.SetDrawColor( clr )
for i = 0, math.pi * (width/180), step do
surface.DrawLine( centerX, centerY, centerX+(math.cos(i)*radius), centerY+(math.sin(i)*radius) )
end
end
hook.Add("HUDPaint","CircularCircle",function()
Circle(ScrW()*0.5,ScrH()*0.5,70,360,color_white)
end)
[/lua]
the reason for this is because cos/sin take radians (2*pi radians is the same as 360 degrees)
this is a bad way to do filled circles though, look for one of the dozens of different snippets doing it with surface.DrawPoly
Sorry, you need to Log In to post a reply to this thread.