Advertisement
Zsolesszka

[FS]LockCar 0.3 v1.3.1

May 30th, 2013
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.52 KB | None | 0 0
  1. // Vehicle Locked and UnLocked by.: Phento Date 10.03.03 v1.2
  2. // Update 2013.06.01 by.: Zsolesszka
  3. // Update 2013.06.03 Fixed, VehicleLocked array index (0-1999), GetPlayerVehicleID return valid vehicleid (1-2000)
  4.  
  5. #include <a_samp>
  6.  
  7. new
  8.     MaxPlayers,
  9.     VehicleLocked[MAX_VEHICLES] = { -1, ... };
  10.  
  11. stock
  12.     Un_Lock_Car(playerid, bool:locked)
  13. {
  14.     if(GetPlayerVehicleSeat(playerid) != 0) SendClientMessage(playerid, 0x0099FFAA, "You are not a driver!");
  15.     else
  16.     {
  17.         new
  18.             vehicleid = GetPlayerVehicleID(playerid);
  19.         if(VehicleLocked[vehicleid - 1] == ((locked)?(playerid):(-1))) SendClientMessage(playerid, 0x0099FFAA, (locked)?("Already vehicle locked!"):("The vehicle not locked!"));
  20.         else
  21.         {
  22.             VehicleLocked[vehicleid - 1] = (locked)?(playerid):(-1);
  23.             for(new p; p < MaxPlayers; p++)
  24.             {
  25.                 if(IsPlayerConnected(p) && p != playerid) { SetVehicleParamsForPlayer(vehicleid, p, false, locked); }
  26.             }
  27.             SendClientMessage(playerid, 0x0099FFAA, (locked)?("Vehicle locked!"):("Vehicle unlocked!"));
  28.         }
  29.     }
  30. }
  31.  
  32. stock
  33.     UnLockAllCar(playerid)
  34. {
  35.     for(new vehicleid = 1; vehicleid <= MAX_VEHICLES; vehicleid++)
  36.     {
  37.         if(VehicleLocked[vehicleid - 1] != playerid)
  38.         {
  39.             VehicleLocked[vehicleid - 1] = -1;
  40.             for(new p; p < MaxPlayers; p++)
  41.             {
  42.                 if(IsPlayerConnected(p)) { SetVehicleParamsForPlayer(vehicleid, p, false, false); }
  43.             }
  44.         }
  45.     }
  46. }
  47.  
  48. public
  49.     OnFilterScriptInit()
  50. {
  51.     MaxPlayers = GetMaxPlayers();
  52.     print("-----------------------------------");
  53.     print("  Lock and Unlock Car by.: Zsolesszka");
  54.     print("         v.1.3.1");
  55.     print("-----------------------------------\n");
  56.     return 1;
  57. }
  58.  
  59. public
  60.     OnPlayerDisconnect(playerid, reason)
  61. {
  62.     UnLockAllCar(playerid);
  63.     return 1;
  64. }
  65.  
  66. public
  67.     OnVehicleStreamIn(vehicleid, forplayerid)
  68. {
  69.     if(VehicleLocked[vehicleid - 1] != -1 && VehicleLocked[vehicleid - 1] != forplayerid)
  70.     {
  71.         SetVehicleParamsForPlayer(vehicleid, forplayerid, false, true); // Relock vehicle
  72.     }
  73.     return 1;
  74. }
  75.  
  76. public
  77.     OnPlayerCommandText(playerid, cmdtext[])
  78. {
  79.     if(!strcmp("/lock", cmdtext, true))
  80.     {
  81.         Un_Lock_Car(playerid, true);
  82.         return 1;
  83.     }
  84.  
  85.     if(!strcmp("/unlock", cmdtext, true))
  86.     {
  87.         Un_Lock_Car(playerid, false);
  88.         return 1;
  89.     }
  90.  
  91.     if(!strcmp("/xunlock", cmdtext, true))
  92.     {
  93.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0x0099FFAA, "You are not rcon admin!");
  94.         UnLockAllCar(-1);
  95.         SendClientMessage(playerid, 0x0099FFAA, "All Vehicle unlocked!");
  96.         return 1;
  97.     }
  98.     return 0;
  99. }
  100.  
  101. public
  102.     OnFilterScriptExit()
  103. {
  104.     UnLockAllCar(-1);
  105.     return 1;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement