Advertisement
Guest User

Untitled

a guest
Dec 8th, 2017
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.84 KB | None | 0 0
  1. /*
  2.     Disable Vehicle Fire Sync
  3.     AdrianGraber
  4. */
  5.  
  6. #define FILTERSCRIPT
  7.  
  8. #include <a_samp>
  9. #include <Pawn.RakNet>
  10.  
  11. const VEHICLE_SYNC = 200;
  12. new CallbackTime[MAX_PLAYERS];
  13. static const DetectedModels[] =
  14. {
  15.     //Add here ModelIDs of vehicles you want to disallow firing from vehicle
  16.     //In this examlpe I will add Hunter, Sea Sparrow and Rhino
  17.     //Try not to use this in normal vehicles, as it will prevent nitro syncing
  18.     425,
  19.     432,
  20.     447
  21. };
  22.  
  23. public OnFilterScriptInit()
  24. {
  25.     print("\n--------------------------------------");
  26.     print("   Disallow Vehicle Fire Started...    ");
  27.     print("--------------------------------------\n");
  28.     return 1;
  29. }
  30.  
  31. public OnFilterScriptExit()
  32. {
  33.     return 1;
  34. }
  35.  
  36. IPacket:VEHICLE_SYNC(playerid, BitStream:bs)
  37. {
  38.  
  39.     new inCarData[PR_InCarSync];
  40.  
  41.     BS_IgnoreBits(bs, 8);
  42.     BS_ReadInCarSync(bs, inCarData);
  43.    
  44.     new modelid = GetVehicleModel(inCarData[PR_vehicleId]);
  45.  
  46.     //RIDE2DAY
  47.     for(new i; i != sizeof(DetectedModels); i++)
  48.     {
  49.         if(modelid == DetectedModels[i])
  50.         {
  51.             break;
  52.         }
  53.  
  54.         if(sizeof(DetectedModels) - i == 1)
  55.         {
  56.             return 1;
  57.         }
  58.     }
  59.    
  60.     if((inCarData[PR_keys] & KEY_FIRE) || (inCarData[PR_keys] & KEY_ACTION))
  61.     {
  62.         inCarData[PR_keys] &= ~KEY_FIRE;
  63.         inCarData[PR_keys] &= ~KEY_ACTION;
  64.  
  65.         BS_SetWriteOffset(bs, 8);
  66.         BS_WriteInCarSync(bs, inCarData);
  67.        
  68.         if(CallbackTime[playerid] < gettime())
  69.         {
  70.             CallLocalFunction("OnPlayerFiresForbiddenVeh", "d", playerid);
  71.             CallbackTime[playerid] = gettime() + 5;
  72.         }
  73.  
  74.     }
  75.  
  76.     return 1;
  77. }
  78.  
  79. forward OnPlayerFiresForbiddenVeh(playerid);
  80. public OnPlayerFiresForbiddenVeh(playerid)
  81. {
  82.     SendClientMessage(playerid, -1, "You can't fire with this vehicle! Your action will not be synced!"); //Example, better to do this with a Dialog or something to scare the player
  83.     return 1;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement