[lua]net.WriteString(tostring(ply:Name()..": "..text));[/lua]
When I read it, this returns:
[code]
!2
volksleibstpanzer: yo[/code]
[QUOTE=Commander11;46377786][lua]net.WriteString(tostring(ply:Name()..": "..text));[/lua]
When I read it, this returns:
[code]
!2
volksleibstpanzer: yo[/code][/QUOTE]
Show all related net library usage.
Creating an addon that needs a folder in data.
My structure is basically addonname/data/foldername and addonname/lua
Inside a lua file I have:
[code]
if not file.IsDir( "foldername", "DATA" ) then
error("Data files can't be found!")
end
[/code]
This error occurs even though I have addonname/data/foldername, as stated above, however if I manually move foldername into garrysmod/data, then the error doesn't appear and it seems to be fine
Not really an issue at all, since I can just make the error message say to manually move files, but am I doing something wrong here or is it just gmod being weird?
[QUOTE=NiandraLades;46378140]Creating an addon that needs a folder in data.
My structure is basically addonname/data/foldername and addonname/lua
Inside a lua file I have:
[code]
if not file.IsDir( "foldername", "DATA" ) then
error("Data files can't be found!")
end
[/code]
This error occurs even though I have addonname/data/foldername, as stated above, however if I manually move foldername into garrysmod/data, then the error doesn't appear and it seems to be fine
Not really an issue at all, since I can just make the error message say to manually move files, but am I doing something wrong here or is it just gmod being weird?[/QUOTE]
I guess it's because the DATA path doesn't take into account mounting, try using GAME instead, giving the folder name as "data/foldername"
Leave the data files in garrysmod/data. I don't really see a reason to have it anywhere else.
[QUOTE=Author.;46378481]Leave the data files in garrysmod/data. I don't really see a reason to have it anywhere else.[/QUOTE]
It would work perfectly as long as you're not trying to write files to that specific addon/data folder - file.Write won't let you write anything but .txt files in the garrysmod/data/ folder, but just checking the contents of the addon/data folder using mounted folders should be fine.
[QUOTE=Internet1001;46378517]It would work perfectly as long as you're not trying to write files to that specific addon/data folder - file.Write won't let you write anything but .txt files in the garrysmod/data/ folder, but if you're just checking the contents of the addon/data folder using mounted folders should be fine.[/QUOTE]
.dat files too
Kinda breaks the point of the data folder, though. You're better of leaving it in the addon.
Also you wont be able to upload those custom files to workshop.
[QUOTE=Willox;46377941]Show all related net library usage.[/QUOTE]
Basically:
[lua]net.Receive("SendText", function(length, client)
local typ, name, text = net.ReadString(), net.ReadString(), net.ReadString()
chat.AddText(Color(0, 76, 153), typ, Color(114, 175, 237), name, text);
end);
if !SERVER then return; end
Plugin.Chat = {};
util.AddNetworkString("SendText");
function GM:PlayerSay(ply, text, teamChat)
net.Start("SendText");
net.WriteString("[IC]");
net.WriteString(tostring(ply:Name()));
net.WriteString(": "..text);
net.Send(META:FindPlayersInArea(ply:GetPos(), META.Defaults.Radius.Normal));
return "";
end [/lua]
Just a really quick question, is there an up-to-date round based gamemode base? Been searching and all I could find was outdated fretta. Will I just have to make my own round functions? I probably have not searched enough..
Hmm. I'm adding an addition to a medal system im making and I needed to network the player death hook so I could run some client side code. Its giving me this: [code] attempt to index local 'pl' (a nil value) [/code]
[B]Serverside[/B]
[code]
util.AddNetworkString("NetDeath") --not very creative ://
hook.Add("PlayerDeath", "NetTheMedal", function(pl)
net.Start("NetDeath")
net.Send(pl)
end)
[/code]
[B]Clientside:[/B]
[code]
net.Receive("NetDeath", function(len, pl)
if pl:IsValid() and pl:IsPlayer() then
AddNewMedal("Medal Unlocked", "gun_menu/combatribbon.png", 250, 84, "gun_menu/ribboneffect.wav")
end
end)
[/code]
net.Send only takes one argument which is the Entity to send the networked information to.
[editline]1st November 2014[/editline]
Aaand you just edited it out :v:
Yeah sorry >_< pasted older code and changed it
[QUOTE=_Entity;46380521]Yeah sorry >_< pasted older code and changed it[/QUOTE]
You are using net library wrong
[url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
[editline]31st October 2014[/editline]
How do I call stuff like this from another lua file?
[code]
local ROUNDS = {}
ROUNDS.round = 0
function ROUNDS.CurrentRound()
return self.round
end
function ROUNDS.Begin()
PrintMessage( HUD_PRINTTALK, "Round " .. self.round .. " has begun." )
end
[/code]
It's just a bit of code for an example, how would I call or access it's variables and functions from another file?
-snip. Completely misread!
[QUOTE=_Entity;46380589]you could use net.WriteTable(ROUNDS.round) and send the table index "round" which will be the current round im sure ?[/QUOTE]
What? No?
I want to call functions from this file from another lua file? Why would I use net?
Remove the local?..
[QUOTE=Author.;46380756]Remove the local?..[/QUOTE]
Oh, it appears the file isn't being included properly, I tried that before, that was my first guess, but I think it's just a bug with something else in my code, thanks.
I'm an idiot, I had that file saved in a different gamemode -_-
[QUOTE=AnonTakesOver;46380702]What? No?
I want to call functions from this file from another lua file? Why would I use net?[/QUOTE]
Oh right I misread badly, my apologies! One last thing, How can you check if a player is in a certain area?
Question: Can i call a hook inside another hook? like, on PlayerSpawn call another hook
In pointshop, by _Undefined I only have one model that works and the rest are errors... Could I please have a fix to this?..
[QUOTE=|Legion|;46381465]In pointshop, by _Undefined I only have one model that works and the rest are errors... Could I please have a fix to this?..[/QUOTE]
Are you sure the model is the right one and you have all of them downloaded? check again the ITEM.Model thing, make sure you type .mdl instead of .mld
[QUOTE=Scarface3353;46381459]Question: Can i call a hook inside another hook? like, on PlayerSpawn call another hook[/QUOTE]
Yes you can. Depending on the context use [URL="http://wiki.garrysmod.com/page/gamemode/Call"]gamemode.Call[/URL] or [URL="http://wiki.garrysmod.com/page/hook/Call"]hook.Call[/URL]
[QUOTE=Scarface3353;46381488]Are you sure the model is the right one and you have all of them downloaded? check again the ITEM.Model thing, make sure you type .mdl instead of .mld[/QUOTE]
Made sure, still errors...
[QUOTE=|Legion|;46381506]Made sure, still errors...[/QUOTE]
May i see the .lua of any of the errors?
How do I cancel the sounds of a certain player, like walking and swimming etc?
-snip- nevermind, found something better
[QUOTE=Scarface3353;46381519]May i see the .lua of any of the errors?[/QUOTE]
.lua of any of the errors?
[QUOTE=AnonTakesOver;46381560]How do I cancel the sounds of a certain player, like walking and swimming etc?[/QUOTE]
Not sure if it works for swimming, but this works for walking and such.
[url]http://wiki.garrysmod.com/page/GM/PlayerFootstep[/url]
Sorry, you need to Log In to post a reply to this thread.