[QUOTE=Persious;38129210]Is tmysql4 working on GMod 13?
Whenever I start my server, it crashes when it tries loading the module.[/QUOTE]
Yeah, it's working. Be sure to name it gmsv_tmysql4_win32.dll
Apparently you need another extension.
I'll try re-downloading it.
[editline]21st October 2012[/editline]
I guess I'm doing something wrong, as I still haven't got it working.
It gets to "Loading tmysql module..." then creates two dumps, and SRCDS crashes after.
This is my code, which runs from init.lua just after I include and AddCSLuaFile shared.lua, cl_init.lua and config.lua
[lua]Msg("\nLoading tmysql module...\n")
require("tmysql4")
if (tmysql) then
Msg("Loaded tmysql module... \n")
else
Msg("Failed to load tmysql module... \n")
end
local db, err = tmysql.initialize(BHop.Config["Host"], BHop.Config["Username"], BHop.Config["Password"], BHop.Config["Database"], tonumber(BHop.Config["Port"]))
if db then
print("[MySQL] Connected to SV_DATABASE!\n")
SV_DATABASE = db
else
print("[MySQL] Error connecting to SV_DATABASE:\n")
print(err)
end
db = nil
err = nil
[/lua]
Do I need to have it in a hook or something?
In GM13, I'm trying to code a weapon inventory system, and i'm encountering some diffiiculties getting a table to client, so that the ingame shop will not display items a player already has:
[code]
//for everything in the table of purchaseable items
if(!table.HasValue(glon.decode(LocalPlayer():GetNetworkedString( "Inventory")),v.Ent))then //YES I KNOW, GLON BLASHABBHASDFS
//create icon in the list
[/code]
Long story short, Json didn't seem to work for this, so i put glon into my gamemode files.
The issue is the string length through network variables, how would be a better way to send/receive this information?
Can someone write something that would work?*
Things i have already tried:
-Usermessages/Net(couldn't figure this one out, if you can figure something out, that would be nice)
-Accessing the shared functions for getting the inventory from client
-Console commands
This works just fine, until said string goes above 200 something characters long. The string is cut off, and cannot be read properly, which breaks the entire menu. This data is saved/loaded from text documents via "meta" functions in the player shared code, but i have to use the networked strings for the client to access this.
How else should i go about this?
Help would be gladly appreciated, I've been trying to fix this problem for 3 something hours
Erk. You're gonna have to learn to use umsgs or net, you really are. Have the server store the client's inventory and send updates down to him when necessary, and then when the client displays the shop window it hides the items it already has.
What couldn't you figure out, exactly?
[QUOTE=Luni;38131124]Erk. Never use NW vars if you can help it. Especially not like that. D:
You're gonna have to learn to use umsgs or net, you really are. Have the server store the client's inventory and send updates down to him when necessary, and then when the client displays the shop window it hides the items it already has.[/QUOTE]
I know how to use them, just not in this context, because when it recieved the table, the code would refuse to use it as a variable.
Here's a more detailed version:
[code]
{
Ent= "weapon_magmanade",
Price = 2500
}
//above is an example of an entry in ValidWeapons
for k,v in pairs(ValidWeapons) do
if(!table.HasValue(glon.decode(LocalPlayer():GetNetworkedString( "Inventory")),v.Ent))then
//if(!table.HasValue(LocalPlayer():GetInventory(),v.Ent))then
icon = Product_List:AddLine(weapons.Get(v.Ent).PrintName,v.Price,v.Ent) -- Add lines
icon.DoClick = function( icon )//1st click, doesnt really need to be here, the list buys using the double click hook.
TPrice = v.Price//sets a variable for the menu to use
TEnt = weapons.Get(v[Ent]) //sets a variable for the menu to use
TEntname = v[Ent] //sets a variable for the menu to use
Preview_image:SetText("Buy ".. TName .." for "..TPrice.."$")//Todo:whydoesthisstillexist
Preview_image:SetDisabled( false )//Todo:whydoesthisstillexist
end
end
end
[/code]
[QUOTE=Persious;38129458]I'll try re-downloading it.
[editline]21st October 2012[/editline]
I guess I'm doing something wrong, as I still haven't got it working.
It gets to "Loading tmysql module..." then creates two dumps, and SRCDS crashes after.
This is my code, which runs from init.lua just after I include and AddCSLuaFile shared.lua, cl_init.lua and config.lua
-snip-
Do I need to have it in a hook or something?[/QUOTE]
PM me the dumps please?
PM'd you.
[QUOTE=laynedel;38131212]I know how to use them, just not in this context, because when it recieved the table, the code would refuse to use it as a variable.[/QUOTE]
What do you mean?
Hi, i haven't used lua in a while but i'm trying to modify the scoreboard and I swear I was able to modify gamemode functions in old GMOD. Anyways, this is what I'm trying to do in GMOD 13.
[lua]function GAMEMODE:ScoreboardShow()
print( "Hello World!\n" )
end[/lua]
This is located in [CODE]garry's mod beta\garrysmodbeta\addons\ServerScoreboard\lua\autorun\client[/CODE] so it shouldn't be a problem. The problem is the fact that it says 'GAMEMODE' is a nil value. I've tried with GM instead of GAMEMODE and it's given me the same error.
TL;DR Trying to replace default scoreboard function, don't know how.
[QUOTE=Luni;38134524]What do you mean?[/QUOTE]
I made it so when the menu is opened, the player sends a console command that asks the server to send them the inventory data, i made it so when the information is recieved, it prints the table to console and sets a variable to the table it recieved, I realize my problem now, I have to launch the menu when the player recieves this info.
[code]
[ERROR] gamemodes/rp/gamemode/player.lua:13: attempt to index global 'glon' (a nil value)
[/code] Why am I getting this error? Shouldn't glon be included automatically?
[QUOTE=jaooe;38137751][code]
[ERROR] gamemodes/rp/gamemode/player.lua:13: attempt to index global 'glon' (a nil value)
[/code] Why am I getting this error? Shouldn't glon be included automatically?[/QUOTE]
As far as I remember, no add a require"glon" at the top of the file.
And if you're in garrysmod 13 - Glon is removed in gmod13.
Can you explain this error to me please?
[code]
[ERROR] gamemodes/darkages/entities/entities/npc_arena/init.lua:13: ')' expected near '|'
1. unknown - gamemodes/darkages/entities/entities/npc_arena/init.lua:0
[/code]
Line 13
[lua]
self:CapabilitiesAdd( CAP_ANIMATEDFACE | CAP_TURN_HEAD )
[/lua]
And this one too
[code]
[ERROR] gamemodes/darkages/gamemode/init.lua:65: attempt to call field 'AddNetworkString' (a string value)
1. unknown - gamemodes/darkages/gamemode/init.lua:65
[/code]
Line 65
[lua]
util.AddNetworkString( "huddata" )
[/lua]
[QUOTE=runamagic;38137962]Can you explain this error to me please?
[code]
[ERROR] gamemodes/darkages/entities/entities/npc_arena/init.lua:13: ')' expected near '|'
1. unknown - gamemodes/darkages/entities/entities/npc_arena/init.lua:0
[/code]
Line 13
[lua]
self:CapabilitiesAdd( CAP_ANIMATEDFACE | CAP_TURN_HEAD )
[/lua][/QUOTE]
try using "or" instead "|"
[QUOTE=runamagic;38137962]Can you explain this error to me please?
[lua]
self:CapabilitiesAdd( CAP_ANIMATEDFACE | CAP_TURN_HEAD )
[/lua]
[/lua][/QUOTE]
The bitwise functions | and & were removed, you have to use bit.bor and bit.band instead
[lua]
self:CapabilitiesAdd( bit.bor(CAP_ANIMATEDFACE , CAP_TURN_HEAD ))
[/lua]
Does anybody have a full font list of surface.CreateFont from GMOD12 to GMOD13? It would take a while to recreate just from the res file.
How do you calculate a vector position that's right in front of a entity's angle? so say, it could be used for a cannon that spawns a cannonball right in front of it's barrel, no matter where the cannon is pointing at.
[QUOTE=Aphtonites;38139208]How do you calculate a vector position that's right in front of a entity's angle? so say, if you activate the script, an object would right in front of it.
The answer is probably really simple, but i can't figure it out :suicide:[/QUOTE]
[lua]local pos = ent:GetPos() + ent:GetForward()*10
otherEnt:SetPos(pos)[/lua]
That should set the entity(otherENt) position 10 units in front of ent.
[QUOTE=TOMASAS;38139265][lua]local pos = ent:GetPos() + ent:GetForward()*10
otherEnt:SetPos(pos)[/lua]
That should set the entity(otherENt) position 10 units in front of ent.[/QUOTE]
Oh boy, that works great, thanks!
Does anyone have an updated list of player models for Gmod 13? (if there is one).
Spend The Two Minutes To Find It Yourself Holy Shit The Laziness In This Forum Astounds Me
[QUOTE=Hyper Iguana;38140753]Does anyone have an updated list of player models for Gmod 13? (if there is one).[/QUOTE]
I think it's the same
In GM12 this code works but in GM13 the file isn't made or even detected when I manually make the file to test ( won't delete the file in order to replace it )
[lua]
local id = string.Replace( self:SteamID(), ":", "!" )
local pnts = self:PS_GetPoints()
local items = string.Implode( ",", self.Items )
local data = Format( "%s/%s", pnts, items )
if file.Exists( "pointshop/" .. id .. ".txt", "DATA" ) then
file.Delete( "pointshop/" .. id .. ".txt" )
evolve:Notify( evolve.colors.red, "[DEBUG] " .. id .. " file deleted" )
end
file.Write( "pointshop/" .. id .. ".txt", data )
evolve:Notify( evolve.colors.red, "[DEBUG] " .. id .. " " .. data )
[/lua]
It does print the correct things it's supposed to.
[QUOTE=Jvs;38138438]The bitwise functions | and & were removed, you have to use bit.bor and bit.band instead
[lua]
self:CapabilitiesAdd( bit.bor(CAP_ANIMATEDFACE , CAP_TURN_HEAD ))
[/lua][/QUOTE]
Acutally, or worked instead of | but thank you :)
or is not the same as |
[QUOTE=runamagic;38145430]Acutally, or worked instead of | but thank you :)[/QUOTE]
You only made it return CAP_ANIMATEDFACE with [lua]CAP_ANIMATEDFACE or CAP_TURN_HEAD[/lua], because it'd check if the first one was nil, if it was it'd return the second, and since it wasn't it only returns CAP_ANIMATEDFACE, while you actually want both.
"or" and "and" are not bitwise functions, you need to use bit.bor and bit.band.
Hey, so I've got a table named mapsdata, which outputs:
[lua]
1:
Map = "map name here"
Eggs = 1
EntPos = Vector(0, 0, 0)
[/lua]
How can I get the eggs by using the map name?
I tried doing this: mapsdata.Map['map name here'].Eggs but that didn't work.
[QUOTE=Persious;38148237]Hey, so I've got a table named mapsdata, which outputs:
[lua]
1:
Map = "map name here"
Eggs = 1
EntPos = Vector(0, 0, 0)
[/lua]
How can I get the eggs by using the map name?
I tried doing this: mapsdata.Map['map name here'].Eggs but that didn't work.[/QUOTE]
I don't thing the Map part of what you're trying will work, you have to find it by index or change 1: to something like "mapname":
so mapsdata.["Mapname"].Eggs or something
Well, how could I do that when my table format looks like this:
[lua]
mapsdata = { }
function AddMapData(Map, EntPos, Eggs)
table.insert(mapsdata, {Map = Map, EntPos = EntPos, Eggs = Eggs})
end
[/lua]
[QUOTE=Persious;38148237]Hey, so I've got a table named mapsdata, which outputs:
[lua]
1:
Map = "map name here"
Eggs = 1
EntPos = Vector(0, 0, 0)
[/lua]
How can I get the eggs by using the map name?
I tried doing this: mapsdata.Map['map name here'].Eggs but that didn't work.[/QUOTE]
[lua]
function GetMapByName(str)
if str == nil then return nil end
for k,v in pairs(Maps) do
if v.Map == str then
return v
end
end
return nil
end
[/lua]
I'm guessing that would work?
Sorry, you need to Log In to post a reply to this thread.