Message is pooled but if i put some code it won't be pooled for some reason
8 replies, posted
So I'm new to this networking thing, (glua in general lol) and i've done a system in which when you press shift you run faster. The thing is that it works perfectly, but I want to add that when you get to a speed the player is kind of ragdolled during a period of time (like he slipped and fell into the floor). It works completely well without the added code (which is the speed3 thing) but when i add it it gives me this error, even though all strings have been added (line 69 btw is the 'net.Start("wannaragdolls1")' thing)
[CODE]
[ERROR] lua/autorun/client/semi_perfect_scrip.lua:69: Calling net.Start with unpooled message name! [http://goo.gl/qcx0y]
1. Start - [C]:-1
2. fn - lua/autorun/client/semi_perfect_scrip.lua:69
3. unknown - addons/ulib_557962238/lua/ulib/shared/hook.lua:109
[/CODE]
This is at serverside:
[CODE]
speedAt1 = 300 //speed at level 1
speedAt2 = 400 //speed at level 2
speedAt3 = 500 //speed at level 3
speedAt4 = 600 //speed at level 4
speedAt5 = 650 //speed at level 5
util.AddNetworkString( "speed1" )
util.AddNetworkString( "speed2" )
util.AddNetworkString( "speed3" )
util.AddNetworkString( "speed4" )
util.AddNetworkString( "speed5" )
net.Receive("speed1", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt1, speedAt1)
end
)
net.Receive("speed2", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt2, speedAt2)
end
)
net.Receive("speed3", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt3, speedAt3)
if ply:GetVelocity():Length() > 0 then
elseif ply:IsOnGround() == false then
elseif math.random(0,100) < 3 then
print("i work")
end
end
end
end)
net.Receive("speed4", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt4, speedAt4)
end
)
net.Receive("speed5", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt5, speedAt5)
end
)
[/CODE]
Client code (not all the code but the part that contains the net start)
[CODE]
hook.Add("Think","ragdollTrigger", function(ply, mv)
if speed == 3 then
net.Start("speed3")
net.SendToServer()
end
[/CODE]
You need to use util.AddNetworkString for ALL net messages.
[QUOTE=Sean Bean;52499649]You need to use util.AddNetworkString for ALL net messages.[/QUOTE]
What do you mean by that? I added all the util.strings thing
util.AddNetworkString( "speed1" )
util.AddNetworkString( "speed2" )
util.AddNetworkString( "speed3" )
util.AddNetworkString( "speed4" )
util.AddNetworkString( "speed5" )
In fact it works without the code:
if ply:GetVelocity():Length() > 0 then
elseif ply:IsOnGround() == false then
elseif math.random(0,100) < 3 then
print("i work")
end
end
end
Thats what i dont understand, if you could give me an example id be very grateful
[QUOTE=h3xu.hg;52499670]What do you mean by that? I added all the util.strings thing[/QUOTE]
You never added "wannaragdolls1".
[QUOTE=Sean Bean;52499675]You never added "wannaragdolls1".[/QUOTE]
Sorry, when i copied the code i copied the wrong part, the thing is there is something like a
if speed == 3 then
net.start("speed3")
net.sendToServer()
end
The problem here is that the code of speed3 ( in the server ) for some reason breaks the whole code and wont work, but without it it works (i checked it)
You need to wait a few frames before sending the net message after you pool a network string.
[QUOTE=Robotboy655;52499702]You need to wait a few frames before sending the net message after you pool a network string.[/QUOTE]
It works completely fine without the code (connects and does stuff)
if ply:GetVelocity():Length() > 0 then
elseif ply:IsOnGround() == false then
elseif math.random(0,100) < 3 then
print("i work")
end
end
end
So it cant be that, i think that it is a problem in the code and not in the networking
I cant find it though :(
Also I just want to point out that your code is highly vulnerable because you are allowing the player to say what speed they should be, instead of letting the server determine it. You don't need net messages at all for what you are trying to do.
[QUOTE=James xX;52500019]Also I just want to point out that your code is highly vulnerable because you are allowing the player to say what speed they should be, instead of letting the server determine it. You don't need net messages at all for what you are trying to do.[/QUOTE]
I ended up solving it, it was just that the code was wrong (for some reason if any of net.receive is wrong , it will mess up everything) and i'll also modify it so the server determines the speed (and not the player) thanks! (im new at this so ye)
[CODE]
speedAt1 = 300 //speed at level 1
speedAt2 = 400 //speed at level 2
speedAt3 = 500 //speed at level 3
speedAt4 = 600 //speed at level 4
speedAt5 = 650 //speed at level 5
util.AddNetworkString( "speed1" )
util.AddNetworkString( "speed2" )
util.AddNetworkString( "speed3" )
util.AddNetworkString( "speed4" )
util.AddNetworkString( "speed5" )
net.Receive("speed1", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt1, speedAt1)
end
)
net.Receive("speed2", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt2, speedAt2)
end
)
net.Receive("speed3", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt3, speedAt3)
if ply:GetVelocity():Length() > 0 then
if ply:IsOnGround() == false then
if math.random(0,100) > 50 then
print("i work")
end
end
end
end)
net.Receive("speed4", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt4, speedAt4)
end
)
net.Receive("speed5", function(len, ply)
GAMEMODE:SetPlayerSpeed( ply, speedAt5, speedAt5)
end
)
[/CODE]
Sorry, you need to Log In to post a reply to this thread.