• Problem with my RpName
    2 replies, posted
Hello Guys!, i have got a problem with my Rpname script, i write two local [CODE]local f_name, l_name = "Harry", "Potter"[/CODE] I Do two TextEntry for f_name and l_name (First Name and Last Name). [CODE]local TextEntry = vgui.Create( "DTextEntry", Frame2 ) TextEntry:SetPos(Frame2:GetWide() * 100, Frame2:GetTall() * 0) TextEntry:SetSize(Frame2:GetWide() * 0.3, Frame2:GetTall() * 0.1,2) TextEntry:SetText(f_name) TextEntry:SetFont( "Text" ) TextEntry.OnTextChanged = function(self) f_name = self:GetValue() end[/CODE] [CODE]local TextEntry2 = vgui.Create( "DTextEntry", Frame2 ) -- create the form as a child of frame TextEntry2:SetPos(Frame2:GetWide() * 100, Frame2:GetTall() * 0) TextEntry2:SetSize(Frame2:GetWide() * 0.3, Frame2:GetTall() * 0.1,2) TextEntry2:SetText( l_name ) TextEntry2:SetFont( "Text" ) TextEntry2.OnTextChanged = function(self) l_name = self:GetValue() end[/CODE] Then i need changue the rpname of the player. I Try this: When the player click on button. [CODE]net.Start("rpname") net.WriteString(f_name) net.WriteString(l_name) net.SendToServer()[/CODE] In serverside i make this [CODE]function rpname( ply ) local s = net.ReadString() local ss = net.ReadString() ply:setRPName(s .. " " .. ss, false) net.Send(ply) end net.Receive("rpname",rpname)[/CODE] Say this on console: [CODE]attempt to index local 'ply' (a number value)[/CODE] I Need help :(
[QUOTE=davicyyo;52328069]snip[/QUOTE] The first argument of [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Receive]net.Receive[/url] callback function is the length of the message, the second one is the player that sent the message, so you need to do : [code]function rpname( len, ply ) --Added first argument local s = net.ReadString() local ss = net.ReadString() ply:setRPName(s .. " " .. ss, false) net.Send(ply) end net.Receive("rpname",rpname)[/code] [editline]8th June 2017[/editline] Also not sure why you have another net.Send in your function.
it's true!, my bad :dance: Many Thanks bilbasio! :wow:
Sorry, you need to Log In to post a reply to this thread.