Adding " " to a string

Hello,

I am networking a playermodel path to the server from the client.

I cannot for the life of me figure out how to add " " around the string so that it will set the player model.

Here is what I have:


net.Receive( "PlayerModel", function( length, client )
	PrintMessage(HUD_PRINTTALK, tostring(net.ReadString()))
    PMdl = net.ReadString()
	client:SetModel(tostring(PMdl))

end )

It is probably stupid but tostring doesn’t work.

Thanks in advance!

-snip-

Well, first thing’s first: putting tostring( ) on a string doesn’t make sense. Adding fluff to your code that shouldn’t change anything will only make things weirder and weirder until it becomes incomprehensible. Always have reason for your code, for code is literally an iteration of logic.

print(’ Hehe “I am a string” Haha ') or print( " Hehe “I am a string” Haha " )

The funny thing is, you don’t need quotes in there. And tostring too. Since you already read a string.

[del]I’d assume the problem is in your send code.[/del] See post below.

Quotes are just the visual representation of a string.

With the net library, you get a stream, which means you can only Read* once per Write*.

[lua]
net.Receive(“PlayerModel”, function(length, client)
local plymdl = net.ReadString()
PrintMessage(HUD_PRINTTALK, plymdl)

client:SetModel(plymdl)

end)
[/lua]



string = "\" \""


will output " "
You put a ’ \ ’ before the ’ " ’ to make it not cancel the string.
so, you could do



client:SetModel("\"" .. PMdl .."\"")


EDIT:
Dammit, I was too slow :stuck_out_tongue:

Are you serious with the stream thing? That explains random issues I’ve encountered! Someone should put that on the Wiki.

-snip- bad reading

Wow, didn’t even know that. Thanks so much!