Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:listcars(playerid, params[])
- {
- new
- string[512],
- string2[512],
- var[11];
- for (new i = 0; i < MAX_CARS; i ++)
- {
- if (Car_IsOwner(playerid, i))
- {
- 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]);
- strcat(string2, string);
- count++;
- format(var, sizeof(var), "PvCarID%d", count);
- SetPVarInt(playerid, var, i);
- }
- }
- format(string, sizeof(string), "Name\tFuel\n%s", string2);
- Dialog_Show(playerid, DIALOG_CALLVEH, DIALOG_STYLE_TABLIST_HEADERS, "[Your vehicles]", string, "Spawn", "Close");
- return 1;
- }
- CMD:lock(playerid, params[])
- {
- static
- id = -1;
- if ((id = Car_Nearest(playerid)) != -1)
- {
- static
- engine,
- lights,
- alarm,
- doors,
- bonnet,
- boot,
- objective;
- GetVehicleParamsEx(carData[id][carVehicle], engine, lights, alarm, doors, bonnet, boot, objective);
- if (Car_IsOwner(playerid, id) || (playerData[playerid][pFaction] != -1 && carData[id][carFaction] == GetFactionType(playerid)))
- {
- if (!carData[id][carLocked])
- {
- carData[id][carLocked] = 1;
- Car_Save(id);
- GameTextForPlayer(playerid, "You have ~r~locked~w~ the vehicle!", 5000, 1);
- PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
- SendNearbyMessage(playerid, 20.0, COLOR_PURPLE, "** %s Lock %s", GetPlayerNameEx(playerid), ReturnVehicleModelName(carData[id][carModel]));
- SendClientMessageEx(playerid, COLOR_WHITE, "DEBUG: ID: %d", id);
- SetVehicleParamsEx(carData[id][carVehicle], engine, lights, alarm, 1, bonnet, boot, objective);
- }
- else
- {
- carData[id][carLocked] = 0;
- Car_Save(id);
- GameTextForPlayer(playerid, "You have ~g~unlocked~w~ the vehicle!", 5000, 1);
- PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
- SendNearbyMessage(playerid, 20.0, COLOR_PURPLE, "** %s Unlock %s", GetPlayerNameEx(playerid), ReturnVehicleModelName(carData[id][carModel]));
- SendClientMessageEx(playerid, COLOR_WHITE, "DEBUG: ID: %d", id);
- SetVehicleParamsEx(carData[id][carVehicle], engine, lights, alarm, 0, bonnet, boot, objective);
- }
- }
- }
- return 1;
- }
- Car_Nearest(playerid)
- {
- static
- Float:fX,
- Float:fY,
- Float:fZ;
- for (new i = 0; i != MAX_CARS; i ++)
- {
- if (carData[i][carExists])
- {
- GetVehiclePos(carData[i][carVehicle], fX, fY, fZ);
- if (IsPlayerInRangeOfPoint(playerid, 3.0, fX, fY, fZ))
- {
- return i;
- }
- }
- }
- return -1;
- }
- Car_IsOwner(playerid, carid)
- {
- if (!playerData[playerid][IsLoggedIn] || playerData[playerid][pID] == -1)
- return 0;
- if ((carData[carid][carExists] && carData[carid][carOwner] != 0) && carData[carid][carOwner] == playerData[playerid][pID])
- {
- return 1;
- }
- return 0;
- }
- forward OnPlayerSpawnedCar(playerid, carid);
- public OnPlayerSpawnedCar(playerid, carid)
- {
- if (carid != -1 && carData[carid][carExists] && carData[carid][carOwner] == playerData[playerid][pID])
- {
- if (IsValidVehicle(carData[carid][carVehicle]))
- DestroyVehicle(carData[carid][carVehicle]);
- if (carData[carid][carColor1] == -1)
- carData[carid][carColor1] = random(127);
- if (carData[carid][carColor2] == -1)
- carData[carid][carColor2] = random(127);
- 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);
- }
- return 1;
- }
- Dialog:DIALOG_CALLVEH(playerid, response, listitem, inputtext[])
- {
- if (response)
- {
- new var[32];
- format(var, sizeof(var), "PvCarID%d", listitem+1);
- new carid = GetPVarInt(playerid, var);
- SetTimerEx("OnPlayerSpawnedCar", 100, 0, "dd", playerid, carid);
- SendClientMessageEx(playerid, COLOR_WHITE, "{FFFF00}%s {FFFFFF}Fuel {FFFF00}%.1f {FFFFFF}Litors", ReturnVehicleModelName(carData[carid][carModel]), carData[carid][carFuel]);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement