Advertisement
Guest User

Untitled

a guest
Nov 14th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.06 KB | None | 0 0
  1. CMD:listcars(playerid, params[])
  2. {
  3.     new
  4.         string[512],
  5.         string2[512],
  6.         var[11];
  7.  
  8.     for (new i = 0; i < MAX_CARS; i ++)
  9.     {
  10.         if (Car_IsOwner(playerid, i))
  11.         {
  12.             format(string, sizeof(string), "%s\t{D0AEEB}({FFFFFF}%.1f/%.1f L{D0AEEB})\n", ReturnVehicleModelName(carData[i][carModel]), carData[i][carFuel], vehicleData[carData[i][carModel] - 400][vFuel]);
  13.             strcat(string2, string);
  14.             count++;
  15.             format(var, sizeof(var), "PvCarID%d", count);
  16.             SetPVarInt(playerid, var, i);
  17.         }
  18.     }
  19.  
  20.     format(string, sizeof(string), "Name\tFuel\n%s", string2);
  21.     Dialog_Show(playerid, DIALOG_CALLVEH, DIALOG_STYLE_TABLIST_HEADERS, "[Your vehicles]", string, "Spawn", "Close");
  22.     return 1;
  23. }
  24.  
  25. CMD:lock(playerid, params[])
  26. {
  27.     static
  28.         id = -1;
  29.  
  30.     if ((id = Car_Nearest(playerid)) != -1)
  31.     {
  32.         static
  33.             engine,
  34.             lights,
  35.             alarm,
  36.             doors,
  37.             bonnet,
  38.             boot,
  39.             objective;
  40.  
  41.         GetVehicleParamsEx(carData[id][carVehicle], engine, lights, alarm, doors, bonnet, boot, objective);
  42.  
  43.         if (Car_IsOwner(playerid, id) || (playerData[playerid][pFaction] != -1 && carData[id][carFaction] == GetFactionType(playerid)))
  44.         {
  45.             if (!carData[id][carLocked])
  46.             {
  47.                 carData[id][carLocked] = 1;
  48.                 Car_Save(id);
  49.  
  50.                 GameTextForPlayer(playerid, "You have ~r~locked~w~ the vehicle!", 5000, 1);
  51.                 PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
  52.  
  53.                 SendNearbyMessage(playerid, 20.0, COLOR_PURPLE, "** %s Lock %s", GetPlayerNameEx(playerid), ReturnVehicleModelName(carData[id][carModel]));
  54.                 SendClientMessageEx(playerid, COLOR_WHITE, "DEBUG: ID: %d", id);
  55.  
  56.                 SetVehicleParamsEx(carData[id][carVehicle], engine, lights, alarm, 1, bonnet, boot, objective);
  57.             }
  58.             else
  59.             {
  60.                 carData[id][carLocked] = 0;
  61.                 Car_Save(id);
  62.  
  63.                 GameTextForPlayer(playerid, "You have ~g~unlocked~w~ the vehicle!", 5000, 1);
  64.                 PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
  65.  
  66.                 SendNearbyMessage(playerid, 20.0, COLOR_PURPLE, "** %s Unlock %s", GetPlayerNameEx(playerid), ReturnVehicleModelName(carData[id][carModel]));
  67.                 SendClientMessageEx(playerid, COLOR_WHITE, "DEBUG: ID: %d", id);
  68.  
  69.                 SetVehicleParamsEx(carData[id][carVehicle], engine, lights, alarm, 0, bonnet, boot, objective);
  70.             }
  71.         }
  72.     }
  73.     return 1;
  74. }
  75.  
  76. Car_Nearest(playerid)
  77. {
  78.     static
  79.         Float:fX,
  80.         Float:fY,
  81.         Float:fZ;
  82.  
  83.     for (new i = 0; i != MAX_CARS; i ++)
  84.     {
  85.         if (carData[i][carExists])
  86.         {
  87.             GetVehiclePos(carData[i][carVehicle], fX, fY, fZ);
  88.  
  89.             if (IsPlayerInRangeOfPoint(playerid, 3.0, fX, fY, fZ))
  90.             {
  91.                 return i;
  92.             }
  93.         }
  94.     }
  95.     return -1;
  96. }
  97.  
  98. Car_IsOwner(playerid, carid)
  99. {
  100.     if (!playerData[playerid][IsLoggedIn] || playerData[playerid][pID] == -1)
  101.         return 0;
  102.  
  103.     if ((carData[carid][carExists] && carData[carid][carOwner] != 0) && carData[carid][carOwner] == playerData[playerid][pID])
  104.     {
  105.         return 1;
  106.     }
  107.  
  108.     return 0;
  109. }
  110.  
  111. forward OnPlayerSpawnedCar(playerid, carid);
  112. public OnPlayerSpawnedCar(playerid, carid)
  113. {
  114.     if (carid != -1 && carData[carid][carExists] && carData[carid][carOwner] == playerData[playerid][pID])
  115.     {
  116.         if (IsValidVehicle(carData[carid][carVehicle]))
  117.             DestroyVehicle(carData[carid][carVehicle]);
  118.  
  119.         if (carData[carid][carColor1] == -1)
  120.             carData[carid][carColor1] = random(127);
  121.  
  122.         if (carData[carid][carColor2] == -1)
  123.             carData[carid][carColor2] = random(127);
  124.  
  125.         carData[carid][carVehicle] = CreateVehicle(carData[carid][carModel], carData[carid][carPosX], carData[carid][carPosY], carData[carid][carPosZ], carData[carid][carPosA], carData[carid][carColor1], carData[carid][carColor2], -1);
  126.     }
  127.     return 1;
  128. }
  129.  
  130. Dialog:DIALOG_CALLVEH(playerid, response, listitem, inputtext[])
  131. {
  132.     if (response)
  133.     {
  134.         new var[32];
  135.         format(var, sizeof(var), "PvCarID%d", listitem+1);
  136.         new carid = GetPVarInt(playerid, var);
  137.         SetTimerEx("OnPlayerSpawnedCar", 100, 0, "dd", playerid, carid);
  138.         SendClientMessageEx(playerid, COLOR_WHITE, "{FFFF00}%s {FFFFFF}Fuel {FFFF00}%.1f {FFFFFF}Litors", ReturnVehicleModelName(carData[carid][carModel]), carData[carid][carFuel]);
  139.     }
  140.     return 1;
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement