UNPKG

@infernus/raknet

Version:

A wrapper of the popular open.mp raknet plugin for samp-node.

2 lines (1 loc) 32.2 kB
import{I18n as k,InvalidEnum as O,defineEvent as A,LimitsEnum as v}from"@infernus/core";samp.defined||(samp.defined={}),samp.defined.PAWNRAKNET_INC_=!0;const te=256,E=13,ae=e=>Math.ceil(e/8),re=e=>e*8;var x=(e=>(e[e.IncomingPacket=0]="IncomingPacket",e[e.IncomingRpc=1]="IncomingRpc",e[e.OutgoingPacket=2]="OutgoingPacket",e[e.OutgoingRpc=3]="OutgoingRpc",e[e.IncomingCustomRpc=4]="IncomingCustomRpc",e[e.NumberOfEventTypes=5]="NumberOfEventTypes",e))(x||{}),t=(e=>(e[e.Int8=0]="Int8",e[e.Int16=1]="Int16",e[e.Int32=2]="Int32",e[e.UInt8=3]="UInt8",e[e.UInt16=4]="UInt16",e[e.UInt32=5]="UInt32",e[e.Float=6]="Float",e[e.Bool=7]="Bool",e[e.String=8]="String",e[e.CInt8=9]="CInt8",e[e.CInt16=10]="CInt16",e[e.CInt32=11]="CInt32",e[e.CUInt8=12]="CUInt8",e[e.CUInt16=13]="CUInt16",e[e.CUInt32=14]="CUInt32",e[e.CFloat=15]="CFloat",e[e.CBool=16]="CBool",e[e.CString=17]="CString",e[e.Bits=18]="Bits",e[e.Float3=19]="Float3",e[e.Float4=20]="Float4",e[e.Vector=21]="Vector",e[e.NormQuat=22]="NormQuat",e[e.String8=23]="String8",e[e.String32=24]="String32",e[e.IgnoreBits=25]="IgnoreBits",e))(t||{}),S=(e=>(e[e.System=0]="System",e[e.High=1]="High",e[e.Medium=2]="Medium",e[e.Low=3]="Low",e))(S||{}),m=(e=>(e[e.Unreliable=6]="Unreliable",e[e.UnreliableSequenced=7]="UnreliableSequenced",e[e.Reliable=8]="Reliable",e[e.ReliableOrdered=9]="ReliableOrdered",e[e.ReliableSequenced=10]="ReliableSequenced",e))(m||{}),c=(e=>(e[e.SendPacket=0]="SendPacket",e[e.SendRpc=1]="SendRpc",e[e.EmulateIncomingPacket=2]="EmulateIncomingPacket",e[e.EmulateIncomingRpc=3]="EmulateIncomingRpc",e[e.New=4]="New",e[e.NewCopy=5]="NewCopy",e[e.Delete=6]="Delete",e[e.Reset=7]="Reset",e[e.ResetReadPointer=8]="ResetReadPointer",e[e.ResetWritePointer=9]="ResetWritePointer",e[e.IgnoreBits=10]="IgnoreBits",e[e.SetWriteOffset=11]="SetWriteOffset",e[e.GetWriteOffset=12]="GetWriteOffset",e[e.SetReadOffset=13]="SetReadOffset",e[e.GetReadOffset=14]="GetReadOffset",e[e.GetNumberOfBitsUsed=15]="GetNumberOfBitsUsed",e[e.GetNumberOfBytesUsed=16]="GetNumberOfBytesUsed",e[e.GetNumberOfUnreadBits=17]="GetNumberOfUnreadBits",e[e.GetNumberOfBitsAllocated=18]="GetNumberOfBitsAllocated",e))(c||{}),u=(e=>(e[e.DriverSync=200]="DriverSync",e[e.RconCommand=201]="RconCommand",e[e.AimSync=203]="AimSync",e[e.WeaponsUpdate=204]="WeaponsUpdate",e[e.StatsUpdate=205]="StatsUpdate",e[e.BulletSync=206]="BulletSync",e[e.OnFootSync=207]="OnFootSync",e[e.MarkersSync=208]="MarkersSync",e[e.UnoccupiedSync=209]="UnoccupiedSync",e[e.TrailerSync=210]="TrailerSync",e[e.PassengerSync=211]="PassengerSync",e[e.SpectatingSync=212]="SpectatingSync",e[e.InternalPing=6]="InternalPing",e[e.ConnectedPong=9]="ConnectedPong",e[e.RequestStaticData=10]="RequestStaticData",e[e.ConnectionRequest=11]="ConnectionRequest",e[e.AuthKey=12]="AuthKey",e[e.RpcMapping=17]="RpcMapping",e[e.DetectLostConnections=23]="DetectLostConnections",e[e.NewIncomingConnection=30]="NewIncomingConnection",e[e.NoFreeIncomingConnections=31]="NoFreeIncomingConnections",e[e.DisconnectionNotification=32]="DisconnectionNotification",e[e.ConnectionLost=33]="ConnectionLost",e[e.ConnectionRequestAccepted=34]="ConnectionRequestAccepted",e[e.ConnectionAttemptFailed=35]="ConnectionAttemptFailed",e[e.ConnectionBanned=36]="ConnectionBanned",e[e.InvalidPassword=37]="InvalidPassword",e[e.ModifiedPacket=38]="ModifiedPacket",e))(u||{}),K=(e=>(e[e.ShowActor=171]="ShowActor",e[e.HideActor=172]="HideActor",e[e.ApplyActorAnimation=173]="ApplyActorAnimation",e[e.ClearActorAnimation=174]="ClearActorAnimation",e[e.SetActorFacingAngle=175]="SetActorFacingAngle",e[e.SetActorPos=176]="SetActorPos",e[e.SetActorHealth=178]="SetActorHealth",e[e.SetPlayerAttachedObject=113]="SetPlayerAttachedObject",e[e.ChatBubble=59]="ChatBubble",e[e.GiveActorDamage=177]="GiveActorDamage",e[e.DisableCheckpoint=37]="DisableCheckpoint",e[e.SetRaceCheckpoint=38]="SetRaceCheckpoint",e[e.DisableRaceCheckpoint=39]="DisableRaceCheckpoint",e[e.SetCheckpoint=107]="SetCheckpoint",e[e.ShowDialog=61]="ShowDialog",e[e.AddGangZone=108]="AddGangZone",e[e.GangZoneDestroy=120]="GangZoneDestroy",e[e.GangZoneFlash=121]="GangZoneFlash",e[e.GangZoneStopFlash=85]="GangZoneStopFlash",e[e.ShowGameText=73]="ShowGameText",e[e.SetGravity=146]="SetGravity",e[e.SetMapIcon=56]="SetMapIcon",e[e.RemoveMapIcon=144]="RemoveMapIcon",e[e.InitMenu=76]="InitMenu",e[e.ShowMenu=77]="ShowMenu",e[e.HideMenu=78]="HideMenu",e[e.ShowPlayerNameTag=80]="ShowPlayerNameTag",e[e.CreateObject=44]="CreateObject",e[e.SetPlayerObjectMaterialText=84]="SetPlayerObjectMaterialText",e[e.AttachObjectToPlayer=75]="AttachObjectToPlayer",e[e.AttachCameraToObject=81]="AttachCameraToObject",e[e.EditAttachedObject=116]="EditAttachedObject",e[e.EditObject=117]="EditObject",e[e.EnterEditObject=27]="EnterEditObject",e[e.CancelEdit=28]="CancelEdit",e[e.SetObjectPos=45]="SetObjectPos",e[e.SetObjectRotation=46]="SetObjectRotation",e[e.DestroyObject=47]="DestroyObject",e[e.MoveObject=99]="MoveObject",e[e.StopObject=122]="StopObject",e[e.CreatePickup=95]="CreatePickup",e[e.DestroyPickup=63]="DestroyPickup",e[e.ServerJoin=137]="ServerJoin",e[e.ServerQuit=138]="ServerQuit",e[e.InitGame=139]="InitGame",e[e.ConnectionRejected=130]="ConnectionRejected",e[e.UpdateScoresAndPings=155]="UpdateScoresAndPings",e[e.ClientJoin=25]="ClientJoin",e[e.NpcJoin=54]="NpcJoin",e[e.ClientCheck=103]="ClientCheck",e[e.GameModeRestart=40]="GameModeRestart",e[e.ApplyPlayerAnimation=86]="ApplyPlayerAnimation",e[e.ClearPlayerAnimation=87]="ClearPlayerAnimation",e[e.DeathBroadcast=166]="DeathBroadcast",e[e.SetPlayerName=11]="SetPlayerName",e[e.SetPlayerPos=12]="SetPlayerPos",e[e.SetPlayerPosFindZ=13]="SetPlayerPosFindZ",e[e.SetPlayerFacingAngle=19]="SetPlayerFacingAngle",e[e.SetPlayerSkillLevel=34]="SetPlayerSkillLevel",e[e.SetPlayerSkin=153]="SetPlayerSkin",e[e.SetPlayerTime=29]="SetPlayerTime",e[e.SetPlayerSpecialAction=88]="SetPlayerSpecialAction",e[e.SetWeather=152]="SetWeather",e[e.SetWorldBounds=17]="SetWorldBounds",e[e.SetPlayerVelocity=90]="SetPlayerVelocity",e[e.TogglePlayerControllable=15]="TogglePlayerControllable",e[e.TogglePlayerSpectating=124]="TogglePlayerSpectating",e[e.ToggleClock=30]="ToggleClock",e[e.SetPlayerTeam=69]="SetPlayerTeam",e[e.PlaySound=16]="PlaySound",e[e.GivePlayerMoney=18]="GivePlayerMoney",e[e.ResetPlayerMoney=20]="ResetPlayerMoney",e[e.ResetPlayerWeapons=21]="ResetPlayerWeapons",e[e.GivePlayerWeapon=22]="GivePlayerWeapon",e[e.PlayAudioStream=41]="PlayAudioStream",e[e.PlayCrimeReport=112]="PlayCrimeReport",e[e.StopAudioStream=42]="StopAudioStream",e[e.RemoveBuilding=43]="RemoveBuilding",e[e.SetPlayerHealth=14]="SetPlayerHealth",e[e.SetPlayerArmour=66]="SetPlayerArmour",e[e.SetWeaponAmmo=145]="SetWeaponAmmo",e[e.SetCameraBehind=162]="SetCameraBehind",e[e.SetArmedWeapon=67]="SetArmedWeapon",e[e.WorldPlayerAdd=32]="WorldPlayerAdd",e[e.WorldPlayerRemove=163]="WorldPlayerRemove",e[e.InterpolateCamera=82]="InterpolateCamera",e[e.CreateExplosion=79]="CreateExplosion",e[e.SendDeathMessage=55]="SendDeathMessage",e[e.SendGameTimeUpdate=60]="SendGameTimeUpdate",e[e.SendClientMessage=93]="SendClientMessage",e[e.SetShopName=33]="SetShopName",e[e.SetPlayerDrunkLevel=35]="SetPlayerDrunkLevel",e[e.SetPlayerFightingStyle=89]="SetPlayerFightingStyle",e[e.SetInterior=156]="SetInterior",e[e.SetPlayerColor=72]="SetPlayerColor",e[e.ForceClassSelection=74]="ForceClassSelection",e[e.ToggleWidescreen=111]="ToggleWidescreen",e[e.SetPlayerWantedLevel=133]="SetPlayerWantedLevel",e[e.SetCameraPos=157]="SetCameraPos",e[e.SetCameraLookAt=158]="SetCameraLookAt",e[e.SetSpawnInfo=68]="SetSpawnInfo",e[e.RequestClass=128]="RequestClass",e[e.RequestSpawn=129]="RequestSpawn",e[e.SpectatePlayer=126]="SpectatePlayer",e[e.SpectateVehicle=127]="SpectateVehicle",e[e.EnableStuntBonus=104]="EnableStuntBonus",e[e.ToggleSelectTextDraw=83]="ToggleSelectTextDraw",e[e.TextDrawSetString=105]="TextDrawSetString",e[e.ShowTextDraw=134]="ShowTextDraw",e[e.HideTextDraw=135]="HideTextDraw",e[e.PlayerEnterVehicle=26]="PlayerEnterVehicle",e[e.PlayerExitVehicle=154]="PlayerExitVehicle",e[e.RemoveVehicleComponent=57]="RemoveVehicleComponent",e[e.AttachTrailerToVehicle=148]="AttachTrailerToVehicle",e[e.DetachTrailerFromVehicle=149]="DetachTrailerFromVehicle",e[e.LinkVehicleToInterior=65]="LinkVehicleToInterior",e[e.PutPlayerInVehicle=70]="PutPlayerInVehicle",e[e.RemovePlayerFromVehicle=71]="RemovePlayerFromVehicle",e[e.UpdateVehicleDamageStatus=106]="UpdateVehicleDamageStatus",e[e.SetVehicleTireStatus=98]="SetVehicleTireStatus",e[e.ScmEvent=96]="ScmEvent",e[e.SetVehicleNumberPlate=123]="SetVehicleNumberPlate",e[e.DisableVehicleCollisions=167]="DisableVehicleCollisions",e[e.SetVehicleHealth=147]="SetVehicleHealth",e[e.SetVehicleVelocity=91]="SetVehicleVelocity",e[e.SetVehiclePos=159]="SetVehiclePos",e[e.SetVehicleZAngle=160]="SetVehicleZAngle",e[e.SetVehicleParams=161]="SetVehicleParams",e[e.SetVehicleParamsEx=24]="SetVehicleParamsEx",e[e.WorldVehicleAdd=164]="WorldVehicleAdd",e[e.WorldVehicleRemove=165]="WorldVehicleRemove",e[e.Create3DTextLabel=36]="Create3DTextLabel",e[e.Delete3DTextLabel=58]="Delete3DTextLabel",e[e.SetWorldTime=94]="SetWorldTime",e[e.ToggleCameraTarget=170]="ToggleCameraTarget",e[e.EnterVehicle=26]="EnterVehicle",e[e.ExitVehicle=154]="ExitVehicle",e[e.VehicleDamaged=106]="VehicleDamaged",e[e.VehicleDestroyed=136]="VehicleDestroyed",e[e.SendSpawn=52]="SendSpawn",e[e.ChatMessage=101]="ChatMessage",e[e.InteriorChangeNotification=118]="InteriorChangeNotification",e[e.DeathNotification=53]="DeathNotification",e[e.SendCommand=50]="SendCommand",e[e.ClickPlayer=23]="ClickPlayer",e[e.DialogResponse=62]="DialogResponse",e[e.ClientCheckResponse=103]="ClientCheckResponse",e[e.GiveTakeDamage=115]="GiveTakeDamage",e[e.MapMarker=119]="MapMarker",e[e.MenuSelect=132]="MenuSelect",e[e.MenuQuit=140]="MenuQuit",e[e.SelectTextDraw=83]="SelectTextDraw",e[e.PickedUpPickup=131]="PickedUpPickup",e[e.SelectObject=27]="SelectObject",e[e.CameraTarget=168]="CameraTarget",e[e.SetPlayerVirtualWorld=48]="SetPlayerVirtualWorld",e[e.ModelInfo=179]="ModelInfo",e[e.ModelFile=183]="ModelFile",e[e.SrcFinishedDownloading=185]="SrcFinishedDownloading",e[e.FinishedDownloading=184]="FinishedDownloading",e[e.RequestDffFile=181]="RequestDffFile",e[e.RequestTxdFile=182]="RequestTxdFile",e))(K||{}),q=(e=>(e[e.INTERNAL_PING=6]="INTERNAL_PING",e[e.CONNECTED_PONG=9]="CONNECTED_PONG",e[e.REQUEST_STATIC_DATA=10]="REQUEST_STATIC_DATA",e[e.CONNECTION_REQUEST=11]="CONNECTION_REQUEST",e[e.AUTH_KEY=12]="AUTH_KEY",e[e.RPC_MAPPING=17]="RPC_MAPPING",e[e.DETECT_LOST_CONNECTIONS=23]="DETECT_LOST_CONNECTIONS",e[e.NEW_INCOMING_CONNECTION=30]="NEW_INCOMING_CONNECTION",e[e.NO_FREE_INCOMING_CONNECTIONS=31]="NO_FREE_INCOMING_CONNECTIONS",e[e.DISCONNECTION_NOTIFICATION=32]="DISCONNECTION_NOTIFICATION",e[e.CONNECTION_LOST=33]="CONNECTION_LOST",e[e.CONNECTION_REQUEST_ACCEPTED=34]="CONNECTION_REQUEST_ACCEPTED",e[e.CONNECTION_ATTEMPT_FAILED=35]="CONNECTION_ATTEMPT_FAILED",e[e.CONNECTION_BANNED=36]="CONNECTION_BANNED",e[e.INVALID_PASSWORD=37]="INVALID_PASSWORD",e[e.MODIFIED_PACKET=38]="MODIFIED_PACKET",e[e.RECEIVED_STATIC_DATA=41]="RECEIVED_STATIC_DATA",e))(q||{});const w=(e,a,r="utf8")=>(typeof e=="string"?k.encodeToBuf(e,r):e).slice(0,a),F=(e,a,r,n)=>{const i=e.readValue([r,a]),l=k.getValidStr(i);return k.decodeFromBuf(l,n)},d=(...e)=>samp.callPublic("RakNetNatives","a",e),ie=(e,a,r=0)=>{switch(a){case t.Bool:case t.CBool:return!!samp.callPublic("RakNetReadInt","i",e);case t.Float:return samp.callPublicFloat("RakNetReadFloat","i",e);case t.CFloat:return samp.callPublicFloat("RakNetReadCompressedFloat","i",e);case t.Bits:return samp.callPublic("RakNetReadBits","ii",e,r);case t.Float3:{samp.callPublic("RakNetReadFloat3","i",e);const n=[];for(let i=0;i<3;i++)n[i]=samp.callPublicFloat("RakNetReadFloat3Array","i",i);return n}case t.Float4:{samp.callPublic("RakNetReadFloat4","i",e);const n=[];for(let i=0;i<4;i++)n[i]=samp.callPublicFloat("RakNetReadFloat4Array","i",i);return n}case t.Vector:{samp.callPublic("RakNetReadVector","i",e);const n=[];for(let i=0;i<3;i++)n[i]=samp.callPublicFloat("RakNetReadFloat3Array","i",i);return n}case t.NormQuat:{samp.callPublic("RakNetReadNormQuat","i",e);const n=[];for(let i=0;i<4;i++)n[i]=samp.callPublicFloat("RakNetReadFloat4Array","i",i);return n}case t.String8:{samp.callPublic("RakNetReadString8","i",e);const n=[];for(let i=0;i<8;i++)n[i]=samp.callPublic("RakNetReadString8Array","i",i);return n}case t.String32:{samp.callPublic("RakNetReadString32","i",e);const n=[];for(let i=0;i<32;i++)n[i]=samp.callPublic("RakNetReadString32Array","i",i);return n}case t.String:{samp.callPublic("RakNetReadString","ii",e,r);const n=[];for(let i=0;i<r;i++)n[i]=samp.callPublic("RakNetReadStringArray","i",i);return n}case t.CString:{samp.callPublic("RakNetReadCompressedString","ii",e,r);const n=[];for(let i=0;i<r;i++)n[i]=samp.callPublic("RakNetReadStringArray","i",i);return n}default:return samp.callPublic("RakNetReadInt","ii",e,a)}},ne=(e,a,r,n=0)=>{switch(a){case t.Bool:case t.CBool:return Array.isArray(r)?!1:!!samp.callPublic("RakNetWriteInt","ii",e,+r);case t.Float:return typeof r!="number"?!1:!!samp.callPublicFloat("RakNetWriteFloat","if",e,r);case t.CFloat:return typeof r!="number"?!1:!!samp.callPublicFloat("RakNetWriteCompressedFloat","if",e,r);case t.Bits:return typeof r!="number"?!1:!!samp.callPublic("RakNetWriteBits","iii",e,r,n);case t.Float3:return!Array.isArray(r)||r.length!==3?!1:!!samp.callPublicFloat("RakNetWriteFloat3","iv",e,r);case t.Float4:return!Array.isArray(r)||r.length!==4?!1:!!samp.callPublicFloat("RakNetWriteFloat4","iv",e,r);case t.Vector:return!Array.isArray(r)||r.length!==3?!1:!!samp.callPublicFloat("RakNetWriteVector","iv",e,r);case t.NormQuat:return!Array.isArray(r)||r.length!==4?!1:!!samp.callPublicFloat("RakNetWriteNormQuat","iv",e,r);case t.String8:return Array.isArray(r)?!!samp.callPublicFloat("RakNetWriteString8","ia",e,r):!1;case t.String32:return Array.isArray(r)?!!samp.callPublicFloat("RakNetWriteString32","ia",e,r):!1;case t.String:return Array.isArray(r)?!!samp.callPublicFloat("RakNetWriteString","iai",e,r,n||r.length):!1;case t.CString:return Array.isArray(r)?!!samp.callPublicFloat("RakNetWriteCompressedString","iai",e,r,n||r.length):!1;default:return typeof r!="number"?!1:!!samp.callPublic("RakNetWriteInt","iii",e,a,r)}};class o{id;constructor(a){a?a instanceof o?this.id=a.id:this.id=a:this.id=d(c.New)}sendPacket(a,r=S.High,n=m.ReliableOrdered,i=0){const l=typeof a=="number"?a:a.id;d(c.SendPacket,this.id,l,r,n,i)}sendRPC(a,r,n=S.High,i=m.ReliableOrdered,l=0){const s=typeof a=="number"?a:a.id;d(c.SendRpc,this.id,s,r,n,i,l)}emulateIncomingPacket(a){const r=typeof a=="number"?a:a.id;d(c.EmulateIncomingPacket,this.id,r)}emulateIncomingRPC(a,r){const n=typeof a=="number"?a:a.id;d(c.EmulateIncomingRpc,this.id,n,r)}newCopy(){return new o(d(c.NewCopy,this.id))}delete(){return d(c.Delete,this.id),this.id}reset(){d(c.Reset,this.id)}resetReadPointer(){d(c.ResetReadPointer,this.id)}resetWritePointer(){d(c.ResetWritePointer,this.id)}ignoreBits(a){d(c.IgnoreBits,this.id,a)}setWriteOffset(a){d(c.SetWriteOffset,this.id,a)}getWriteOffset(){return d(c.GetWriteOffset,this.id)}setReadOffset(a){d(c.SetReadOffset,this.id,a)}getReadOffset(){return d(c.GetReadOffset,this.id)}getNumberOfBitsUsed(){return d(c.GetNumberOfBitsUsed,this.id)}getNumberOfBytesUsed(){return d(c.GetNumberOfBytesUsed,this.id)}getNumberOfUnreadBits(){return d(c.GetNumberOfUnreadBits,this.id)}getNumberOfBitsAllocated(){return d(c.GetNumberOfBitsAllocated,this.id)}readValue(...a){const r=[];return a.forEach(n=>{const i=Array.isArray(n),l=i?n[0]:n,s=ie(this.id,l,i?n[1]:0);r.push(s)}),r.length===1?r[0]:r}writeValue(...a){const r=[];return a.forEach(n=>{const[i,l,s=0]=n,I=ne(this.id,i,l,s);r.push(I)}),r.length===1?r[0]:r}readInt8(){return this.readValue(t.Int8)}readInt16(){return this.readValue(t.Int16)}readInt32(){return this.readValue(t.Int32)}readUint8(){return this.readValue(t.UInt8)}readUint16(){return this.readValue(t.UInt16)}readUint32(){return this.readValue(t.UInt32)}readFloat(){return this.readValue(t.Float)}readBool(){return this.readValue(t.Bool)}readString(a=1024){return F(this,a,t.String)}readCompressedInt8(){return this.readValue(t.CInt8)}readCompressedInt16(){return this.readValue(t.CInt16)}readCompressedInt32(){return this.readValue(t.CInt32)}readCompressedUint8(){return this.readValue(t.CUInt8)}readCompressedUint16(){return this.readValue(t.CUInt16)}readCompressedUint32(){return this.readValue(t.CUInt32)}readCompressedFloat(){return this.readValue(t.CFloat)}readCompressedBool(){return this.readValue(t.CBool)}readCompressedString(a,r){return F(this,a,t.CString,r)}readBits(a){return this.readValue([t.Bits,a])}readFloat3(){return this.readValue(t.Float3)}readFloat4(){return this.readValue(t.Float4)}readVector(){return this.readValue(t.Vector)}readNormQuat(){return this.readValue(t.NormQuat)}readString8(a){return F(this,8,t.String8,a)}readString32(a){return F(this,32,t.String32,a)}writeInt8(a){return this.writeValue([t.Int8,a])}writeInt16(a){return this.writeValue([t.Int16,a])}writeInt32(a){return this.writeValue([t.Int32,a])}writeUint8(a){return this.writeValue([t.UInt8,a])}writeUint16(a){return this.writeValue([t.UInt16,a])}writeUint32(a){return this.writeValue([t.UInt32,a])}writeFloat(a){return this.writeValue([t.Float,a])}writeBool(a){return this.writeValue([t.Bool,a])}writeString(a,r=1024){return this.writeValue([t.String,w(a,r)])}writeCompressedInt8(a){return this.writeValue([t.CInt8,a])}writeCompressedInt16(a){return this.writeValue([t.CInt16,a])}writeCompressedInt32(a){return this.writeValue([t.CInt32,a])}writeCompressedUint8(a){return this.writeValue([t.CUInt8,a])}writeCompressedUint16(a){return this.writeValue([t.CUInt16,a])}writeCompressedUint32(a){return this.writeValue([t.CUInt32,a])}writeCompressedFloat(a){return this.writeValue([t.CFloat,a])}writeCompressedBool(a){return this.writeValue([t.CBool,a])}writeCompressedString(a,r=1024){return this.writeValue([t.CString,w(a,r)])}writeBits(a,r){return this.writeValue([t.Bits,a,r])}writeFloat3(a){return this.writeValue([t.Float3,a])}writeFloat4(a){return this.writeValue([t.Float4,a])}writeVector(a){return this.writeValue([t.Vector,a])}writeNormQuat(a){return this.writeValue([t.NormQuat,a])}writeString8(a){return this.writeValue([t.String8,w(a,8)])}writeString32(a){return this.writeValue([t.String32,w(a,32)])}static packAspectRatio(a){return Math.round((a-1)*255)}static unpackAspectRatio(a){return a/255+1}static packCameraZoom(a){return Math.round((a-35)/35*63)}static unpackCameraZoom(a){return a/63*35+35}static packHealthArmour(a,r){let n;return a>0&&a<100?n=a/7<<4:a>=100?n=240:n=0,r>0&&r<100?n|=r/7:r>=100&&(n|=15),n}static unpackHealthArmour(a){let r,n;return r=a>>4,r===15?r=100:r*=7,n=a&15,n===15?n=100:n*=7,{health:r,armour:n}}readWeaponsUpdate(){const a={};a.slotWeaponId=[],a.slotWeaponAmmo=[],a.slotUpdated=[];let r=0;const n=this.getNumberOfBytesUsed();for(n>5&&(r=(n-5)/4),[a.targetId,a.targetActorId]=this.readValue(t.UInt16,t.UInt16);r--;){const[i,l,s]=this.readValue(t.UInt8,t.UInt8,t.UInt16);i<E&&(a.slotWeaponId[i]=l,a.slotWeaponAmmo[i]=s,a.slotUpdated[i]=!0)}return a}readStatsUpdate(){const a={};return[a.money,a.drunkLevel]=this.readValue(t.Int32,t.Int32),a}readRconCommand(){const a={};return[a.command]=this.readValue(t.String32),a}writeWeaponsUpdate(a){this.writeValue([t.UInt16,a.targetId],[t.UInt16,a.targetActorId]);for(let r=0;r<E;r++)a.slotUpdated[r]&&this.writeValue([t.UInt8,r],[t.UInt8,a.slotWeaponId[r]],[t.UInt16,a.slotWeaponAmmo[r]])}writeStatsUpdate(a){this.writeValue([t.Int32,a.money],[t.Int32,a.drunkLevel])}writeRconCommand(a){this.writeValue([t.String32,a.command])}sendPacketToPlayerStream(a,r,n=S.High,i=m.ReliableOrdered,l=0){a.forEach(s=>{s.isStreamedIn(r)&&this.sendPacket(s.id,n,i,l)})}sendRPCToPlayerStream(a,r,n,i=S.High,l=m.ReliableOrdered,s=0){a.forEach(I=>{I.isStreamedIn(r)&&this.sendRPC(I.id,n,i,l,s)})}sendPacketToVehicleStream(a,r,n=O.PLAYER_ID,i=S.High,l=m.ReliableOrdered,s=0){a.forEach(I=>{n!==O.PLAYER_ID&&(I===n||r.isStreamedIn(I))||this.sendPacket(I.id,i,l,s)})}sendRPCToVehicleStream(a,r,n,i=O.PLAYER_ID,l=S.High,s=m.ReliableOrdered,I=0){a.forEach(T=>{i!==O.PLAYER_ID&&(T===i||r.isStreamedIn(T))||this.sendRPC(T.id,n,l,s,I)})}}const[Q]=A({name:"OnIncomingPacket",identifier:"iii",beforeEach(e,a,r){return{playerId:e,packetId:a,bs:new o(r)}}}),[Z]=A({name:"OnIncomingRPC",identifier:"iii",beforeEach(e,a,r){return{playerId:e,rpcId:a,bs:new o(r)}}}),[Y]=A({name:"OnOutgoingPacket",identifier:"iii",beforeEach(e,a,r){return{playerId:e,packetId:a,bs:new o(r)}}}),[$]=A({name:"OnOutgoingRPC",identifier:"iii",beforeEach(e,a,r){return{playerId:e,rpcId:a,bs:new o(r)}}}),X=(e,a)=>Q(r=>r.packetId===e?a(r):r.next()),J=(e,a)=>Z(r=>r.rpcId===e?a(r):r.next()),z=(e,a)=>Y(r=>r.packetId===e?a(r):r.next()),ee=(e,a)=>$(r=>r.rpcId===e?a(r):r.next()),le=X,se=J,ce=z,oe=ee,p=e=>a=>{Object.defineProperty(a.prototype,"_packetId",{configurable:!1,enumerable:!1,writable:!1,value:e})},h=(e,a,r)=>{const n=r.value;r.value=function(...i){const l=this.bs;return l.resetReadPointer(),l.readBits(8)!==this._packetId?null:n.apply(this,i)}},y=(e,a,r)=>{const n=r.value;r.value=function(...i){const l=this.bs;l.resetWritePointer(),l.writeBits(this._packetId,8),n.apply(this,i)}};var de=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,B=(e,a,r,n)=>{for(var i=n>1?void 0:n?ue(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&de(a,r,i),i};let P=class extends o{constructor(e){super(e),this.bs=e}readSync(){const e={};return[e.camMode,e.camFrontVec,e.camPos,e.aimZ,e.weaponState,e.camZoom,e.aspectRatio]=this.bs.readValue(t.UInt8,t.Float3,t.Float3,t.Float,[t.Bits,2],[t.Bits,6],t.UInt8),e}writeSync(e){this.bs.writeValue([t.UInt8,e.camMode],[t.Float3,e.camFrontVec],[t.Float3,e.camPos],[t.Float,e.aimZ],[t.Bits,e.weaponState,2],[t.Bits,e.camZoom,6],[t.UInt8,e.aspectRatio])}};B([h],P.prototype,"readSync",1),B([y],P.prototype,"writeSync",1),P=B([p(u.AimSync)],P);var Ie=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,D=(e,a,r,n)=>{for(var i=n>1?void 0:n?pe(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&Ie(a,r,i),i};let g=class extends o{constructor(e){super(e),this.bs=e}readSync(){const e={};return[e.fromId,e.hitType,e.hitId,e.origin,e.hitPos,e.offsets,e.weaponId]=this.bs.readValue(t.UInt16,t.UInt8,t.UInt16,t.Float3,t.Float3,t.Float3,t.UInt8),e}writeSync(e){this.bs.writeValue([t.UInt16,e.fromId],[t.UInt8,e.hitType],[t.UInt16,e.hitId],[t.Float3,e.origin],[t.Float3,e.hitPos],[t.Float3,e.offsets],[t.UInt8,e.weaponId])}};D([h],g.prototype,"readSync",1),D([y],g.prototype,"writeSync",1),g=D([p(u.BulletSync)],g);var he=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,W=(e,a,r,n)=>{for(var i=n>1?void 0:n?ye(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&he(a,r,i),i};let C=class extends o{constructor(e){super(e),this.bs=e}readSync(e=!1){const a={trainSpeed:0,trailerId:0};if(e){let r;[a.vehicleId,a.lrKey,a.udKey,a.keys,a.quaternion,a.position,a.velocity,a.vehicleHealth,r,a.weaponId,a.sirenState,a.landingGearState]=this.bs.readValue(t.UInt16,t.UInt16,t.UInt16,t.UInt16,t.NormQuat,t.Float3,t.Vector,t.UInt16,t.UInt8,t.UInt8,t.Bool,t.Bool),a.vehicleHealth=a.vehicleHealth?+a.vehicleHealth:0;const{health:n,armour:i}=o.unpackHealthArmour(r);a.playerHealth=n,a.armour=i,this.bs.readValue(t.Bool)&&(a.trainSpeed=this.bs.readValue(t.Float)),this.bs.readValue(t.Bool)&&(a.trailerId=this.bs.readValue(t.UInt16))}else[a.vehicleId,a.lrKey,a.udKey,a.keys,a.quaternion,a.position,a.velocity,a.vehicleHealth,a.playerHealth,a.armour,a.additionalKey,a.weaponId,a.sirenState,a.landingGearState,a.trailerId,a.trainSpeed]=this.bs.readValue(t.UInt16,t.UInt16,t.UInt16,t.UInt16,t.Float4,t.Float3,t.Float3,t.Float,t.UInt8,t.UInt8,[t.Bits,2],[t.Bits,6],t.UInt8,t.UInt8,t.UInt16,t.Float);return a}writeSync(e,a=!1){if(a){const r=o.packHealthArmour(e.playerHealth,e.armour);this.bs.writeValue([t.UInt16,e.vehicleId],[t.UInt16,e.lrKey],[t.UInt16,e.udKey],[t.UInt16,e.keys],[t.NormQuat,e.quaternion],[t.Float3,e.position],[t.Vector,e.velocity],[t.UInt16,Math.round(e.vehicleHealth)],[t.UInt8,r],[t.UInt8,e.weaponId],[t.Bool,e.sirenState],[t.Bool,e.landingGearState]),e.trainSpeed?this.bs.writeValue([t.Bool,!0],[t.Float,e.trainSpeed]):this.bs.writeValue([t.Bool,!1]),e.trailerId?this.bs.writeValue([t.Bool,!0],[t.UInt16,e.trailerId]):this.bs.writeValue([t.Bool,!1])}else this.bs.writeValue([t.UInt16,e.vehicleId],[t.UInt16,e.lrKey],[t.UInt16,e.udKey],[t.UInt16,e.keys],[t.Float4,e.quaternion],[t.Float3,e.position],[t.Float3,e.velocity],[t.Float,e.vehicleHealth],[t.UInt8,e.playerHealth],[t.UInt8,e.armour],[t.Bits,e.additionalKey,2],[t.Bits,e.weaponId,6],[t.UInt8,e.sirenState],[t.UInt8,e.landingGearState],[t.UInt16,e.trailerId],[t.Float,e.trainSpeed])}};W([h],C.prototype,"readSync",1),W([y],C.prototype,"writeSync",1),C=W([p(u.DriverSync)],C);var Se=Object.defineProperty,me=Object.getOwnPropertyDescriptor,_=(e,a,r,n)=>{for(var i=n>1?void 0:n?me(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&Se(a,r,i),i};let b=class extends o{constructor(e){super(e),this.bs=e}readSync(){const e={};e.playerPositionX=[],e.playerPositionY=[],e.playerPositionZ=[],e.playerIsParticipant=[],e.playerIsActive=[];const a=this.bs.readInt32();if(!(a<0||a>v.MAX_PLAYERS)){e.numberOfPlayers=a;for(let r=0;r<a;r++){const n=this.bs.readUint16();if(n>=v.MAX_PLAYERS)return;if(e.playerIsParticipant[n]=!0,this.bs.readCompressedBool()){e.playerIsActive[n]=!0;const[i,l,s]=this.bs.readValue(t.Int16,t.Int16,t.Int16);e.playerPositionX[n]=i,e.playerPositionY[n]=l,e.playerPositionZ[n]=s}}return e}}writeSync(e){this.bs.writeInt32(e.numberOfPlayers);for(let a=0;a<v.MAX_PLAYERS;a++)e.playerIsParticipant[a]&&(this.bs.writeValue([t.UInt16,a],[t.CBool,e.playerIsActive[a]]),e.playerIsActive[a]&&this.bs.writeValue([t.Int16,e.playerPositionX[a]],[t.Int16,e.playerPositionY[a]],[t.Int16,e.playerPositionZ[a]]))}};_([h],b.prototype,"readSync",1),_([y],b.prototype,"writeSync",1),b=_([p(u.MarkersSync)],b);var Pe=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,M=(e,a,r,n)=>{for(var i=n>1?void 0:n?ge(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&Pe(a,r,i),i};let R=class extends o{constructor(e){super(e),this.bs=e}readSync(e=!1){const a={lrKey:0,udKey:0,surfingVehicleId:0,animationId:0,animationFlags:0};if(e){this.bs.readValue(t.Bool)&&(a.lrKey=this.bs.readValue(t.UInt16)),this.bs.readValue(t.Bool)&&(a.udKey=this.bs.readValue(t.UInt16));let r,n;[a.keys,a.position,a.quaternion,r,a.weaponId,a.specialAction,a.velocity,n]=this.bs.readValue(t.UInt16,t.Float3,t.NormQuat,t.UInt8,t.UInt8,t.UInt8,t.Vector,t.Bool);const{health:i,armour:l}=o.unpackHealthArmour(r);a.health=i,a.armour=l,n&&([a.surfingVehicleId,a.surfingOffsets]=this.bs.readValue(t.UInt16,t.Float3)),this.bs.readValue(t.Bool)&&([a.animationId,a.animationFlags]=this.bs.readValue(t.Int16,t.Int16))}else[a.lrKey,a.udKey,a.keys,a.position,a.quaternion,a.health,a.armour,a.additionalKey,a.weaponId,a.specialAction,a.velocity,a.surfingOffsets,a.surfingVehicleId,a.animationId,a.animationFlags]=this.bs.readValue(t.UInt16,t.UInt16,t.UInt16,t.Float3,t.Float4,t.UInt8,t.UInt8,[t.Bits,2],[t.Bits,6],t.UInt8,t.Float3,t.Float3,t.UInt16,t.Int16,t.Int16);return a}writeSync(e,a=!1){if(this.bs.resetWritePointer(),this.bs.writeBits(u.OnFootSync,8),a){e.lrKey?this.bs.writeValue([t.Bool,!0],[t.UInt16,e.lrKey]):this.bs.writeValue([t.Bool,!1]),e.udKey?this.bs.writeValue([t.Bool,!0],[t.UInt16,e.udKey]):this.bs.writeValue([t.Bool,!1]);const r=o.packHealthArmour(e.health,e.armour);this.bs.writeValue([t.UInt16,e.keys],[t.Float3,e.position],[t.NormQuat,e.quaternion],[t.UInt8,r],[t.UInt8,e.weaponId],[t.UInt8,e.specialAction],[t.Vector,e.velocity]),e.surfingVehicleId?this.bs.writeValue([t.Bool,!0],[t.UInt16,e.surfingVehicleId],[t.Float3,e.surfingOffsets]):this.bs.writeValue([t.Bool,!1]),e.animationId||e.animationFlags?this.bs.writeValue([t.Bool,!0],[t.Int16,e.animationId],[t.Int16,e.animationFlags]):this.bs.writeValue([t.Bool,!1])}else this.bs.writeValue([t.UInt16,e.lrKey],[t.UInt16,e.udKey],[t.UInt16,e.keys],[t.Float3,e.position],[t.Float4,e.quaternion],[t.UInt8,e.health],[t.UInt8,e.armour],[t.Bits,e.additionalKey,2],[t.Bits,e.weaponId,6],[t.UInt8,e.specialAction],[t.Float3,e.velocity],[t.Float3,e.surfingOffsets],[t.UInt16,e.surfingVehicleId],[t.Int16,e.animationId],[t.Int16,e.animationFlags])}};M([h],R.prototype,"readSync",1),M([y],R.prototype,"writeSync",1),R=M([p(u.OnFootSync)],R);var Ce=Object.defineProperty,be=Object.getOwnPropertyDescriptor,G=(e,a,r,n)=>{for(var i=n>1?void 0:n?be(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&Ce(a,r,i),i};let f=class extends o{constructor(e){super(e),this.bs=e}readSync(){const e={};return[e.vehicleId,e.driveBy,e.seatId,e.additionalKey,e.weaponId,e.playerHealth,e.playerArmour,e.lrKey,e.udKey,e.keys,e.position]=this.bs.readValue(t.UInt16,[t.Bits,2],[t.Bits,6],[t.Bits,2],[t.Bits,6],t.UInt8,t.UInt8,t.UInt16,t.UInt16,t.UInt16,t.Float3),e}writeSync(e){this.bs.writeValue([t.UInt16,e.vehicleId],[t.Bits,e.driveBy,2],[t.Bits,e.seatId,6],[t.Bits,e.additionalKey,2],[t.Bits,e.weaponId,6],[t.UInt8,e.playerHealth],[t.UInt8,e.playerArmour],[t.UInt16,e.lrKey],[t.UInt16,e.udKey],[t.UInt16,e.keys],[t.Float3,e.position])}};G([h],f.prototype,"readSync",1),G([y],f.prototype,"writeSync",1),f=G([p(u.PassengerSync)],f);var Re=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,j=(e,a,r,n)=>{for(var i=n>1?void 0:n?fe(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&Re(a,r,i),i};let N=class extends o{constructor(e){super(e),this.bs=e}readSync(){const e={};return[e.lrKey,e.udKey,e.keys,e.position]=this.bs.readValue(t.UInt16,t.UInt16,t.UInt16,t.Float3),e}writeSync(e){this.bs.writeValue([t.UInt16,e.lrKey],[t.UInt16,e.udKey],[t.UInt16,e.keys],[t.Float3,e.position])}};j([h],N.prototype,"readSync",1),j([y],N.prototype,"writeSync",1),N=j([p(u.SpectatingSync)],N);var Ne=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,L=(e,a,r,n)=>{for(var i=n>1?void 0:n?Ue(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&Ne(a,r,i),i};let U=class extends o{constructor(e){super(e),this.bs=e}readSync(){const e={};return[e.trailerId,e.position,e.quaternion,e.velocity,e.angularVelocity]=this.bs.readValue(t.UInt16,t.Float3,t.Float4,t.Float3,t.Float3),e}writeSync(e){this.bs.writeValue([t.UInt16,e.trailerId],[t.Float3,e.position],[t.Float4,e.quaternion],[t.Float3,e.velocity],[t.Float3,e.angularVelocity])}};L([h],U.prototype,"readSync",1),L([y],U.prototype,"writeSync",1),U=L([p(u.TrailerSync)],U);var Ve=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,H=(e,a,r,n)=>{for(var i=n>1?void 0:n?Oe(a,r):a,l=e.length-1,s;l>=0;l--)(s=e[l])&&(i=(n?s(a,r,i):s(i))||i);return n&&i&&Ve(a,r,i),i};let V=class extends o{constructor(e){super(e),this.bs=e}readSync(){const e={};return[e.vehicleId,e.seatId,e.roll,e.direction,e.position,e.velocity,e.angularVelocity,e.vehicleHealth]=this.bs.readValue(t.UInt16,t.UInt8,t.Float3,t.Float3,t.Float3,t.Float3,t.Float3,t.Float),e}writeSync(e){this.bs.writeValue([t.UInt16,e.vehicleId],[t.UInt8,e.seatId],[t.Float3,e.roll],[t.Float3,e.direction],[t.Float3,e.position],[t.Float3,e.velocity],[t.Float3,e.angularVelocity],[t.Float,e.vehicleHealth])}};H([h],V.prototype,"readSync",1),H([y],V.prototype,"writeSync",1),V=H([p(u.UnoccupiedSync)],V);export{P as AimSync,o as BitStream,g as BulletSync,X as IPacket,J as IRPC,C as InCarSync,le as IncomingPacket,se as IncomingRPC,q as InternalPacketIdList,b as MarkersSync,z as OPacket,ee as ORPC,R as OnFootSync,ce as OutgoingPacket,oe as OutgoingRPC,ae as PR_BITS_TO_BYTES,re as PR_BYTES_TO_BITS,te as PR_MAX_HANDLERS,E as PR_MAX_WEAPON_SLOTS,u as PacketIdList,x as PacketRpcEventType,S as PacketRpcPriority,m as PacketRpcReliability,t as PacketRpcValueType,f as PassengerSync,K as RPCIdList,c as RakNetNatives,N as SpectatingSync,U as TrailerSync,V as UnoccupiedSync,Q as onIncomingPacket,Z as onIncomingRPC,Y as onOutgoingPacket,$ as onOutgoingRPC};