Okay, so today I've got back to working on my gamemode and when I ran it I noticed that error that wasn't there before the update appeared: -- I CAN'T really put the error here because I removed the function and cleared console, however theres 1 thing that you'll need to help me out:
I can't do:
PrintTable(player.GetByID(1).XPM)
PrintTable(ply.XPM)
Outputs nothing, like the tables were empty, however doing:
PrintTable(FetchData) works flawlessly
Heres the code and as I remember it worked before the update.
[lua]function DB.PlayerCheck(ply)
ply.XPM = {} -- Temp. table
ply.XPM.xp = 0
ply.XPM.fame = 0
ply.XPM.infame = 0
FetchData = sql.Query("SELECT * FROM xpm_players WHERE id = '"..ply:SteamID().."'") -- Get data from the database
if FetchData then -- asign it where it belongs
ply.XPM.xp = FetchData.xp
ply.XPM.fame = FetchData.fame
ply.XPM.infame = FetchData.infame
end
end
hook.Add("PlayerInitialSpawn", "PlayerCheck", DB.PlayerCheck)[/lua]
Also sorry if I made any mistake while writting this post, it's really late
Trying to add a point shop item that would force a player to be a Traitor/Detective the next round. Major problem at the moment is I can't find the proper command to FORCE one of those in the first place. The wiki lists commands which don't seem to function at all. (ttt_force_traitor)
Could anyone provide a quick example for [url=http://wiki.garrysmod.com/page/Libraries/physenv/AddSurfaceData]AddSurfaceData[/url]? The wiki doesn't exactly explain how the data has to be formatted.
[QUOTE=Mitsudigi;39031633]Is it possible to change view model materials with Lua instead of using separate models for each?
Is the only way to debug server/client crashes to send crash dumps to certain people on these forums? If so, who?
Unrelated, but why does Garry use "L.U.A." in this board's name when the official Lua website has stated forever that it's incorrect?
[url]http://www.lua.org/about.html[/url][/QUOTE]
Garry does that to piss some people off.
[QUOTE=luavirusfree;39035899]Not a problem now. I want to know how to give a swep to the player without errors. self.Owner:Give(swep) errors... (Giving a swep, with a swep).
Also, ents.Create returned an error. Both errors happen in both server and client.
[php]
[ERROR] lua/weapons/smallmario/shared.lua:87: attempt to call field 'Create' (a nil value) 1. unknown - lua/weapons/smallmario/shared.lua:87
[/php] Color: Yellow.[/QUOTE]
I think you don't understand the difference between clientside and serverside.
In garrysmod the client is yellow, the server is blue.
Some functions are clientside only, some serverside only and most are shared.
The error you showed means "Create" is a nil value I'm going to assume that you misspelled ents.Create ( You probably wrote ent.Create ) and that's why it gives you that error.
To prevent the first error do it like this:
[code]
if ( SERVER and self.Owner and IsValid(self.Owner) ) then self.Owner:Give("weapon_purple_dildo") end
[/code]
Second one is fixable like that too.
And please, don't implent it exactly like I gave it to you add newlines and tabbing.
[QUOTE=brandonj4;39034132]Thanks, I probably would have never found that.
I only found a Pastebin of functions used for the process but no actual code, but thank you.
[editline]30th December 2012[/editline]
When you Emit the sound, be sure to use:
[code]
if (SERVER) or (CLIENT) then
self:EmitSound("mysound")
end
[/code]
This will make sure that it doesn't emit clientside [B]and [/B]serverside. Makes sense?[/QUOTE]
What :v:, running shared is just running it on both server and client, you should use IfIsFirstTimePredicted() to stop and quick repeating with prediction.
[editline]30th December 2012[/editline]
That is why you include something shared on cl_init and init.
[QUOTE=Leystryku;39036990]Garry does that to piss some people off.
I think you don't understand the difference between clientside and serverside.
In garrysmod the client is yellow, the server is blue.
Some functions are clientside only, some serverside only and most are shared.
The error you showed means "Create" is a nil value I'm going to assume that you misspelled ents.Create ( You probably wrote ent.Create ) and that's why it gives you that error.
To prevent the first error do it like this:
[code]
if ( SERVER and self.Owner and IsValid(self.Owner) ) then self.Owner:Give("weapon_purple_dildo") end
[/code]
Second one is fixable like that too.
And please, don't implent it exactly like I gave it to you add newlines and tabbing.[/QUOTE]
actually, because the code is being run clientside, it errors on ents.Create because ents.Create is serverside only now, and will error if used on the client.
[code]SERVER or CLIENT[/code] will always evaluate to true.
[QUOTE=skullorz;39037417]actually, because the code is being run clientside, it errors on ents.Create because ents.Create is serverside only now, and will error if used on the client.[/QUOTE]
"Both errors happen in both server and client."
Read first, then post.
[QUOTE=brandonj4;39034132]
[editline]30th December 2012[/editline]
When you Emit the sound, be sure to use:
[code]
if (SERVER) or (CLIENT) then
self:EmitSound("mysound")
end
[/code]
This will make sure that it doesn't emit clientside [B]and [/B]serverside. Makes sense?[/QUOTE]
Yep, but still glitches. (I mean the self:EmitSound("mysound") part, all SWEP Bases I know only need that, and worked fine until now so...)
Edit:
Ok, what the f***, I changed the default HL2 revolver sound to the one I was using on my pistol, and the revolver has now the same glitch... Could it be the .wav file?
Edit 2:
Yep, that fixed it. The .wav file was corrupted and started looping for no reason, making it play endlessly. And it would stack up, making that awkward loop effect.
[QUOTE=brandonj4;39034132]
When you Emit the sound, be sure to use:
[code]
if (SERVER) or (CLIENT) then
self:EmitSound("mysound")
end
[/code]
This will make sure that it doesn't emit clientside [B]and [/B]serverside. Makes sense?[/QUOTE]
Ehm, no it won't. It does the exact opposite.
[QUOTE=ralle105;39040088]Ehm, no it won't. It does the exact opposite.[/QUOTE]
Weird, because that stopped the issue for me back in GM12. Assuming it would work on the current version.
[QUOTE=brandonj4;39040614]Weird, because that stopped the issue for me back in GM12. Assuming it would work on the current version.[/QUOTE]
When it's ran serverside, SERVER = true, CLIENT = false, so SERVER or CLIENT is true. When ran clientside, CLIENT = true, SERVER = false, so SERVER or CLIENT is still true. You may aswell be doing
[lua]
if true then
self:EmitSound("whatever")
end
[/lua]
Which surely you can see is completely redundant?
[QUOTE=Leystryku;39036990]Garry does that to piss some people off.
I think you don't understand the difference between clientside and serverside.
In garrysmod the client is yellow, the server is blue.
Some functions are clientside only, some serverside only and most are shared.
The error you showed means "Create" is a nil value I'm going to assume that you misspelled ents.Create ( You probably wrote ent.Create ) and that's why it gives you that error.
To prevent the first error do it like this:
[code]
if ( SERVER and self.Owner and IsValid(self.Owner) ) then self.Owner:Give("weapon_purple_dildo") end
[/code]
Second one is fixable like that too.
And please, don't implent it exactly like I gave it to you add newlines and tabbing.[/QUOTE]
I did not write the wrong thing, it worked in another swep I made, so I copied it from there. I can do if (SERVER) then, but still... it never worked at all. I need to know how to create a swep from a swep's code.
Even with if (SERVER) then, it doesn't do anything. No errors, but no replacement swep. All it does is remove the current swep.
How can I make one lua file run on the server and another run on the client?
I tried putting them both in lua/autorun but they both ended up running on the client. How can I make one clientside and one serverside?
[QUOTE=>>;39046656]How can I make one lua file run on the server and another run on the client?
I tried putting them both in lua/autorun but they both ended up running on the client. How can I make one clientside and one serverside?[/QUOTE]
[lua]
AddCSLua("autorun/filename.lua")
print("IM ON BOTH SIDES")
if CLIENT then
print("IM CLIENTSIDE")
else
print("IM SVSIDE")
end
[/lua]
So if I add both in autorun, and in the serverside one I add
[lua]if(CLIENT)then return end[/lua]
and if in clientside I add
[lua]if(SERVER)then return end[/lua]
that would work?
[QUOTE=>>;39046810]So if I add both in autorun, and in the serverside one I add
[lua]if(CLIENT)then return end[/lua]
and if in clientside I add
[lua]if(SERVER)then return end[/lua]
that would work?[/QUOTE]
If these files are for the same purpose why not mash them together into one shared file?
I don't know how to explain it other than the way I posted.
[QUOTE=Soleeedus;39009862]thanks, the timer worked. however, ply colors are still a little weird.
[IMG]http://puu.sh/1Gx3M[/IMG]
after holstering the suicide bomb instead of detonating it, the player remains purple unless he uses the suicide bomb, to which he turns red
after using the suicide bomb/round is over, the player respawns. He remains purple, regardless of whether he's t or inno
[IMG]http://puu.sh/1Gx7V[/IMG]
any idea?
[editline]28th December 2012[/editline]
and yes, that's when I used hyperiguana's fix[/QUOTE]
anyone?
[QUOTE=brandonj4;39046870]If these files are for the same purpose why not mash them together into one shared file?
I don't know how to explain it other than the way I posted.[/QUOTE]
They serve two different purposes but work together.
[lua]local function ban(ply,cmd,args)
print("Test")
game.ConsoleCommand("ulx ban "..ply:GetName().." 0 loser")
print(ply:Nick().." was banned for cheating. Nice try.")
end
concommand.Add("_banme", ban)[/lua]
Do you have any idea why this isn't working?
[QUOTE=>>;39047078]They serve two different purposes but work together.
[lua]local function ban(ply,cmd,args)
print("Test")
game.ConsoleCommand("ulx ban "..ply:GetName().." 0 Cheats")
print(ply:Nick().." was banned for cheating. Nice try.")
end
concommand.Add("_catapult", ban)[/lua]
Do you have any idea why this isn't working?[/QUOTE]
[lua]
if SERVER then
local function ban(ply,cmd,args)
print("Test")
game.ConsoleCommand("ulx ban "..ply:GetName().." 0 Cheats")
print(ply:Nick().." was banned for cheating. Nice try.")
end
concommand.Add("_catapult", ban)
end
[/lua]
That should work.
[QUOTE=brandonj4;39047118][lua]
if SERVER then
local function ban(ply,cmd,args)
print("Test")
game.ConsoleCommand("ulx ban "..ply:GetName().." 0 Cheats")
print(ply:Nick().." was banned for cheating. Nice try.")
end
concommand.Add("_catapult", ban)
end
[/lua]
That should work.[/QUOTE]
[lua]if(CLIENT)then return end
AddCSLuaFile("cl_cat.lua")
local function ban(ply,cmd,args)
print("ok")
game.ConsoleCommand("ulx ban "..ply:GetName().." 0 Cheats")
MsgN(ply:Nick().." was banned for cheating. Nice try.")
end
concommand.Add("_catapult", ban)[/lua]
That's the entire file. Would that still have the same effect?
[QUOTE=>>;39047078]They serve two different purposes but work together.
[lua]local function ban(ply,cmd,args)
print("Test")
game.ConsoleCommand("ulx ban "..ply:GetName().." 0 loser")
print(ply:Nick().." was banned for cheating. Nice try.")
end
concommand.Add("_banme", ban)[/lua]
Do you have any idea why this isn't working?[/QUOTE]
Try:
[lua]
concommand.Add("_banme", function(ply,cmd,args)
RunConsoleCommand("ulx","ban",ply:Nick(),0,"loser")
end)
[/lua]
[QUOTE=Hyper Iguana;39047234]Try:
[lua]
concommand.Add("_banme", function(ply,cmd,args)
RunConsoleCommand("ulx","ban",ply:Nick(),0,"loser")
end)
[/lua][/QUOTE]
Thanks, I guess game.ConsoleCommand is just a meanie.
[QUOTE=>>;39047337]Thanks, I guess game.ConsoleCommand is just a meanie.[/QUOTE]
game.ConsoleCommand requires \n at the end of the command:
[lua]
if SERVER then
local function ban(ply,cmd,args)
print("Test")
game.ConsoleCommand("ulx ban "..ply:GetName().." 0 Cheats\n")
print(ply:Nick().." was banned for cheating. Nice try.")
end
concommand.Add("_catapult", ban)
end
[/lua]
[QUOTE=brandonj4;39047439]game.ConsoleCommand requires \n at the end of the command:
[lua]
if SERVER then
local function ban(ply,cmd,args)
print("Test")
game.ConsoleCommand("ulx ban "..ply:GetName().." 0 Cheats\n")
print(ply:Nick().." was banned for cheating. Nice try.")
end
concommand.Add("_catapult", ban)
end
[/lua][/QUOTE]
So why was my method dumb? My method is much more efficient than yours. :v:
Can someone tell me how to open a link in the steam browser? I've seen some servers do it but I thought gui.OpenURL was removed. I apologize if someone's already answered this but I don't feel like browsing 114 pages to find the answer.
It was readded with some added security.
[QUOTE=Teddi Orange;39036629]Could anyone provide a quick example for [url=http://wiki.garrysmod.com/page/Libraries/physenv/AddSurfaceData]AddSurfaceData[/url]? The wiki doesn't exactly explain how the data has to be formatted.[/QUOTE]
^^ Anyone?
[QUOTE=Soleeedus;39047074]anyone?[/QUOTE]
This happens from two things:
1) You did SetColor( r, g, b, a ). It should be SetColor( Color( r, g, b, a ) )
2) You tried changing the alpha without changing the render mode.
If doing entity:SetColor( Color( r, g, b, 100 ) ), prior to that do entity:SetRenderMode(RENDERMODE_TRANSALPHA). You have to do that if setting the alpha under 255.
[QUOTE=Teddi Orange;39049804]^^ Anyone?[/QUOTE]
I *think* it's like this, although it seems silly to use a string like this and not just a table
[code]
"default"
{
"density" "2000"
"elasticity" "0.25"
"friction" "0.8"
"dampening" "0.0"
"stepleft" "Default.StepLeft"
"stepright" "Default.StepRight"
"bulletimpact" "Default.BulletImpact"
"scraperough" "Default.ScrapeRough"
"scrapesmooth" "Default.ScrapeSmooth"
"impacthard" "Default.ImpactHard"
"impactsoft" "Default.ImpactSoft"
"audioreflectivity" "0.66"
"audiohardnessfactor" "1.0"
"audioroughnessfactor" "1.0"
"scrapeRoughThreshold" "0.5"
"impactHardThreshold" "0.5"
"gamematerial" "C"
"jumpfactor" "1.0"
"maxspeedfactor" "1.0"
"climbable" "0"
}[/code]
Sorry, you need to Log In to post a reply to this thread.