[QUOTE=Hyper Iguana;39074995]It's not accessible on the client if you're doing it on the server. Use net to send the information to the client.[/QUOTE]
[QUOTE=.\\Shadow};39074991]You'll have to network it yourself if you want to access it like that.[/QUOTE]
[QUOTE=thomasfn;39074997]Unfortunately, variables set on the player object serverside don't magically get synced to the client. Look into using the net library. You'll need to send a net message containing the inventory every time it changes to the player.
[/QUOTE]
Thanks guys! I didn't realise I had to use net :)
[QUOTE=RattSplat;39074263]Need help changing death sounds such as in TTT. Heres what I've got:
[lua]
local deathsounds = {
Sound("player/death1.wav"),
Sound("player/death2.wav"),
Sound("player/death3.wav"),
Sound("player/death4.wav"),
Sound("player/death5.wav"),
Sound("player/death6.wav"),
Sound("vo/npc/male01/pain07.wav"),
Sound("vo/npc/male01/pain08.wav"),
Sound("vo/npc/male01/pain09.wav"),
Sound("vo/npc/male01/pain04.wav"),
Sound("vo/npc/Barney/ba_pain06.wav"),
Sound("vo/npc/Barney/ba_pain07.wav"),
Sound("vo/npc/Barney/ba_pain09.wav"),
Sound("vo/npc/Barney/ba_ohshit03.wav"), --heh
Sound("vo/npc/Barney/ba_no01.wav"),
Sound("vo/npc/male01/no02.wav"),
Sound("hostage/hpain/hpain1.wav"),
Sound("hostage/hpain/hpain2.wav"),
Sound("hostage/hpain/hpain3.wav"),
Sound("hostage/hpain/hpain4.wav"),
Sound("hostage/hpain/hpain5.wav"),
Sound("hostage/hpain/hpain6.wav")
};
local function PlayDeathSound(victim)
if not IsValid(victim) then return end
sound.Play(table.Random(deathsounds), victim:GetShootPos(), 90, 100)
end
-- kill hl2 beep
function DR:PlayerDeathSound() return true end
[/lua][/QUOTE]
Bump
Can you use MySQLoo on a server shutdown? I'm calling my save profile function but it doesn't execute the mysqloo section.
[CODE]function SaveProfile(pl)
-- Connect to the database --
print("Save")
local db = mysqloo.connect(SQLIP, SQLUSER, SQLPASS, SQLDB, SQLPORT)
function db:onConnected()
local steamID = pl:SteamID()
print("Save2")
local q = self:query("SELECT * FROM profiles WHERE steamID='"..steamID.."' LIMIT 1")
... ect[/CODE]
[CODE]
function ServerShutDown()
for k, pl in pairs(player.GetAll()) do
local Refund = 0
for k,v in pairs(ents.GetAll()) do
Refund = Refund + RefundProp(v,pl)
end
pl:SetNWInt("cash", math.floor(2000000000))
SaveProfile(pl)
end
end
hook.Add("ShutDown", "ServerShutDown", ServerShutDown)[/CODE]
It prints out Save but not Save2. I can also print out db. And I checked the function db:onConnectionFailed(err) and that's doesn't get called, it just stops. Any work arounds for this would be appreciated as i don't want to scrap using mysqloo. I'm enjoying the ease of use besides this.
Connecting to a database isn't instant. By the time it would have connected, the server has already shut down.
Not to mention that ShutDown isn't called when the server crashes, save their profile when it changes instead
I've created some explosive weapons but the damage done doesn't show up in the damage logs.. How do I set this up to work properly?
[QUOTE=RattSplat;39075833]Bump[/QUOTE]
What's actually wrong with that?
Is there a way to hook into when a network value is synchronised? By network value I mean a value assigned with ent:SetNWWhatever().
Ive been having suicidal thoughts ....:suicide:
[QUOTE=applejacks;39078827]Ive been having suicidal thoughts ....:suicide:[/QUOTE]
If you commit suicide your life will never improve. As long as you are alive there is the chance that things will get better. Why throw that away?
[SUB][SUB][SUB]Also wrong thread[/SUB][/SUB][/SUB]
[QUOTE=applejacks;39078827]Ive been having suicidal thoughts ....:suicide:[/QUOTE]
[url]http://www.suicidehotlines.com/[/url]
Alright is there a way to see if a table is equal to another one? Like if it has all the same values? I have a crafting system that uses 9 slots and I'm trying to see if all 9 match.
[QUOTE=jrj996;39079071]Alright is there a way to see if a table is equal to another one? Like if it has all the same values? I have a crafting system that uses 9 slots and I'm trying to see if all 9 match.[/QUOTE]
[lua]function table.IsEqual(this, that)
if table.Count(this) ~= table.Count(that) then
return false
end
for k, v in pairs(this) do
if v ~= that[k] then
return false end
end
end
return true
end[/lua]
This bunch of code just keeps repeating itself when opening up srcds.exe, it's like it never stops and the server doesn't go on. It just keeps repeating.
[code]
http://pastebin.com/NKynnk0u
[/code]
[QUOTE=Ziks;39079132][lua]function table.IsEqual(this, that)
if table.Count(this) ~= table.Count(that) then
return false
end
for k, v in pairs(this) do
if v ~= that[k] then
return false end
end
end
return true
end[/lua][/QUOTE]
Thanks mate!
Alright well actually now I'm having another problem, it's discovering all of them but it's not stopping and going on to the next one(Which is making it say only 1 works.), I'm not that great with the advanced things in loops, so I'm not sure how to break out once it does find it, any ideas? :v
Here's the code
[lua]
for k,v in pairs(global_recipes) do
if table.IsEqual(craftSlots,v.Slots) then
curRecipe = v.Output
bCraft:SetVisible(true)
bCraft:SetGText("Craft "..curRecipe.."?")
else
bCraft:SetVisible(false)
curRecipe = "Unknown"
end
end
[/lua]
nevermind, I found a way to fix it:
[lua]
for k,v in pairs(global_recipes) do
if table.IsEqual(craftSlots,v.Slots) then
curRecipe = v.Output
bCraft:SetVisible(true)
bCraft:SetGText("Craft "..curRecipe.."?")
break
else
bCraft:SetVisible(false)
curRecipe = "Unknown"
end
end
[/lua]
[QUOTE=kingen50cent;39079140]This bunch of code just keeps repeating itself when opening up srcds.exe, it's like it never stops and the server doesn't go on. It just keeps repeating.
[code]-snip-[/code][/QUOTE]
Could you maybe put that in [url=http://pastebin.com/]pastebin[/url] or something and edit your post to have the link instead of all that text? My scroll wheel is getting pretty worn.
[QUOTE=Ziks;39079228]Could you maybe put that in [url=http://pastebin.com/]pastebin[/url] or something and edit your post to have the link instead of all that text? My scroll wheel is getting pretty worn.[/QUOTE]
Done!
-snip-
[CODE]matPlayer = Material("models/humans/male/group01/citizen_sheet")
matPlayer:SetTexture("$basetexture", Material("models/player/uniform"):GetTexture("$basetexture"))
matPlayer:SetInt("$blendtintbybasealpha", 1)[/CODE]
This used to work during the beta, not sure what's wrong with it now. Anyone have any ideas?
[QUOTE=Drakehawke;39079305]you should check that there's nothing in that that's in this too, also you have an extra end
[lua]function table.IsEqual(this, that)
if table.Count(this) ~= table.Count(that) then
return false
end
for k, v in pairs(this) do
if v ~= that[k] then return false end
end
for k, v in pairs(that) do
if v ~= this[k] then return false end
end
return true
end[/lua][/QUOTE]
I was assuming that table.Count didn't count nil values, since if it didn't then you only need to loop through one.
I was also hoping that the extra end would lead to the asker getting an error and reading through the code to fix it themselves.
[QUOTE=Ziks;39079443]I was assuming that table.Count didn't count nil values, since if it didn't then you only need to loop through one.
I was also hoping that the extra end would lead to the asker getting an error and reading through the code to fix it themselves.[/QUOTE]
Oh yeah good point, but infact it would be [b]technically[/b] more efficient to ditch the table.Count part and use just the two loops, 3 loops vs 2.
[QUOTE=cardboardtheory;39068842]So I did some edits to this [URL="http://facepunch.com/showthread.php?t=1209676"]code[/URL], namely removing the gm in front of the functions, changing the font to default, and removing some extra code that seemed only specific to that gamemode.
The only error I've seen in the console so far was about the gm nil value, but after removing gm from every function, that problem seems to have been solved. Now, there's simply no reference to the code at all: all that shows up in gmod is the default HUD.
Here's the code:
[CODE]paraHud = {};
paraHud.SUPER_SIZE = 0.05/2; -- 3D Hud Scale (Def: 0.05)
paraHud.SUPER_DISTANCE = 25/2; -- 3D Hud Distance (Def: 25)
paraHud.SUPER_ANGLE = 20; -- 3D Hud Angle (Def: 20)
paraHud.SUPER_COLOR = Color(229, 178, 85, 255);
paraHud.ScreenWidth = 0;
paraHud.ScreenHeight = 0;
paraHud.ScreenFOV = 0;
-- 15 DEGREES
-- 16:9 FOV90 (2/2/1) 0.4 DIFF
-- 16:9 FOV75 (2.4/2/1)
-- 16:10 FOV90 (2.15/2/1) 0.45 DIFF
-- 16:10 FOV75 (2.6/2/1)
-- 4:3 FOV90 (2.6/2/1) 0.55 DIFF
-- 4:3 FOV75 (3.15/2/1)
function HUDPaint()
--paraHud.Health();
--paraHud.Need();
--paraHud.Test3D();
paraHud.CheckDimensions();
-- Draw 3D Hud
cam.Start3D(EyePos(), EyeAngles())
--paraHud.SuperHud();
cam.End3D()
--paraHud.GetPlayerInfo();
end
function HUDShouldDraw(name)
local draw = true;
if(name == "CHudHealth" or name == "CHudBattery" or name == "CHudAmmo" or name == "CHudSecondaryAmmo") then
draw = false;
end
return draw;
end
function paraHud.CheckDimensions()
local width = ScrW();
local height = ScrH();
local fov = LocalPlayer():GetFOV();
if(paraHud.ScreenWidth ~= width or paraHud.ScreenHeight ~= height or (fov >= 75 and paraHud.ScreenFOV ~= fov)) then
paraHud.ChangeRatios(width, height, fov);
end
return;
end
function paraHud.ChangeRatios(width, height, fov)
local fovDiff = fov - 75;
if(width / height == 16 / 9) then
paraHud.SUPER_SIZE = 0.05 / (2.4 - 0.4 * (fovDiff / 15));
print("Changed to 16:9 mode!");
elseif(width / height == 16 / 10) then
paraHud.SUPER_SIZE = 0.05 / (2.6 - 0.45 * (fovDiff / 15));
print("Changed to 16:10 mode!");
else
paraHud.SUPER_SIZE = 0.05 / (3.15 - 0.55 * (fovDiff / 15));
print("Changed to 4:3 mode!");
end
paraHud.ScreenWidth = width;
paraHud.ScreenHeight = height;
paraHud.ScreenFOV = fov;
return;
end
function paraHud.Health3D(pl, pos, ang)
local health = pl:Health();
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 );
draw.DrawText(health, "default", -440*4, 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER );
cam.End3D2D();
surface.SetFont("default");
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 );
draw.DrawText("/100", "default", (-440*2)+(surface.GetTextSize(health)/2), 194*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER );
draw.DrawText("Alien Host", "default", -440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER );
cam.End3D2D();
return;
end
function paraHud.Weapon3D(pl, pos, ang)
local weapon = pl:GetActiveWeapon();
if(weapon ~= nil) then
local weaponType = weapon:GetPrintName();
local weaponMag = weapon:Clip1();
local weaponAmmo = pl:GetAmmoCount(weapon:GetPrimaryAmmoType());
if(weaponMag < 0) then
if(weaponAmmo > 0) then
-- Basic
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 );
draw.DrawText(weaponAmmo, "default", 440*4, 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER );
cam.End3D2D();
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 );
draw.DrawText(weaponType, "default", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER );
cam.End3D2D();
else
-- Melee
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 );
draw.DrawText(weaponType, "default", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER );
cam.End3D2D();
end
elseif(weaponAmmo < 1 and weaponMag < 1) then
-- No Ammo
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 );
draw.DrawText(weaponType, "default", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER );
cam.End3D2D();
else
-- Full
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 );
draw.DrawText("/"..weaponAmmo, "default", 440*2, 194*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER );
draw.DrawText(weaponType, "default", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER );
cam.End3D2D();
surface.SetFont("default");
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 );
draw.DrawText(weaponMag, "default", (440*4)-(surface.GetTextSize("/"..weaponAmmo)*2), 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER );
cam.End3D2D();
end
end
return;
end
function paraHud.Need3D(pl, pos, ang)
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/(4*1.1) );
draw.DrawText("KILL", "default", -460*4, -257*4, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP );
cam.End3D2D();
surface.SetFont("default");
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/(2*1.1) );
draw.DrawText("10x", "default", (-458*2)+(surface.GetTextSize("PISS")/2), -255*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP );
draw.DrawText("Need", "default", -460*2, -270*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP );
cam.End3D2D();
end
function paraHud.Inventory3D(pl, pos, ang)
cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 );
draw.DrawText("1234567890", "default", 0, 300*4, paraHud.SUPER_COLOR, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER );
surface.SetDrawColor(paraHud.SUPER_COLOR);
surface.DrawLine(-200*4, 285*4, 200*4, 285*4); -- Top
surface.DrawLine(-200*4, 360*4, 200*4, 360*4); -- Bottom
surface.DrawLine(-200*4, 285*4, -200*4, 360*4); -- Left
surface.DrawLine(200*4, 285*4, 200*4, 360*4); -- Right
cam.End3D2D();
return;
end
function paraHud.SuperHud()
local pl = LocalPlayer();
local plAng = EyeAngles();
local plPos = EyePos();
local pos = plPos;
local centerAng = Angle(plAng.p, plAng.y, 0);
pos = pos + (centerAng:Forward() * paraHud.SUPER_DISTANCE);
centerAng:RotateAroundAxis( centerAng:Right(), 90 );
centerAng:RotateAroundAxis( centerAng:Up(), -90 );
local leftAng = Angle(centerAng.p, centerAng.y, centerAng.r);
local rightAng = Angle(centerAng.p, centerAng.y, centerAng.r);
leftAng:RotateAroundAxis( leftAng:Right(), paraHud.SUPER_ANGLE*-1 );
rightAng:RotateAroundAxis( rightAng:Right(), paraHud.SUPER_ANGLE );
local centerAngUp = Angle(plAng.p, plAng.y, 0);
centerAngUp:RotateAroundAxis( centerAngUp:Right(), 98 );
centerAngUp:RotateAroundAxis( centerAngUp:Up(), -90 );
local leftAngUp = Angle(centerAngUp.p, centerAngUp.y, centerAngUp.r);
local rightAngUp = Angle(centerAngUp.p, centerAngUp.y, centerAngUp.r);
leftAngUp:RotateAroundAxis( leftAngUp:Right(), paraHud.SUPER_ANGLE*-1 );
rightAngUp:RotateAroundAxis( rightAngUp:Right(), paraHud.SUPER_ANGLE );
if(pl:Alive() == true and pl:Health() > 0) then
cam.Start3D(plPos, plAng);
cam.IgnoreZ(true);
paraHud.Health3D(pl, pos, leftAng);
paraHud.Weapon3D(pl, pos, rightAng);
paraHud.Need3D(pl, pos, leftAngUp);
paraHud.Time3D(pl, pos, rightAngUp);
Hello Lua coders of Facepunch. How would I go about using ApplyForceOffset (or a similar forcing function, I really don't know) to force an entity to reach a specific angle? Normally I would have just used SetAngles but the entity I'm working on is forced around with ApplyForceCenter (for movement, not angles) and when the code sets the entity's angles the entity comes to a jerking halt, making the entity slow to move and derpy looking.
[QUOTE=.\\Shadow};39076022]Connecting to a database isn't instant. By the time it would have connected, the server has already shut down.[/QUOTE]
So I got mad at this last night and decided to go to bed. In the middle of the night i woke up with an epiphany... wait. So if anyone else is having this issue it is possible to run mysqloo at server shut down with DB:wait().
[QUOTE=Ziks;39078800]Is there a way to hook into when a network value is synchronised? By network value I mean a value assigned with ent:SetNWWhatever().[/QUOTE]
Sorry for reposting, but it was right at the end of last page so maybe no-one saw it.
I would like to make a police Siren Script, but i dont really know where to start
Well, i know how the PERP Lightning system works, but as you maybe know, the Colours gets mixxed, when 2 Lightsources are nearby....
Maybe someon can give me a point, where to start?
//Edit: Still need a example of a cam3D2D browser pls :)
I have this code and I was wondering how I would call it from the client. WOuld it just be LocalPlayer():GetItems()? When I tried that it just gave me this error.
[QUOTE][ERROR] addons/tokenshop/lua/autorun/client/cl_vgui.lua:180: attempt to call method 'GetItems' (a nil value)
1. LoadA - addons/tokenshop/lua/autorun/client/cl_vgui.lua:180
2. DoClick - addons/tokenshop/lua/autorun/client/cl_vgui.lua:125
3. unknown - lua/vgui/dlabel.lua:206[/QUOTE]
[lua]
local pm = FindMetaTable( "Player" )
if not pm then return end
function pm:GetItems( )
tmysql.query("SELECT * FROM inventory WHERE steamid = '" .. self:SteamID() .. "'", function(inventory)
if self.CurrentModel == nil then self.CurrentModel = "Phoenix" end
self.Inventory = {}
for k,v in pairs(inventory) do
name = inventory[k]["iname"]
itype = inventory[k]["type"]
equipped = inventory[k]["equipped"]
table.insert(self.Inventory, name)
if equipped and itype == "model" then
self.CurrentModel = name
-- self:EquipItem(name, itype)
end
end
itemcount = table.Count(self.Inventory)
end, 1)
net.Start("Info")
net.WriteTable(self.Inventory)
net.Send(self)
end
[/lua]
I've been trying to fix Garry's Mod Racer up to work with Garry's Mod 13, however I ran into a problem when I tried to change ValidEntity to IsValid.
[QUOTE][ERROR] gamemodes/gmodracer/gamemode/cl_misc.lua:54: attempt to call method 'GetScriptedVehicle' (a nil value)
1. unknown - gamemodes/gmodracer/gamemode/cl_misc.lua:54[/QUOTE]
And right here is the conflicting code that was taken directly from the Garry's Mod wiki back in GM12.
[CODE] local ScriptedVehicle = ply:GetScriptedVehicle()
if ( IsValid( ScriptedVehicle ) ) then
local view = ScriptedVehicle.CalcView( ScriptedVehicle:GetTable(), ply, origin, angles, fov )
if ( view ) then return view end
end[/CODE]
The code is part of the GM:CalcView( ply, origin, angles, fov ) function. Any help would be appreciated.
[QUOTE=Bl00dyhell9;39083788]I've been trying to fix Garry's Mod Racer up to work with Garry's Mod 13, however I ran into a problem when I tried to change ValidEntity to IsValid.
And right here is the conflicting code that was taken directly from the Garry's Mod wiki back in GM12.
[CODE] local ScriptedVehicle = ply:GetScriptedVehicle()
if ( IsValid( ScriptedVehicle ) ) then
local view = ScriptedVehicle.CalcView( ScriptedVehicle:GetTable(), ply, origin, angles, fov )
if ( view ) then return view end
end[/CODE]
The code is part of the GM:CalcView( ply, origin, angles, fov ) function. Any help would be appreciated.[/QUOTE]
[lua]
local meta = FindMetaTable( "Player" )
if meta then
function meta:GetScriptedVehicle()
return self:GetNetworkedEntity( "ScriptedVehicle", NULL )
end
function meta:SetScriptedVehicle( veh )
self:SetNetworkedEntity( "ScriptedVehicle", veh )
self:SetViewEntity( veh )
end
end
[/lua]
Put that in shared.lua
Sorry, you need to Log In to post a reply to this thread.