meta strings

hi, straight to the point

if i wanted to use a string instead of numbers with a meta function would it be like


function meta:SetString(string)

or


function meta:SetString(text)

Arguments can be named pretty much anything, they have no effect on the type of variable.

so i could do either one of what i had before?

Yes, but it’s bad practice to override globals like string, so the latter is better.

latter?

[editline]13th March 2015[/editline]

currently my code is


function meta:SetString(text)
	self:SetNetworkedInt( "String", text )
end

but its giving me errors if i try and use it, im using it in a derma string request


function StringInput1( ply )
Derma_StringRequest(
	"SBio - " .. SERVER_NAME .. "", 
	"Input Your Name!", 
	"", 
	function(text) 
	SetNames( text )
	ply:ConCommand("say","!name", text)
	print("[SBio] " .. ply:Nick() " Has Inputted Text! " .. text .. "")
	ply:ConCommand("bio_menu2")
	end, 
	function(text) ply:ConCommand("stringinput") end
)
end
concommand.Add("stringinput",StringInput1)

Latter meaning the second of the two.

The fact that it’s complaining about a global call means you’re not calling it correctly. You should call your metamethod with ply:SetString(…).

Can you just post the whole code? Because the place that errors isn’t even in the snippet.

Also:


function meta:SetString(text)
	self:SetNetworkedInt( "String", text )
end

You are using


SetNetworkedInt

with a string, you should be using


SetNetworkedString

Actually, those functions are deprecated(Might be removed in future), so use this:


SetNWString

and don’t use a name like “String” for a global/Networked value, make that name unique