Hello again. I'm still having a problem with this NPC script. I'm trying to add NPCs based on standard rebel AI but I have them use all 9 male models. Another set has extra males up to 11
This [I]should[/I] make it so a random model is selected when one is spawned, but it just says it's unable to find the model in the console.
[code]
local NPC = {
Name = "Rebel Trooper Captain",
Class = "npc_citizen",
Model = "models/SGG/Starwars/Rebels/r_trooper_captain/male_01.mdl",
Category = Category,
SpawnFlags = SF_CITIZEN_RANDOM_HEAD,
KeyValues = { citizentype = CT_REBEL, trooper_captain = 1 },
Weapons = { "weapon_pistol", "weapon_ar2", "weapon_smg1", "weapon_ar2", "weapon_shotgun" }
}
list.Set( "NPC", "Rebel_trooper_captain", NPC )
hook.Add("PlayerSpawnedNPC", "trooper_captain_initmodel", function(pl, npc)
if IsValid(npc) then
local keyValues = npc:GetKeyValues()
if keyValues["trooper_captain"] then
local nTrooper = tonumber(keyValues["trooper_captain"])
if nTrooper == 1 then
npc:SetModel("models/SGG/Starwars/Rebels/r_trooper_captain/male0" .. math.random(1,9) .. ".mdl")
end
end
end
end)
local NPC = {
Name = "Rebel Soldier (Forest)",
Class = "npc_citizen",
Model = "models/SGG/Starwars/Rebels/r_soldier_forest/male_01.mdl",
Category = Category,
SpawnFlags = SF_CITIZEN_RANDOM_HEAD,
KeyValues = { citizentype = CT_REBEL, trooper_soldier_forest = 1 },
Weapons = { "weapon_pistol", "weapon_ar2", "weapon_smg1", "weapon_ar2", "weapon_shotgun" }
}
list.Set( "NPC", "Rebel_soldier_forest", NPC )
hook.Add("PlayerSpawnedNPC", "soldier_forest_initmodel", function(pl, npc)
if IsValid(npc) then
local keyValues = npc:GetKeyValues()
if keyValues["soldier_forest"] then
local nTrooper = tonumber(keyValues["soldier_forest"])
if nTrooper == 1 then
local nRand = math.random(1,11)
npc:SetModel("models/SGG/Starwars/Rebels/r_soldier_forest/male" .. (nRand < 10 && "0" || "") .. nRand .. ".mdl")
end
end
end
end)
[/code]
[editline]20th February 2016[/editline]
Also, Is it possible to do something similar to this, like say, use combine AI, but have them friendly and use custom sounds?
Looking for a fix for TTT Pointshop skins [U]resetting on round start[/U].
Skins would reset visually if you were alive when the round started (But if you had died / killed yourself during the pre-round it would spawn you in with the skin) would tend to have players have to suicide if they didnt want to un-equip and re-equip the skin manually every time.
This was an odd issue given some skins would have the issues while other times it would randomly select a player and would mess it up for them only.
The skin I would have consistant results on was the TDA Snow Miku skin which is here: [url]http://steamcommunity.com/sharedfiles/filedetails/?id=561431680[/url]
And the pointshop code for it being [CODE]ITEM.Name = 'Snow Miku'
ITEM.Price = 750000
ITEM.Model = 'models/captainbigbutt/vocaloid/tiku_classic.mdl'
function ITEM:OnEquip(ply, modifications)
if not ply._OldModel then
ply._OldModel = ply:GetModel()
end
timer.Simple(1, function()
ply:SetModel(self.Model)
ply:SetSkin(modifications.group or 0)
ply:SetSkin(modifications.group or 0)
ply:SetSkin(modifications.group or 0)
end)
end
function ITEM:OnHolster(ply)
if ply._OldModel then
ply:SetModel(ply._OldModel)
end
end
function ITEM:Modify(modifications)
Derma_Query("Choose Bodygroup", "",
"Normal", function()
modifications.group = 0
PS:SendModifications(self.ID, modifications)
end,
"All White", function()
modifications.group = 1
PS:SendModifications(self.ID, modifications)
end,
"Normal w/ Glow", function()
modifications.group = 2
PS:SendModifications(self.ID, modifications)
end,
"White w/ Glow", function()
modifications.group = 3
PS:SendModifications(self.ID, modifications)
end)
print("modify")
end
function ITEM:OnModify(ply, modifications)
self:OnHolster(ply)
self:OnEquip(ply, modifications)
end[/CODE]
Have latest pointshop 1 vers and TTT off of their github as a before mention.
Have tried using the hook "TTTBeginRound" and when called would reset the skins just as PS would.
v is in sv_player_extension.lua at row 15
[lua]timer.Simple(1, function()
if !IsValid(self) then return end
for item_id, item in pairs(self.PS_Items) do
local ITEM = PS.Items[item_id]
if item.Equipped then
ITEM:OnEquip(self, item.Modifiers)
end
end
end)
[/lua]
Found the problem being that TTT would recall the spawn command in GarrysMod\garrysmod\gamemodes\terrortown\gamemode 's init.lua on row 651
[lua]SpawnWillingPlayers(true)[/lua]
Then call the "TTTBeginRound" hook lower down, Have tried a few things yet am now seemingly stuck, not experienced enough with lua to find a solution.
Really hope to find a solution here and hope I provided enough information. Thanks for reading and for the help in advance!
This is more of a server issue, but I don't know where to post about this.
I'm trying to make my server automatically run these commands when it starts because I can't figure out how to save settings for the simple prop damage addon. I already put these inside of a lua file in the /lua/autorun/server/ folder and it still doesn't work.
[lua]
spd_prophealth 2.5
spd_colorfade_r 0
spd_colorfade_b 0
spd_colorfade_g 0
spd_physicsdamage 0
spd_bulletdamage 0
spd_explosiondamage 0
spd_unfreeze 0
spd_removeconstraints 0
spd_health_weightratio 1
spd_health_volumeratio 1
[/lua]
I'm able to run all of these commands in the server's console and everything works out fine, but whenever I reset, it just goes back to the addon's default configuration.
[QUOTE=.Vel;49782485]This is more of a server issue, but I don't know where to post about this.
I'm trying to make my server automatically run these commands when it starts because I can't figure out how to save settings for the simple prop damage addon. I already put these inside of a lua file in the /lua/autorun/server/ folder and it still doesn't work.
[lua]
spd_prophealth 2.5
spd_colorfade_r 0
spd_colorfade_b 0
spd_colorfade_g 0
spd_physicsdamage 0
spd_bulletdamage 0
spd_explosiondamage 0
spd_unfreeze 0
spd_removeconstraints 0
spd_health_weightratio 1
spd_health_volumeratio 1
[/lua]
I'm able to run all of these commands in the server's console and everything works out fine, but whenever I reset, it just goes back to the addon's default configuration.[/QUOTE]
you want to put them inside the server.cfg or autoexec.cfg inside your cfg folder
[QUOTE=skullorz;49782504]you want to put them inside the server.cfg or autoexec.cfg inside your cfg folder[/QUOTE]
It seems super obvious after you say that. Thanks a ton for the help.
[CODE] if ( self.Owner:HasWeapon( self.Data.Class ) ) then
local weap = ents.Create( self.Data.Class )
weap:SetPos( self.Owner:TraceFromEyes( 100 ).HitPos + Vector( 0, 0, 15 ) )
if(self.Owner.lastWep ~= nil)then
self.Owner.lastWep:Remove()
self.Owner.lastWep = nil
end
weap:Spawn()
weap:SetNWEntity("Owner",self.Owner)
self.Owner.lastWep = weap
SPropProtection.PlayerMakePropOwner( self.Owner, weap )
hook.Add("WeaponEquip", function(weapon)
timer.Simple(0, function()
local ply = weapon:GetOwner()
print("This has run!")
ply:PrintMessage(3, "Picked Up: "..weapon:GetClass())
local Owner = weapon:GetNWEntity("Owner")
Owner.lastWep = nil
end)
end)
else
self.Owner:Give( self.Data.Class )
end
for k, v in pairs( self.Data.Cost ) do
self.Owner:DecResource( k, v )
end
end[/CODE]
The code does its job more or less. Making a new weapon will remove any older weapons that have been crafted. However it should only do that if said weapons haven't been picked up by a player. Currently the weapon gets removed from the inventory if a new one is crafted. I only want it to remove any weapons that haven't been picked up at the time of a new one being crafted.
Can anyone tell me how to stop it from removing crafted items from people's inventory?
After some more testing, it seems it doesn't run the hook at all. Anyone know why that is?
[QUOTE=JasonMan34;49778541](Off topic)
You seem to have quite a long list of elseif statements, and a lot of repetitive commands with different variables inside.
You might wanna take a look at [URL="https://facepunch.com/showthread.php?t=1504473"]this[/URL] thread, you can make 84 lines into 20 or less (And it wouldn't require as much effort when adding chat commands)[/QUOTE]
Thanks, that works perfectly!
Is there a reliable hook that I can use on clients that is called when they switch weapons?
I don't know why SWEP:Deploy() doesn't always work but I need to set properties on a gun when it's being deployed.
I tried the OnViewModelChanged hook but it seems to also not get called when SWEP:Deploy() doesn't get called.
I also tried SWEP:CallOnClient("Deploy"), but the corresponding call on the client is delayed (by ping), so that Think() might be called before Deploy() is, thus causing lua errors in my script.
Quick question that's been annoying me to no end: Is there any way to draw other players when you're spectating them through OBS_MODE_IN_EYE? I want to use CalcView to move the camera's position behind the players and they aren't rendering. I could use OBS_MODE_FIXED but I'd rather not have to write a bunch of extra code. I've tried overwriting GM:ShouldDrawLocalPlayer but that didn't help.
I have a string that contains this:
[code]world
{
"id" "1"
"mapversion" "0"
"classname" "worldspawn"
"skyname" "sky_day01_01"
"maxpropscreenwidth" "-1"
"detailvbsp" "detail.vbsp"
"detailmaterial" "detail/detailsprites"
}[/code]
I want to replace sky_day01_01 with something else, but sky_day01_01 could be anything.
It is always after "skyname" though.
How would I do this without converting it to a table, because its from a vmf and the 2 I'm looking at right now have over 200,000 lines
I'm trying to apply a png as material on a car but I can't quite seem to get it right.
This ran on the client
[lua]
-- veh is the vehicle
local imat, num = Material('data/bugatti.png', 'vertexlitgeneric')
veh:SetSubMaterial(0, '!'..imat:GetName())
[/lua]
Produces this:
[t]https://i.gyazo.com/4ba88c3206ad77e7a9cd90bf024b4679.png[/t]
Any suggestions?
[QUOTE=highvoltage;49785188]I have a string that contains this:
[code]world
{
"id" "1"
"mapversion" "0"
"classname" "worldspawn"
"skyname" "sky_day01_01"
"maxpropscreenwidth" "-1"
"detailvbsp" "detail.vbsp"
"detailmaterial" "detail/detailsprites"
}[/code]
I want to replace sky_day01_01 with something else, but sky_day01_01 could be anything.
It is always after "skyname" though.
How would I do this without converting it to a table, because its from a vmf and the 2 I'm looking at right now have over 200,000 lines[/QUOTE]
[url=http://wiki.garrysmod.com/page/Patterns]Patterns.[/url]
[QUOTE=GGG KILLER;49785418][URL="http://wiki.garrysmod.com/page/Patterns"]Patterns.[/URL][/QUOTE]
Thanks, I'll see what I can come up with.
[del]New question, does duplicator.WorkoutSize() simple not work or am i doing something wrong? It always returns (-1,-1,-1) (1,1,1) for me[/del]
Woops, it works differently then I realized. Gotta make a new function
[QUOTE=naTlatsyrC;49782362]Looking for a fix for TTT Pointshop skins [U]resetting on round start[/U].
Skins would reset visually if you were alive when the round started (But if you had died / killed yourself during the pre-round it would spawn you in with the skin) would tend to have players have to suicide if they didnt want to un-equip and re-equip the skin manually every time.
This was an odd issue given some skins would have the issues while other times it would randomly select a player and would mess it up for them only.
The skin I would have consistant results on was the TDA Snow Miku skin which is here: [url]http://steamcommunity.com/sharedfiles/filedetails/?id=561431680[/url]
And the pointshop code for it being [CODE]ITEM.Name = 'Snow Miku'
ITEM.Price = 750000
ITEM.Model = 'models/captainbigbutt/vocaloid/tiku_classic.mdl'
function ITEM:OnEquip(ply, modifications)
if not ply._OldModel then
ply._OldModel = ply:GetModel()
end
timer.Simple(1, function()
ply:SetModel(self.Model)
ply:SetSkin(modifications.group or 0)
ply:SetSkin(modifications.group or 0)
ply:SetSkin(modifications.group or 0)
end)
end
function ITEM:OnHolster(ply)
if ply._OldModel then
ply:SetModel(ply._OldModel)
end
end
function ITEM:Modify(modifications)
Derma_Query("Choose Bodygroup", "",
"Normal", function()
modifications.group = 0
PS:SendModifications(self.ID, modifications)
end,
"All White", function()
modifications.group = 1
PS:SendModifications(self.ID, modifications)
end,
"Normal w/ Glow", function()
modifications.group = 2
PS:SendModifications(self.ID, modifications)
end,
"White w/ Glow", function()
modifications.group = 3
PS:SendModifications(self.ID, modifications)
end)
print("modify")
end
function ITEM:OnModify(ply, modifications)
self:OnHolster(ply)
self:OnEquip(ply, modifications)
end[/CODE]
Have latest pointshop 1 vers and TTT off of their github as a before mention.
Have tried using the hook "TTTBeginRound" and when called would reset the skins just as PS would.
v is in sv_player_extension.lua at row 15
[lua]timer.Simple(1, function()
if !IsValid(self) then return end
for item_id, item in pairs(self.PS_Items) do
local ITEM = PS.Items[item_id]
if item.Equipped then
ITEM:OnEquip(self, item.Modifiers)
end
end
end)
[/lua]
Found the problem being that TTT would recall the spawn command in GarrysMod\garrysmod\gamemodes\terrortown\gamemode 's init.lua on row 651
[lua]SpawnWillingPlayers(true)[/lua]
Then call the "TTTBeginRound" hook lower down, Have tried a few things yet am now seemingly stuck, not experienced enough with lua to find a solution.
Really hope to find a solution here and hope I provided enough information. Thanks for reading and for the help in advance![/QUOTE]
I used a TTTBeginRound hook, with a timer of 1 second, and it worked fine. May I ask what exactly did you try to do?
[QUOTE=Lexic;49778859]What am I doing wrong?
sprites/strider_blackball works, but sprites/splodesprite doesn't, and neither does any sprite I like the look of in the texture browser. I grabbed splodesprite from [url]https://wiki.garrysmod.com/page/render/DrawSprite[/url] so I figured it would work.
[lua]
AddCSLuaFile();
ENT.Base = "base_anim";
ENT.Type = "anim";
ENT.Spawnable = false;
ENT.PrintName = "Tombstone";
ENT.Purpose = "Celebrating and marking a player's clumsy death";
ENT.Author = "Lexi"
ENT.RenderGroup = RENDERGROUP_BOTH
DEFINE_BASECLASS "base_entity";
function ENT:Initialize()
self:SetModel("models/gibs/hgibs.mdl");
self:SetMoveType(MOVETYPE_NONE);
self:SetSolid(SOLID_NONE);
end
local behindGlow = Material("sprites/splodesprite");
function ENT:Draw()
self:DrawModel();
end
function ENT:DrawTranslucent()
local obbs = self:OBBMaxs();
local size = obbs:Length() * 4;
render.SetMaterial(behindGlow)
render.DrawSprite(self:GetPos(), size, size);
end
[/lua]
[img]http://i.imgur.com/C5xCaJN.jpg[/img]
[editline]20th February 2016[/editline]
...Huh, I just checked the code on [url]https://wiki.garrysmod.com/page/render/DrawSprite[/url] and turns out it [i]doesn't[/i] work.
Is there some witchcraft I can do to make it actually do alphas?
[img]http://i.imgur.com/af37D1A.png[/img][/QUOTE]
Try Material("matpath", "alphatest")
After what hook is game.GetIPAddress() available, so I can get it once the server has loaded? It doesn't see to be available yet in PostGamemodeLoaded.
[QUOTE=syl0r;49783503]Is there a reliable hook that I can use on clients that is called when they switch weapons?
I don't know why SWEP:Deploy() doesn't always work but I need to set properties on a gun when it's being deployed.
I tried the OnViewModelChanged hook but it seems to also not get called when SWEP:Deploy() doesn't get called.
I also tried SWEP:CallOnClient("Deploy"), but the corresponding call on the client is delayed (by ping), so that Think() might be called before Deploy() is, thus causing lua errors in my script.[/QUOTE]
Not sure but would something like this work? [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSwitchWeapon]GM/PlayerSwitchWeapon[/url]
can TableToJson encrypt a Table with tables inside for its key values. for example
[QUOTE]table = {
key1 = { list, of, items},
key2 = { list2, of, items3},
key3 = { list3, of, items3}
}[/QUOTE]
and can it decrypt the secondary table
[QUOTE=funnygamemake;49787101]***[/QUOTE]
nitpick: you're using the wrong words, json is not an encryption tool, it's a serializer or object notation format or whatever you call it.
also, yes
So can anyone tell me why this code...
[code]
function SWEP:Initialize()
self.NextAmmoRegeneration = 0
end
function SWEP:Think()
if( self.NextAmmoRegeneration <= CurTime() ) then
self.Owner:GiveAmmo(1, "Gravity", true)
self.NextAmmoRegeneration = CurTime() + 1
end
end
[/code]
Brings up this error?
[code]
[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_medgun.lua:54: attempt to call method 'GiveAmmo' (a nil value)
1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_medgun.lua:54
[/code]
The code actually works fine..the ammo spawns. The error pops up though for some odd reason.
[QUOTE=Windwhistle;49789043]So can anyone tell me why this code...
[code]
function SWEP:Initialize()
self.NextAmmoRegeneration = 0
end
function SWEP:Think()
if( self.NextAmmoRegeneration <= CurTime() ) then
self.Owner:GiveAmmo(1, "Gravity", true)
self.NextAmmoRegeneration = CurTime() + 1
end
end
[/code]
Brings up this error?
[code]
[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_medgun.lua:54: attempt to call method 'GiveAmmo' (a nil value)
1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_medgun.lua:54
[/code]
The code actually works fine..the ammo spawns. The error pops up though for some odd reason.[/QUOTE]
Since it's in the think hook it might get called before the weapon gets a owner, try this:
[Lua]function SWEP:Think()
if ( IsValid( self.Owner ) and self.NextAmmoRegeneration <= CurTime() ) then
self.Owner:GiveAmmo(1, "Gravity", true)
self.NextAmmoRegeneration = CurTime() + 1
end
end[/Lua]
[QUOTE=highvoltage;49789086]Since it's in the think hook it might get called before the weapon gets a owner, try this:
[Lua]function SWEP:Think()
if ( IsValid( self.Owner ) and self.NextAmmoRegeneration <= CurTime() ) then
self.Owner:GiveAmmo(1, "Gravity", true)
self.NextAmmoRegeneration = CurTime() + 1
end
end[/Lua][/QUOTE]
Still getting the same error :(
[code]
[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_medgun.lua:52: attempt to call method 'GiveAmmo' (a nil value)
1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_medgun.lua:52
[/code]
When I add this to the think hook, it spams my name..
[code]
print(self.Owner:Nick())
[/code]
FIXED IT!
Apparently, it needed to be done server side...
:cry:
Is there any way to get the size of a Docked panel?
I want to make a square item, but when I pnl:Dock(LEFT) I can't use pnl:SetWide(pnl:GetTall())
So I'm trying to send some strings between clients but I was told I have to relay it through the server. How would I go about doing that?
[QUOTE=ArtikNinetail;49789812]So I'm trying to send some strings between clients but I was told I have to relay it through the server. How would I go about doing that?[/QUOTE]
Probably with the [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]net library[/URL]
E.G.
[CODE]
-- SERVERSIDE
util.AddNetworkString( "stringrelay" )
net.Receive( "stringrelay", function( len, ply ) -- this gets called when the net thing is sent to the server
local someplayer = net.ReadEntity() -- read the sent player/ent
local string = net.ReadString() -- read the string
net.Start( "stringrelay" ) -- start the function
net.WriteString( string ) -- write the string sent from before
net.Send( someplayer ) -- send it to the player specified before
end )
-- CLIENTSIDE
local function RelayString()
local string = 'i eat ass'
net.Start( "stringrelay" ) -- start the net thing clientside
net.WriteEntity( some_random_player ) -- the person you want to send the string to
net.WriteString( string ) -- write your string
net.SendToServer() -- send it to the server for the function above to pick up
end
net.Receive( 'stringrelay', function() -- called when the server sends the client the string
local string = net.ReadString()
print(string) -- we got the string sent
end )
[/CODE]
If you need it to work for a table of players, you could try using [URL="https://wiki.garrysmod.com/page/net/WriteTable"]net.WriteTable[/URL] and [URL="https://wiki.garrysmod.com/page/net/ReadTable"]net.ReadTable[/URL] instead of [URL="https://wiki.garrysmod.com/page/net/WriteEntity"]net.WriteEntity[/URL] and [URL="https://wiki.garrysmod.com/page/net/ReadEntity"]net.ReadEntity[/URL]
[QUOTE=MPan1;49789836]Probably with the [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]net library[/URL]
E.G.
[CODE]
-- SERVERSIDE
util.AddNetworkString( "stringrelay" )
net.Receive( "stringrelay", function( len, ply ) -- this gets called when the net thing is sent to the server
local someplayer = net.ReadEntity() -- read the sent player/ent
local string = net.ReadString() -- read the string
net.Start( "stringrelay" ) -- start the function
net.WriteString( string ) -- write the string sent from before
net.Send( someplayer ) -- send it to the player specified before
end )
-- CLIENTSIDE
local function RelayString()
local string = 'i eat ass'
net.Start( "stringrelay" ) -- start the net thing clientside
net.WriteEntity( some_random_player ) -- the person you want to send the string to
net.WriteString( string ) -- write your string
net.SendToServer() -- send it to the server for the function above to pick up
end
net.Receive( 'stringrelay', function() -- called when the server sends the client the string
local string = net.ReadString()
print(string) -- we got the string sent
end )
[/CODE]
If you need it to work for a table of players, you could try using [URL="https://wiki.garrysmod.com/page/net/WriteTable"]net.WriteTable[/URL] and [URL="https://wiki.garrysmod.com/page/net/ReadTable"]net.ReadTable[/URL] instead of [URL="https://wiki.garrysmod.com/page/net/WriteEntity"]net.WriteEntity[/URL] and [URL="https://wiki.garrysmod.com/page/net/ReadEntity"]net.ReadEntity[/URL][/QUOTE]
So this is the entirety of the code I'm using and nothing seems to happen. Any ideas why? It's being ran just shared.
[code]local send = Player(151)
local recieve = Player(144)
if CLIENT then
if LocalPlayer() == recieve then
net.Receive( "stringrelay", function() -- called when the server recieves the client the string
local str = net.ReadString()
print(str) -- we got the string sent
end )
end
if LocalPlayer() == send then
local function RelayString(tar)
local str = "i eat ass"
net.Start( "stringrelay" ) -- start the net thing clientside
net.WriteEntity( tar ) -- the person you want to recieve the string to
net.WriteString( str ) -- write your string
net.recieveToServer() -- recieve it to the server for the function above to pick up
end
RelayString(Player(144))
end
end
if SERVER then
util.AddNetworkString( "stringrelay" )
net.Receive( "stringrelay", function( len, ply ) -- this gets called when the net thing is sent to the server
local tar = net.ReadEntity() -- read the sent player/ent
local str = net.ReadString() -- read the string
PrintMessage( HUD_PRINTTALK, str)
net.Start( "stringrelay" ) -- start the function
net.WriteString( str ) -- write the string sent from before
net.recieve( tar ) -- recieve it to the player specified before
end )
end
[/code]
Well, recievetoserver isn't a function, and you're not meant to call net.receive serverside there, you're meant to do net.Send with the client's entity as an argument (that makes it get sent to them) ... you completely changed the example I did
[editline]22nd February 2016[/editline]
I'll try to fix your code, hold on for a bit
[QUOTE=MPan1;49789982]Well, recievetoserver isn't a function, and you're not meant to call net.receive serverside there, you're meant to do net.Send with the client's entity as an argument (that makes it get sent to them) ... you completely changed the example I did
[editline]22nd February 2016[/editline]
I'll try to fix your code, hold on for a bit[/QUOTE]
If i was you instead of fixing it for him why dont you just give him tricks/show him whats wrong for him to be able to fix this + future codes itself
[QUOTE=geferon;49790002]If i was you instead of fixing it for him why dont you just give him tricks/show him whats wrong for him to be able to fix this + future codes itself[/QUOTE]
If you looked in the last page, you would see that it was exactly what he had suggested. Apparently though through my ctrl + h it replaced the "SendToServer" with "recieveToServer". But same thing it just wouldn't print anything out.
[QUOTE=geferon;49790002]If i was you instead of fixing it for him why dont you just give him tricks/show him whats wrong for him to be able to fix this + future codes itself[/QUOTE]
I'll explain in a bit, hang on
[editline]22nd February 2016[/editline]
Until I do actually get round to explaining, here's some code that I think works:
[CODE]
if CLIENT then
net.Receive( "stringrelay", function()
local str = net.ReadString()
print(str)
end )
local function DoRelay( receiver, str )
net.Start( "stringrelay" )
net.WriteEntity( receiver )
net.WriteString( str )
net.SendToServer()
end
DoRelay( LocalPlayer(), 'test string' ) -- LocalPlayer is the example person I used that gets the string 'test string' sent to them from whatever client runs the DoRelay function.
end
if SERVER then
util.AddNetworkString( "stringrelay" )
net.Receive( "stringrelay", function( len, ply )
local target = net.ReadEntity()
local str = net.ReadString()
PrintMessage( HUD_PRINTTALK, str )
net.Start( "stringrelay" )
net.WriteString( str )
net.Send( target )
end )
end
[/CODE]
Sorry, you need to Log In to post a reply to this thread.