Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("oosocks")
- local Calltypes = {
- [SCKCALL_CONNECT] = "Connect", -- SCKCALL_CONNECT
- [SCKCALL_REC_SIZE] = "Rec Size", -- SCKCALL_REC_SIZE
- [SCKCALL_REC_LINE] = "Rec Line", -- SCKCALL_REC_LINE
- [SCKCALL_SEND] = "Send", -- SCKCALL_SEND
- [SCKCALL_BIND] = "Bind", -- SCKCALL_BIND
- [SCKCALL_ACCEPT] = "Accept", -- SCKCALL_ACCEPT
- [SCKCALL_LISTEN] = "Listen", -- SCKCALL_LISTEN
- [SCKCALL_REC_DATAGRAM] = "Datagram", -- SCKCALL_REC_DATAGRAM
- }
- local Errtypes = {
- [SCKERR_OK] = "Ok", -- SCKERR_OK
- [SCKERR_BAD] = "Bad", -- SCKERR_BAD
- [SCKERR_CONNECTION_RESET] = "Con Rest", -- SCKERR_CONNECTION_RESET
- [SCKERR_NOT_CONNECTED] = "Not Con", -- SCKERR_NOT_CONNECTED
- [SCKERR_TIMED_OUT] = "Timed Out", -- SCKERR_TIMED_OUT
- }
- --deep magic
- local function convert(x)
- local sign = 1
- local mantissa = string.byte(x, 3) % 128
- for i = 2, 1, -1 do mantissa = mantissa * 256 + string.byte(x, i) end
- if string.byte(x, 4) > 127 then sign = -1 end
- local exponent = (string.byte(x, 4) % 128) * 2 +
- math.floor(string.byte(x, 3) / 128)
- if exponent == 0 then return 0 end
- mantissa = (math.ldexp(mantissa, -23) + 1) * sign
- return math.ldexp(mantissa, exponent - 127)
- end
- if connection then connection:Close() end
- connection = OOSock(IPPROTO_UDP);
- --local e1=Entity ( 373)
- --local e2=Entity ( 207)
- --local ox,oy,oz=0,0,0
- --local x,y,z=0,0,0
- connection:SetCallback(function(socket, callType, callId, err, binread, peer, peerPort)
- if(callType == SCKCALL_BIND && err == SCKERR_OK) then
- print("Bound.");
- //connection:Send("rofl", "127.0.0.1", 37777);
- connection:ReceiveDatagram();
- end
- if(callType == SCKCALL_SEND && err == SCKERR_OK) then
- print("Sent.");
- end
- if(callType == SCKCALL_REC_DATAGRAM && err == SCKERR_OK) then
- local len= binread:GetSize()
- -- print("Got packet len="..len.." from " .. peer .. ":" .. tostring(peerPort));
- if len == 12 then
- x = binread:ReadFloat()
- y = binread:ReadFloat()
- z = binread:ReadFloat()
- else
- print"Data unknown, discarding"
- end
- socket:ReceiveDatagram();
- end
- if(err != SCKERR_OK) then
- socket:Close()
- end
- end);
- local newang = Angle(0,0,0)
- hook.Add('Think',1,function()
- ox = math.Approach(ox,x,math.abs(ox-x)^2)
- oy = math.Approach(oy,y,math.abs(oy-y)^2)
- oz = math.Approach(oz,z,math.abs(oz-z)^2)
- -- MAHGIC SHIT HERE
- /*local sensvec= Vector(ox,0,0)
- e1:SetPos(e2:GetPos()+sensvec*10)
- local ang = sensvec:Angle()
- ang.p=ang.p+90
- e1:SetAngles(ang)
- */
- -- Ply'Pyth':SetEyeAngles(ang)
- end)
- connection:SetBinaryMode( true )
- -- an IP of "" binds to all interfaces.
- connection:Bind("", 12345);
Advertisement
Add Comment
Please, Sign In to add comment