Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 11 12 13 14 15 … 18 Next »
Client to server net message
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
Client to server net message
17-09-2015, 07:14 PM,
#2
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Client to server net message
This is a really convoluted and odd way of trying to accomplish pressing a button.

Problems:
  1. Your initial timer is practically certain to run before any network message can be received.
  2. You're sending a table for 3 values, this is wasteful and really OTT.

You do not need to use a timer to do something with what you're sent. You have the net event, use it!

Client:
hook( "starfall_used", "Used", function()
if ents.player() ~= Owner then return end
if not net.start() then return end

-- You should change WarpBut to be a boolean, not a number. You'll have to change your Button() function.
net.writeBool( WarpBut )
-- 3 bits = values 0-7, up the bit count if you need more.
net.writeUInt( GroupNum, 3 )
net.writeUInt( DestNum, 3 )
net.sendToServer()
end )

Server:
hook( "net", "FromClient", function( Length, Player )
local WarpBut = net.readBool()
-- Remember to read the same amount of bits as you write.
local GroupNum = net.readUInt( 3 )
local DestNum = net.readUInt( 3 )

-- Now perform warp destination stuff right here, there's no need for a timer!
end )
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
Client to server net message - by Destiny's Player - 17-09-2015, 06:35 PM
RE: Client to server net message - by Person8880 - 17-09-2015, 07:14 PM
RE: Client to server net message - by Destiny's Player - 17-09-2015, 07:16 PM
RE: Client to server net message - by Destiny's Player - 18-09-2015, 08:21 PM
RE: Client to server net message - by LocInt - 18-09-2015, 08:36 PM
RE: Client to server net message - by Destiny's Player - 18-09-2015, 08:40 PM
RE: Client to server net message - by LocInt - 18-09-2015, 08:41 PM
RE: Client to server net message - by Person8880 - 18-09-2015, 08:54 PM
RE: Client to server net message - by Destiny's Player - 18-09-2015, 08:57 PM
RE: Client to server net message - by Person8880 - 18-09-2015, 09:33 PM
RE: Client to server net message - by rouing - 19-09-2015, 02:51 AM
RE: Client to server net message - by TheOneAndOnlyTee - 19-09-2015, 02:57 AM

  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.