File size: 39,498 Bytes
72629ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | #if !defined PAWNRAKNET_INC_
#define PAWNRAKNET_INC_
#if !defined PACK_PLUGIN_VERSION
#define PACK_PLUGIN_VERSION(%0,%1,%2) (((%0) << 16) | ((%1) << 8) | (%2))
#endif
#define PAWNRAKNET_VERSION PACK_PLUGIN_VERSION(1, 6, 0)
#define PAWNRAKNET_INCLUDE_VERSION PAWNRAKNET_VERSION
#define PR_MAX_HANDLERS 256
enum PR_EventType
{
PR_INCOMING_PACKET,
PR_INCOMING_RPC,
PR_OUTGOING_PACKET,
PR_OUTGOING_RPC,
PR_INCOMING_CUSTOM_RPC,
PR_NUMBER_OF_EVENT_TYPES,
PR_OUTCOMING_PACKET = PR_OUTGOING_PACKET,
PR_OUTCOMING_RPC = PR_OUTGOING_RPC,
};
enum PR_ValueType
{
PR_INT8,
PR_INT16,
PR_INT32,
PR_UINT8,
PR_UINT16,
PR_UINT32,
PR_FLOAT,
PR_BOOL,
PR_STRING,
PR_CINT8,
PR_CINT16,
PR_CINT32,
PR_CUINT8,
PR_CUINT16,
PR_CUINT32,
PR_CFLOAT,
PR_CBOOL,
PR_CSTRING,
PR_BITS,
PR_FLOAT3,
PR_FLOAT4,
PR_VECTOR,
PR_NORM_QUAT,
PR_STRING8,
PR_STRING32,
PR_IGNORE_BITS,
};
enum PR_PacketPriority
{
PR_SYSTEM_PRIORITY,
PR_HIGH_PRIORITY,
PR_MEDIUM_PRIORITY,
PR_LOW_PRIORITY,
};
enum PR_PacketReliability
{
PR_UNRELIABLE = 6,
PR_UNRELIABLE_SEQUENCED,
PR_RELIABLE,
PR_RELIABLE_ORDERED,
PR_RELIABLE_SEQUENCED,
};
#if !defined __cplusplus
public _pawnraknet_version = PAWNRAKNET_VERSION;
#pragma unused _pawnraknet_version
public bool:_pawnraknet_is_gamemode = !defined FILTERSCRIPT;
#pragma unused _pawnraknet_is_gamemode
#define PR_BITS_TO_BYTES(%0) (((%0)+7)>>3)
#define PR_BYTES_TO_BITS(%0) ((%0)<<3)
#define PR_Handler<%0,%1>:%2(%3) \
forward pr_r%1_%2(); \
public pr_r%1_%2() PR_RegHandler(%2,"pr_"#%1"_"#%2,%0); \
forward pr_%1_%2(%3); \
public pr_%1_%2(%3)
#define IPacket:%0(%1) PR_Handler<PR_INCOMING_PACKET,ip>:%0(%1)
#define IRPC:%0(%1) PR_Handler<PR_INCOMING_RPC,ir>:%0(%1)
#define OPacket:%0(%1) PR_Handler<PR_OUTGOING_PACKET,op>:%0(%1)
#define ORPC:%0(%1) PR_Handler<PR_OUTGOING_RPC,or>:%0(%1)
#define ICustomRPC:%0(%1) PR_Handler<PR_INCOMING_CUSTOM_RPC,icr>:%0(%1)
#define IncomingPacket IPacket
#define IncomingRPC IRPC
#define OutgoingPacket OPacket
#define OutgoingRPC ORPC
#define IncomingCustomRPC ICustomRPC
#define OutcomingPacket OutgoingPacket
#define OutcomingRPC OutgoingRPC
#define PR_MAX_WEAPON_SLOTS 13
enum PR_OnFootSync
{
PR_lrKey,
PR_udKey,
PR_keys,
Float:PR_position[3],
Float:PR_quaternion[4],
PR_health,
PR_armour,
PR_weaponId,
PR_additionalKey,
PR_specialAction,
Float:PR_velocity[3],
Float:PR_surfingOffsets[3],
PR_surfingVehicleId,
PR_animationId,
PR_animationFlags,
};
enum PR_InCarSync
{
PR_vehicleId,
PR_lrKey,
PR_udKey,
PR_keys,
Float:PR_quaternion[4],
Float:PR_position[3],
Float:PR_velocity[3],
Float:PR_vehicleHealth,
PR_playerHealth,
PR_armour,
PR_weaponId,
PR_additionalKey,
PR_sirenState,
PR_landingGearState,
PR_trailerId,
Float:PR_trainSpeed,
};
enum PR_TrailerSync
{
PR_trailerId,
Float:PR_position[3],
Float:PR_quaternion[4],
Float:PR_velocity[3],
Float:PR_angularVelocity[3],
};
enum PR_PassengerSync
{
PR_vehicleId,
PR_seatId,
PR_driveBy,
PR_weaponId,
PR_additionalKey,
PR_playerHealth,
PR_playerArmour,
PR_lrKey,
PR_udKey,
PR_keys,
Float:PR_position[3],
};
enum PR_UnoccupiedSync
{
PR_vehicleId,
PR_seatId,
Float:PR_roll[3],
Float:PR_direction[3],
Float:PR_position[3],
Float:PR_velocity[3],
Float:PR_angularVelocity[3],
Float:PR_vehicleHealth,
};
enum PR_AimSync
{
PR_camMode,
Float:PR_camFrontVec[3],
Float:PR_camPos[3],
Float:PR_aimZ,
PR_camZoom,
PR_weaponState,
PR_aspectRatio,
};
enum PR_BulletSync
{
PR_hitType,
PR_hitId,
Float:PR_origin[3],
Float:PR_hitPos[3],
Float:PR_offsets[3],
PR_weaponId,
};
enum PR_SpectatingSync
{
PR_lrKey,
PR_udKey,
PR_keys,
Float:PR_position[3],
};
enum PR_MarkersSync
{
PR_numberOfPlayers,
PR_playerIsActive[MAX_PLAYERS],
PR_playerPositionX[MAX_PLAYERS],
PR_playerPositionY[MAX_PLAYERS],
PR_playerPositionZ[MAX_PLAYERS],
PR_playerIsParticipant[MAX_PLAYERS],
};
enum PR_WeaponsUpdate
{
PR_targetId,
PR_targetActorId,
PR_slotWeaponId[PR_MAX_WEAPON_SLOTS],
PR_slotWeaponAmmo[PR_MAX_WEAPON_SLOTS],
PR_slotUpdated[PR_MAX_WEAPON_SLOTS],
};
enum PR_StatsUpdate
{
PR_money,
PR_drunkLevel,
};
enum PR_RconCommand
{
PR_command[256],
};
native PR_Init();
native PR_SendPacket(BitStream:bs, playerid, PR_PacketPriority:priority = PR_HIGH_PRIORITY, PR_PacketReliability:reliability = PR_RELIABLE_ORDERED, orderingchannel = 0);
native PR_SendRPC(BitStream:bs, playerid, rpcid, PR_PacketPriority:priority = PR_HIGH_PRIORITY, PR_PacketReliability:reliability = PR_RELIABLE_ORDERED, orderingchannel = 0);
#pragma deprecated Use PR_SendPacket instead
native BS_Send(BitStream:bs, playerid, PR_PacketPriority:priority = PR_HIGH_PRIORITY, PR_PacketReliability:reliability = PR_RELIABLE_ORDERED, orderingchannel = 0) = PR_SendPacket;
#pragma deprecated Use PR_SendRPC instead
native BS_RPC(BitStream:bs, playerid, rpcid, PR_PacketPriority:priority = PR_HIGH_PRIORITY, PR_PacketReliability:reliability = PR_RELIABLE_ORDERED, orderingchannel = 0) = PR_SendRPC;
native PR_EmulateIncomingPacket(BitStream:bs, playerid);
native PR_EmulateIncomingRPC(BitStream:bs, playerid, rpcid);
#pragma deprecated Use PR_EmulateIncomingPacket instead
native BS_EmulateIncomingPacket(BitStream:bs, playerid) = PR_EmulateIncomingPacket;
#pragma deprecated Use PR_EmulateIncomingRPC instead
native BS_EmulateIncomingRPC(BitStream:bs, playerid, rpcid) = PR_EmulateIncomingRPC;
native BitStream:BS_New();
native BitStream:BS_NewCopy(BitStream:bs);
native BS_Delete(&BitStream:bs);
native BS_Reset(BitStream:bs);
native BS_ResetReadPointer(BitStream:bs);
native BS_ResetWritePointer(BitStream:bs);
native BS_IgnoreBits(BitStream:bs, number_of_bits);
native BS_SetWriteOffset(BitStream:bs, offset);
native BS_GetWriteOffset(BitStream:bs, &offset);
native BS_SetReadOffset(BitStream:bs, offset);
native BS_GetReadOffset(BitStream:bs, &offset);
native BS_GetNumberOfBitsUsed(BitStream:bs, &number);
native BS_GetNumberOfBytesUsed(BitStream:bs, &number);
native BS_GetNumberOfUnreadBits(BitStream:bs, &number);
native BS_GetNumberOfBitsAllocated(BitStream:bs, &number);
native BS_WriteValue(BitStream:bs, {PR_ValueType, Float, _}:...);
native BS_ReadValue(BitStream:bs, {PR_ValueType, Float, _}:...);
native PR_RegHandler(eventid, const publicname[], PR_EventType:type);
#define BS_ReadInt8(%0,%1) BS_ReadValue(%0,PR_INT8,%1)
#define BS_ReadInt16(%0,%1) BS_ReadValue(%0,PR_INT16,%1)
#define BS_ReadInt32(%0,%1) BS_ReadValue(%0,PR_INT32,%1)
#define BS_ReadUint8(%0,%1) BS_ReadValue(%0,PR_UINT8,%1)
#define BS_ReadUint16(%0,%1) BS_ReadValue(%0,PR_UINT16,%1)
#define BS_ReadUint32(%0,%1) BS_ReadValue(%0,PR_UINT32,%1)
#define BS_ReadFloat(%0,%1) BS_ReadValue(%0,PR_FLOAT,%1)
#define BS_ReadBool(%0,%1) BS_ReadValue(%0,PR_BOOL,%1)
#define BS_ReadString(%0,%1,%2) BS_ReadValue(%0,PR_STRING,%1,%2)
#define BS_ReadCompressedInt8(%0,%1) BS_ReadValue(%0,PR_CINT8,%1)
#define BS_ReadCompressedInt16(%0,%1) BS_ReadValue(%0,PR_CINT16,%1)
#define BS_ReadCompressedInt32(%0,%1) BS_ReadValue(%0,PR_CINT32,%1)
#define BS_ReadCompressedUint8(%0,%1) BS_ReadValue(%0,PR_CUINT8,%1)
#define BS_ReadCompressedUint16(%0,%1) BS_ReadValue(%0,PR_CUINT16,%1)
#define BS_ReadCompressedUint32(%0,%1) BS_ReadValue(%0,PR_CUINT32,%1)
#define BS_ReadCompressedFloat(%0,%1) BS_ReadValue(%0,PR_CFLOAT,%1)
#define BS_ReadCompressedBool(%0,%1) BS_ReadValue(%0,PR_CBOOL,%1)
#define BS_ReadCompressedString(%0,%1,%2) BS_ReadValue(%0,PR_CSTRING,%1,%2)
#define BS_ReadBits(%0,%1,%2) BS_ReadValue(%0,PR_BITS,%1,%2)
#define BS_ReadFloat3(%0,%1) BS_ReadValue(%0,PR_FLOAT3,%1)
#define BS_ReadFloat4(%0,%1) BS_ReadValue(%0,PR_FLOAT4,%1)
#define BS_ReadVector(%0,%1) BS_ReadValue(%0,PR_VECTOR,%1)
#define BS_ReadNormQuat(%0,%1) BS_ReadValue(%0,PR_NORM_QUAT,%1)
#define BS_ReadString8(%0,%1) BS_ReadValue(%0,PR_STRING8,%1,sizeof(%1))
#define BS_ReadString32(%0,%1) BS_ReadValue(%0,PR_STRING32,%1,sizeof(%1))
#define BS_WriteInt8(%0,%1) BS_WriteValue(%0,PR_INT8,%1)
#define BS_WriteInt16(%0,%1) BS_WriteValue(%0,PR_INT16,%1)
#define BS_WriteInt32(%0,%1) BS_WriteValue(%0,PR_INT32,%1)
#define BS_WriteUint8(%0,%1) BS_WriteValue(%0,PR_UINT8,%1)
#define BS_WriteUint16(%0,%1) BS_WriteValue(%0,PR_UINT16,%1)
#define BS_WriteUint32(%0,%1) BS_WriteValue(%0,PR_UINT32,%1)
#define BS_WriteFloat(%0,%1) BS_WriteValue(%0,PR_FLOAT,%1)
#define BS_WriteBool(%0,%1) BS_WriteValue(%0,PR_BOOL,%1)
#define BS_WriteString(%0,%1) BS_WriteValue(%0,PR_STRING,%1)
#define BS_WriteCompressedInt8(%0,%1) BS_WriteValue(%0,PR_CINT8,%1)
#define BS_WriteCompressedInt16(%0,%1) BS_WriteValue(%0,PR_CINT16,%1)
#define BS_WriteCompressedInt32(%0,%1) BS_WriteValue(%0,PR_CINT32,%1)
#define BS_WriteCompressedUint8(%0,%1) BS_WriteValue(%0,PR_CUINT8,%1)
#define BS_WriteCompressedUint16(%0,%1) BS_WriteValue(%0,PR_CUINT16,%1)
#define BS_WriteCompressedUint32(%0,%1) BS_WriteValue(%0,PR_CUINT32,%1)
#define BS_WriteCompressedFloat(%0,%1) BS_WriteValue(%0,PR_CFLOAT,%1)
#define BS_WriteCompressedBool(%0,%1) BS_WriteValue(%0,PR_CBOOL,%1)
#define BS_WriteCompressedString(%0,%1) BS_WriteValue(%0,PR_CSTRING,%1)
#define BS_WriteBits(%0,%1,%2) BS_WriteValue(%0,PR_BITS,%1,%2)
#define BS_WriteFloat3(%0,%1) BS_WriteValue(%0,PR_FLOAT3,%1)
#define BS_WriteFloat4(%0,%1) BS_WriteValue(%0,PR_FLOAT4,%1)
#define BS_WriteVector(%0,%1) BS_WriteValue(%0,PR_VECTOR,%1)
#define BS_WriteNormQuat(%0,%1) BS_WriteValue(%0,PR_NORM_QUAT,%1)
#define BS_WriteString8(%0,%1) BS_WriteValue(%0,PR_STRING8,%1)
#define BS_WriteString32(%0,%1) BS_WriteValue(%0,PR_STRING32,%1)
#define PR_EXPAND_ARR3(%0) %0[0],%0[1],%0[2]
#define PR_EXPAND_ARR4(%0) %0[0],%0[1],%0[2],%0[3]
stock BS_PackAspectRatio(Float:value)
{
return floatround((value - 1.0) * 255.0);
}
stock Float:BS_UnpackAspectRatio(value)
{
return float(value) / 255.0 + 1.0;
}
stock BS_PackCameraZoom(Float:value)
{
return floatround(((value - 35.0) / 35.0) * 63.0);
}
stock Float:BS_UnpackCameraZoom(value)
{
return (float(value) / 63.0) * 35.0 + 35.0;
}
stock BS_PackHealthArmour(health, armour, &healthArmour)
{
if (health > 0 && health < 100) {
healthArmour = (health / 7) << 4;
} else if (health >= 100) {
healthArmour = 0xF0;
} else {
healthArmour = 0;
}
if (armour > 0 && armour < 100) {
healthArmour |= (armour / 7);
} else if (armour >= 100) {
healthArmour |= 0xF;
}
}
stock BS_UnpackHealthArmour(healthArmour, &health, &armour)
{
health = healthArmour >> 4;
if (health == 0xF) {
health = 100;
} else {
health *= 7;
}
armour = healthArmour & 0xF;
if (armour == 0xF) {
armour = 100;
} else {
armour *= 7;
}
}
stock BS_ReadOnFootSync(BitStream:bs, data[PR_OnFootSync], outgoing = false)
{
if (outgoing) {
new hasLeftRight, hasUpDown, hasSurfInfo, hasAnimation, healthArmour;
BS_ReadValue(bs, PR_BOOL, hasLeftRight);
if (hasLeftRight) {
BS_ReadValue(bs, PR_UINT16, data[PR_lrKey]);
} else {
data[PR_lrKey] = 0;
}
BS_ReadValue(bs, PR_BOOL, hasUpDown);
if (hasUpDown) {
BS_ReadValue(bs, PR_UINT16, data[PR_udKey]);
} else {
data[PR_udKey] = 0;
}
BS_ReadValue(
bs,
PR_UINT16, data[PR_keys],
PR_FLOAT3, data[PR_position],
PR_NORM_QUAT, data[PR_quaternion],
PR_UINT8, healthArmour,
PR_UINT8, data[PR_weaponId],
PR_UINT8, data[PR_specialAction],
PR_VECTOR, data[PR_velocity],
PR_BOOL, hasSurfInfo
);
BS_UnpackHealthArmour(healthArmour, data[PR_health], data[PR_armour]);
if (hasSurfInfo) {
BS_ReadValue(
bs,
PR_UINT16, data[PR_surfingVehicleId],
PR_FLOAT3, data[PR_surfingOffsets]
);
} else {
data[PR_surfingVehicleId] = 0;
}
BS_ReadValue(bs, PR_BOOL, hasAnimation);
if (hasAnimation) {
BS_ReadValue(
bs,
PR_INT16, data[PR_animationId],
PR_INT16, data[PR_animationFlags]
);
} else {
data[PR_animationId] = 0;
data[PR_animationFlags] = 0;
}
} else {
BS_ReadValue(
bs,
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_FLOAT3, data[PR_position],
PR_FLOAT4, data[PR_quaternion],
PR_UINT8, data[PR_health],
PR_UINT8, data[PR_armour],
PR_BITS, data[PR_additionalKey], 2,
PR_BITS, data[PR_weaponId], 6,
PR_UINT8, data[PR_specialAction],
PR_FLOAT3, data[PR_velocity],
PR_FLOAT3, data[PR_surfingOffsets],
PR_UINT16, data[PR_surfingVehicleId],
PR_INT16, data[PR_animationId],
PR_INT16, data[PR_animationFlags]
);
}
}
stock BS_ReadInCarSync(BitStream:bs, data[PR_InCarSync], outgoing = false)
{
if (outgoing) {
new vehicleHealth, healthArmour;
BS_ReadValue(
bs,
PR_UINT16, data[PR_vehicleId],
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_NORM_QUAT, data[PR_quaternion],
PR_FLOAT3, data[PR_position],
PR_VECTOR, data[PR_velocity],
PR_UINT16, vehicleHealth,
PR_UINT8, healthArmour,
PR_UINT8, data[PR_weaponId],
PR_BOOL, data[PR_sirenState],
PR_BOOL, data[PR_landingGearState]
);
data[PR_vehicleHealth] = float(vehicleHealth);
BS_UnpackHealthArmour(healthArmour, data[PR_playerHealth], data[PR_armour]);
new hasTrainSpeed, hasTrailer;
BS_ReadValue(bs, PR_BOOL, hasTrainSpeed);
if (hasTrainSpeed) {
BS_ReadValue(bs, PR_FLOAT, data[PR_trainSpeed]);
} else {
data[PR_trainSpeed] = 0.0;
}
BS_ReadValue(bs, PR_BOOL, hasTrailer);
if (hasTrailer) {
BS_ReadValue(bs, PR_UINT16, data[PR_trailerId]);
} else {
data[PR_trailerId] = 0;
}
} else {
BS_ReadValue(
bs,
PR_UINT16, data[PR_vehicleId],
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_FLOAT4, data[PR_quaternion],
PR_FLOAT3, data[PR_position],
PR_FLOAT3, data[PR_velocity],
PR_FLOAT, data[PR_vehicleHealth],
PR_UINT8, data[PR_playerHealth],
PR_UINT8, data[PR_armour],
PR_BITS, data[PR_additionalKey], 2,
PR_BITS, data[PR_weaponId], 6,
PR_UINT8, data[PR_sirenState],
PR_UINT8, data[PR_landingGearState],
PR_UINT16, data[PR_trailerId],
PR_FLOAT, data[PR_trainSpeed]
);
}
}
stock BS_ReadTrailerSync(BitStream:bs, data[PR_TrailerSync])
{
BS_ReadValue(
bs,
PR_UINT16, data[PR_trailerId],
PR_FLOAT3, data[PR_position],
PR_FLOAT4, data[PR_quaternion],
PR_FLOAT3, data[PR_velocity],
PR_FLOAT3, data[PR_angularVelocity]
);
}
stock BS_ReadPassengerSync(BitStream:bs, data[PR_PassengerSync])
{
BS_ReadValue(
bs,
PR_UINT16, data[PR_vehicleId],
PR_BITS, data[PR_driveBy], 2,
PR_BITS, data[PR_seatId], 6,
PR_BITS, data[PR_additionalKey], 2,
PR_BITS, data[PR_weaponId], 6,
PR_UINT8, data[PR_playerHealth],
PR_UINT8, data[PR_playerArmour],
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_FLOAT3, data[PR_position]
);
}
stock BS_ReadUnoccupiedSync(BitStream:bs, data[PR_UnoccupiedSync])
{
BS_ReadValue(
bs,
PR_UINT16, data[PR_vehicleId],
PR_UINT8, data[PR_seatId],
PR_FLOAT3, data[PR_roll],
PR_FLOAT3, data[PR_direction],
PR_FLOAT3, data[PR_position],
PR_FLOAT3, data[PR_velocity],
PR_FLOAT3, data[PR_angularVelocity],
PR_FLOAT, data[PR_vehicleHealth]
);
}
stock BS_ReadAimSync(BitStream:bs, data[PR_AimSync])
{
BS_ReadValue(
bs,
PR_UINT8, data[PR_camMode],
PR_FLOAT3, data[PR_camFrontVec],
PR_FLOAT3, data[PR_camPos],
PR_FLOAT, data[PR_aimZ],
PR_BITS, data[PR_weaponState], 2,
PR_BITS, data[PR_camZoom], 6,
PR_UINT8, data[PR_aspectRatio]
);
}
stock BS_ReadBulletSync(BitStream:bs, data[PR_BulletSync])
{
BS_ReadValue(
bs,
PR_UINT8, data[PR_hitType],
PR_UINT16, data[PR_hitId],
PR_FLOAT3, data[PR_origin],
PR_FLOAT3, data[PR_hitPos],
PR_FLOAT3, data[PR_offsets],
PR_UINT8, data[PR_weaponId]
);
}
stock BS_ReadSpectatingSync(BitStream:bs, data[PR_SpectatingSync])
{
BS_ReadValue(
bs,
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_FLOAT3, data[PR_position]
);
}
stock BS_ReadMarkersSync(BitStream:bs, data[PR_MarkersSync])
{
new numberOfPlayers, playerId, isActive;
BS_ReadInt32(bs, numberOfPlayers);
if (numberOfPlayers < 0 || numberOfPlayers > MAX_PLAYERS) {
return;
}
data[PR_numberOfPlayers] = numberOfPlayers;
for (new i; i < numberOfPlayers; i++) {
playerId = isActive = 0;
BS_ReadUint16(bs, playerId);
if (playerId >= MAX_PLAYERS) {
return;
}
data[PR_playerIsParticipant][playerId] = true;
BS_ReadCompressedBool(bs, isActive);
if (isActive) {
data[PR_playerIsActive][playerId] = true;
BS_ReadValue(
bs,
PR_INT16, data[PR_playerPositionX][playerId],
PR_INT16, data[PR_playerPositionY][playerId],
PR_INT16, data[PR_playerPositionZ][playerId]
);
}
}
}
stock BS_ReadWeaponsUpdate(BitStream:bs, data[PR_WeaponsUpdate])
{
new numberOfBytes, numberOfSlots, slotId, weaponId, ammo;
BS_GetNumberOfBytesUsed(bs, numberOfBytes);
if (numberOfBytes > 5) {
numberOfSlots = (numberOfBytes - 5) / 4;
}
BS_ReadValue(
bs,
PR_UINT16, data[PR_targetId],
PR_UINT16, data[PR_targetActorId]
);
while (numberOfSlots--) {
slotId = weaponId = ammo = 0;
BS_ReadValue(
bs,
PR_UINT8, slotId,
PR_UINT8, weaponId,
PR_UINT16, ammo
);
if (slotId < PR_MAX_WEAPON_SLOTS) {
data[PR_slotWeaponId][slotId] = weaponId;
data[PR_slotWeaponAmmo][slotId] = ammo;
data[PR_slotUpdated][slotId] = true;
}
}
}
stock BS_ReadStatsUpdate(BitStream:bs, data[PR_StatsUpdate])
{
BS_ReadValue(
bs,
PR_INT32, data[PR_money],
PR_INT32, data[PR_drunkLevel]
);
}
stock BS_ReadRconCommand(BitStream:bs, data[PR_RconCommand])
{
BS_ReadValue(
bs,
PR_STRING32, data[PR_command], sizeof(data[PR_command])
);
}
stock BS_WriteOnFootSync(BitStream:bs, data[PR_OnFootSync], outgoing = false)
{
if (outgoing) {
new healthArmour;
if (data[PR_lrKey]) {
BS_WriteValue(
bs,
PR_BOOL, true,
PR_UINT16, data[PR_lrKey]
);
} else {
BS_WriteValue(bs, PR_BOOL, false);
}
if (data[PR_udKey]) {
BS_WriteValue(
bs,
PR_BOOL, true,
PR_UINT16, data[PR_udKey]
);
} else {
BS_WriteValue(bs, PR_BOOL, false);
}
BS_PackHealthArmour(data[PR_health], data[PR_armour], healthArmour);
BS_WriteValue(
bs,
PR_UINT16, data[PR_keys],
PR_FLOAT3, data[PR_position],
PR_NORM_QUAT, data[PR_quaternion],
PR_UINT8, healthArmour,
PR_UINT8, data[PR_weaponId],
PR_UINT8, data[PR_specialAction],
PR_VECTOR, data[PR_velocity]
);
if (data[PR_surfingVehicleId]) {
BS_WriteValue(
bs,
PR_BOOL, true,
PR_UINT16, data[PR_surfingVehicleId],
PR_FLOAT3, data[PR_surfingOffsets]
);
} else {
BS_WriteValue(bs, PR_BOOL, false);
}
if (data[PR_animationId] || data[PR_animationFlags]) {
BS_WriteValue(
bs,
PR_BOOL, true,
PR_INT16, data[PR_animationId],
PR_INT16, data[PR_animationFlags]
);
} else {
BS_WriteValue(bs, PR_BOOL, false);
}
} else {
BS_WriteValue(
bs,
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_FLOAT3, data[PR_position],
PR_FLOAT4, data[PR_quaternion],
PR_UINT8, data[PR_health],
PR_UINT8, data[PR_armour],
PR_BITS, data[PR_additionalKey], 2,
PR_BITS, data[PR_weaponId], 6,
PR_UINT8, data[PR_specialAction],
PR_FLOAT3, data[PR_velocity],
PR_FLOAT3, data[PR_surfingOffsets],
PR_UINT16, data[PR_surfingVehicleId],
PR_INT16, data[PR_animationId],
PR_INT16, data[PR_animationFlags]
);
}
}
stock BS_WriteInCarSync(BitStream:bs, data[PR_InCarSync], outgoing = false)
{
if (outgoing) {
new healthArmour;
BS_PackHealthArmour(data[PR_playerHealth], data[PR_armour], healthArmour);
BS_WriteValue(
bs,
PR_UINT16, data[PR_vehicleId],
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_NORM_QUAT, data[PR_quaternion],
PR_FLOAT3, data[PR_position],
PR_VECTOR, data[PR_velocity],
PR_UINT16, floatround(data[PR_vehicleHealth]),
PR_UINT8, healthArmour,
PR_UINT8, data[PR_weaponId],
PR_BOOL, data[PR_sirenState],
PR_BOOL, data[PR_landingGearState]
);
if (data[PR_trainSpeed]) {
BS_WriteValue(bs,
PR_BOOL, true,
PR_FLOAT, data[PR_trainSpeed]
);
} else {
BS_WriteValue(bs, PR_BOOL, false);
}
if (data[PR_trailerId]) {
BS_WriteValue(bs,
PR_BOOL, true,
PR_UINT16, data[PR_trailerId]
);
} else {
BS_WriteValue(bs, PR_BOOL, false);
}
} else {
BS_WriteValue(
bs,
PR_UINT16, data[PR_vehicleId],
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_FLOAT4, data[PR_quaternion],
PR_FLOAT3, data[PR_position],
PR_FLOAT3, data[PR_velocity],
PR_FLOAT, data[PR_vehicleHealth],
PR_UINT8, data[PR_playerHealth],
PR_UINT8, data[PR_armour],
PR_BITS, data[PR_additionalKey], 2,
PR_BITS, data[PR_weaponId], 6,
PR_UINT8, data[PR_sirenState],
PR_UINT8, data[PR_landingGearState],
PR_UINT16, data[PR_trailerId],
PR_FLOAT, data[PR_trainSpeed]
);
}
}
stock BS_WriteTrailerSync(BitStream:bs, data[PR_TrailerSync])
{
BS_WriteValue(
bs,
PR_UINT16, data[PR_trailerId],
PR_FLOAT3, data[PR_position],
PR_FLOAT4, data[PR_quaternion],
PR_FLOAT3, data[PR_velocity],
PR_FLOAT3, data[PR_angularVelocity]
);
}
stock BS_WritePassengerSync(BitStream:bs, data[PR_PassengerSync])
{
BS_WriteValue(
bs,
PR_UINT16, data[PR_vehicleId],
PR_BITS, data[PR_driveBy], 2,
PR_BITS, data[PR_seatId], 6,
PR_BITS, data[PR_additionalKey], 2,
PR_BITS, data[PR_weaponId], 6,
PR_UINT8, data[PR_playerHealth],
PR_UINT8, data[PR_playerArmour],
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_FLOAT3, data[PR_position]
);
}
stock BS_WriteUnoccupiedSync(BitStream:bs, data[PR_UnoccupiedSync])
{
BS_WriteValue(
bs,
PR_UINT16, data[PR_vehicleId],
PR_UINT8, data[PR_seatId],
PR_FLOAT3, data[PR_roll],
PR_FLOAT3, data[PR_direction],
PR_FLOAT3, data[PR_position],
PR_FLOAT3, data[PR_velocity],
PR_FLOAT3, data[PR_angularVelocity],
PR_FLOAT, data[PR_vehicleHealth]
);
}
stock BS_WriteAimSync(BitStream:bs, data[PR_AimSync])
{
BS_WriteValue(
bs,
PR_UINT8, data[PR_camMode],
PR_FLOAT3, data[PR_camFrontVec],
PR_FLOAT3, data[PR_camPos],
PR_FLOAT, data[PR_aimZ],
PR_BITS, data[PR_weaponState], 2,
PR_BITS, data[PR_camZoom], 6,
PR_UINT8, data[PR_aspectRatio]
);
}
stock BS_WriteBulletSync(BitStream:bs, data[PR_BulletSync])
{
BS_WriteValue(
bs,
PR_UINT8, data[PR_hitType],
PR_UINT16, data[PR_hitId],
PR_FLOAT3, data[PR_origin],
PR_FLOAT3, data[PR_hitPos],
PR_FLOAT3, data[PR_offsets],
PR_UINT8, data[PR_weaponId]
);
}
stock BS_WriteSpectatingSync(BitStream:bs, data[PR_SpectatingSync])
{
BS_WriteValue(
bs,
PR_UINT16, data[PR_lrKey],
PR_UINT16, data[PR_udKey],
PR_UINT16, data[PR_keys],
PR_FLOAT3, data[PR_position]
);
}
stock BS_WriteMarkersSync(BitStream:bs, data[PR_MarkersSync])
{
BS_WriteInt32(bs, data[PR_numberOfPlayers]);
for (new i; i < MAX_PLAYERS; i++) {
if (!data[PR_playerIsParticipant][i]) {
continue;
}
BS_WriteValue(
bs,
PR_UINT16, i,
PR_CBOOL, data[PR_playerIsActive][i]
);
if (data[PR_playerIsActive][i]) {
BS_WriteValue(
bs,
PR_INT16, data[PR_playerPositionX][i],
PR_INT16, data[PR_playerPositionY][i],
PR_INT16, data[PR_playerPositionZ][i]
);
}
}
}
stock BS_WriteWeaponsUpdate(BitStream:bs, data[PR_WeaponsUpdate])
{
BS_WriteValue(
bs,
PR_UINT16, data[PR_targetId],
PR_UINT16, data[PR_targetActorId]
);
for (new slotId; slotId < PR_MAX_WEAPON_SLOTS; slotId++) {
if (!data[PR_slotUpdated][slotId]) {
continue;
}
BS_WriteValue(
bs,
PR_UINT8, slotId,
PR_UINT8, data[PR_slotWeaponId][slotId],
PR_UINT16, data[PR_slotWeaponAmmo][slotId]
);
}
}
stock BS_WriteStatsUpdate(BitStream:bs, data[PR_StatsUpdate])
{
BS_WriteValue(
bs,
PR_INT32, data[PR_money],
PR_INT32, data[PR_drunkLevel]
);
}
stock BS_WriteRconCommand(BitStream:bs, data[PR_RconCommand])
{
BS_WriteValue(
bs,
PR_STRING32, data[PR_command]
);
}
stock PR_SendPacketToPlayerStream(BitStream:bs, playerid, PR_PacketPriority:priority = PR_HIGH_PRIORITY, PR_PacketReliability:reliability = PR_RELIABLE_ORDERED, orderingchannel = 0)
{
#if defined foreach
foreach (new i : Player) {
#else
for (new i = GetPlayerPoolSize(); i >= 0; i--) {
#endif
if (!IsPlayerStreamedIn(i, playerid)) {
continue;
}
PR_SendPacket(bs, i, priority, reliability, orderingchannel);
}
}
stock PR_SendRPCToPlayerStream(BitStream:bs, playerid, rpcid, PR_PacketPriority:priority = PR_HIGH_PRIORITY, PR_PacketReliability:reliability = PR_RELIABLE_ORDERED, orderingchannel = 0)
{
#if defined foreach
foreach (new i : Player) {
#else
for (new i = GetPlayerPoolSize(); i >= 0; i--) {
#endif
if (!IsPlayerStreamedIn(i, playerid)) {
continue;
}
PR_SendRPC(bs, i, rpcid, priority, reliability, orderingchannel);
}
}
stock PR_SendPacketToVehicleStream(BitStream:bs, vehicleid, excludedplayerid = INVALID_PLAYER_ID, PR_PacketPriority:priority = PR_HIGH_PRIORITY, PR_PacketReliability:reliability = PR_RELIABLE_ORDERED, orderingchannel = 0)
{
#if defined foreach
foreach (new i : Player) {
#else
for (new i = GetPlayerPoolSize(); i >= 0; i--) {
#endif
if (i == excludedplayerid || !IsVehicleStreamedIn(vehicleid, i)) {
continue;
}
PR_SendPacket(bs, i, priority, reliability, orderingchannel);
}
}
stock PR_SendRPCToVehicleStream(BitStream:bs, vehicleid, rpcid, excludedplayerid = INVALID_PLAYER_ID, PR_PacketPriority:priority = PR_HIGH_PRIORITY, PR_PacketReliability:reliability = PR_RELIABLE_ORDERED, orderingchannel = 0)
{
#if defined foreach
foreach (new i : Player) {
#else
for (new i = GetPlayerPoolSize(); i >= 0; i--) {
#endif
if (i == excludedplayerid || !IsVehicleStreamedIn(vehicleid, i)) {
continue;
}
PR_SendRPC(bs, i, rpcid, priority, reliability, orderingchannel);
}
}
forward OnIncomingPacket(playerid, packetid, BitStream:bs);
forward OnIncomingRPC(playerid, rpcid, BitStream:bs);
forward OnOutgoingPacket(playerid, packetid, BitStream:bs);
forward OnOutgoingRPC(playerid, rpcid, BitStream:bs);
#pragma deprecated Use OnOutgoingPacket instead
forward OnOutcomingPacket(playerid, packetid, BitStream:bs);
#pragma deprecated Use OnOutgoingRPC instead
forward OnOutcomingRPC(playerid, rpcid, BitStream:bs);
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
PR_Init();
#if defined PawnRakNet_OnFilterScriptInit
PawnRakNet_OnFilterScriptInit();
#endif
return 1;
}
#if defined _ALS_OnFilterScriptInit
#undef OnFilterScriptInit
#else
#define _ALS_OnFilterScriptInit
#endif
#define OnFilterScriptInit PawnRakNet_OnFilterScriptInit
#if defined PawnRakNet_OnFilterScriptInit
forward PawnRakNet_OnFilterScriptInit();
#endif
#else
public OnGameModeInit()
{
PR_Init();
#if defined PawnRakNet_OnGameModeInit
PawnRakNet_OnGameModeInit();
#endif
return 1;
}
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#define OnGameModeInit PawnRakNet_OnGameModeInit
#if defined PawnRakNet_OnGameModeInit
forward PawnRakNet_OnGameModeInit();
#endif
#endif
#endif
#endif |