1. Wheen i make the car (/vcreate) ... let's say i maked it on Chilliad (example) and i wanna park it to lets say... LSPD(example) the car respanws at Chilliad where i created it , does anyone know how i can fix the problem?
2. Wheen i wanna set the color to the car (/vsetcolor) like /vsetcolor 5 5 , it says : "You have changed the color 5-5" but the color is still from the /vcreate (white) .
pawn Код:
/* =============== CHANGE LOG: =================
April 25, 2011:
* Minor optimizations & known bugs fixed.
* Fixed a bug where the car would spawn but the plate wouldn't set!
* Added /RemoveVeh command for the .INI version!
* Added 'TogglePlayerControllable(playerid, true);' when removing the vehicle, else you would be frozen.
* Merge the FILE and MySQL version together. Togable commenting/uncommenting the line: #define USE_MYSQL_VERSION
* Added some security for the MySQL version.
* Added Paint Job saving for both .INI and MySQL versions!
April 26, 2011:
* Added mod saving for both versions!!
* Cleaned up the code a bit.
May 18, 2011:
* Fixed a few errors regarding the mod loading for the .INI version.
* Added /lock /unlock commands. /Exit command has been renamed to /VExit.
* Added Max Ownable Vehicles per player. Current limit is set to 2 vehicles.
* Fixed all known bugs ( Most recent bugs reported on the topic )
May 24, 2011:
* Fixed the vehicles not getting their mods after death.
* Cleaned up the code a bit.
*/
#include <a_samp>
#include <zcmd>
native sscanf(const data[], const format[], {Float,_}:...);
native unformat(const data[], const format[], {Float,_}:...) = sscanf;
//========
//#define USE_MYSQL_VERSION // < Uncomment this line to use INI FILE version! EX: //#define USE_MYSQL_VERSION
//========
#if defined USE_MYSQL_VERSION
#include <a_mysql>
#else
#include <SII>
#endif
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_RED 0xFF0000FF
#define CYELLOW "{9DBD1E}"
#define CORANGE "{E68C0E}"
#define CBLUE "{39AACC}"
#define CDGREEN "{6FA828}"
#define CWHITE "{FFFFFF}"
#define CRED "{FF0000}"
#define CGREY "{7D8584}"
#if defined USE_MYSQL_VERSION
// Edit your MySQL settings
#define SQL_HOST "" // HOST
#define SQL_USER "" // USER
#define SQL_PASS "" // PASS
#define SQL_DB "" // DB
#define mysql_fetch_row(%1) mysql_fetch_row_format(%1,"|")
#endif
#define MAX_BUYABLE_VEH 50 // Change to the ammount of vehicles
#define MAX_VEH_MODS 12 // Max mods ( Do not edit )
#define MAX_OWNABLE_VEH 2 // Change to the ammount of vehicles a player can own!
#define OwnedVeh(%0) ivCreated[%0]
enum _VINFO
{
vModel,
vColor1,
vColor2,
vPrice,
vOwner[MAX_PLAYER_NAME],
Float:vPosX,
Float:vPosY,
Float:vPosZ,
Float:vPosA,
vPlate[32],
vPaintJ,
vLocked
}
new
vInfo[MAX_BUYABLE_VEH][_VINFO],
ivCreated[MAX_VEHICLES],
Total_Veh_Created,
vMods[MAX_BUYABLE_VEH][MAX_VEH_MODS],
Total_Player_Vehicles[MAX_PLAYERS];
public OnFilterScriptInit()
{
#if defined USE_MYSQL_VERSION
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
mysql_debug(1);
#endif
LoadPVehicles();
return 1;
}
public OnFilterScriptExit()
{
for(new i = 0; i < MAX_BUYABLE_VEH; ++i) DestroyVehicle(i);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
if(OwnedVeh(vehicleid) != 0)
{
new
vCreated = OwnedVeh(vehicleid);
DestroyVehicle(vehicleid);
new
NewVeh = CreateVehicle(vInfo[vCreated][vModel], vInfo[vCreated][vPosX], vInfo[vCreated][vPosY], vInfo[vCreated][vPosZ], vInfo[vCreated][vPosA], vInfo[vCreated][vColor1], vInfo[vCreated][vColor2], 500000);
SetVehicleNumberPlate(NewVeh, vInfo[vCreated][vPlate]);
ChangeVehiclePaintjob(NewVeh, vInfo[vCreated][vPaintJ]);
for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
{
if(vMods[vCreated][iMod] > 0)
{
AddVehicleComponent(NewVeh, vMods[vCreated][iMod]);
}
}
printf("=- Vehicle id: %i has been re-created -=", vCreated);
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new
iVehicleID = GetPlayerVehicleID(playerid),
iMsg[120];
if(OwnedVeh(iVehicleID) != 0)
{
if(strmatch(vInfo[OwnedVeh(iVehicleID)][vOwner], "Unbought"))
{
format(iMsg, sizeof(iMsg), ""#CBLUE"Hello! You can purchase this vehicle for: "#CDGREEN"$%i", vInfo[OwnedVeh(iVehicleID)][vPrice]);
SendClientMessage(playerid, -1, iMsg);
SendClientMessage(playerid, COLOR_GREY, "Please type /Buyveh to purchase it. Or type /Exit to exit this vehicle!");
TogglePlayerControllable(playerid, false);
}
else if(strmatch(vInfo[OwnedVeh(iVehicleID)][vOwner], pName(playerid)))
{
format(iMsg, sizeof(iMsg), ""#CBLUE"Hello: "#CDGREEN"%s(%d)! "#CBLUE"Welcome back to your vehicle..", pName(playerid), playerid);
SendClientMessage(playerid, COLOR_RED, iMsg);
}
else if(strmatch(vInfo[OwnedVeh(iVehicleID)][vOwner], pName(playerid)) || vInfo[OwnedVeh(iVehicleID)][vLocked] == 1)
{
format(iMsg, sizeof(iMsg), ""CBLUE"Hello: "#CDGREEN"%s(%d)! "#CBLUE"This vehicle is belongs to: "#CDGREEN"%s!", pName(playerid), playerid, vInfo[OwnedVeh(iVehicleID)][vOwner]);
SendClientMessage(playerid, -1, iMsg);
SendClientMessage(playerid, -1, ""#CYELLOW"This vehicle is "#CRED"locked! "#CYELLOW"Please use /exit to get out of this vehicle!");
TogglePlayerControllable(playerid, false);
}
else if(strmatch(vInfo[OwnedVeh(iVehicleID)][vOwner], pName(playerid)) || vInfo[OwnedVeh(iVehicleID)][vLocked] == 0)
{
format(iMsg, sizeof(iMsg), ""CBLUE"Hello: "#CDGREEN"%s(%d)! "#CBLUE"Welcome to: "#CDGREEN"%s's vehicle!", pName(playerid), playerid, vInfo[OwnedVeh(iVehicleID)][vOwner]);
SendClientMessage(playerid, -1, iMsg);
SendClientMessage(playerid, -1, ""#CYELLOW"This vehicle is "#CDGREEN"unlocked!");
}
else
{
format(iMsg, sizeof(iMsg), ""#CBLUE"The owner of this vehicle is: "#CDGREEN"%s", vInfo[OwnedVeh(iVehicleID)][vOwner]);
SendClientMessage(playerid, -1, iMsg);
RemovePlayerFromVehicle(playerid);
}
}
}
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
if(OwnedVeh(vehicleid) != 0)
{
vInfo[OwnedVeh(vehicleid)][vColor1] = color1;
vInfo[OwnedVeh(vehicleid)][vColor2] = color2;
SavePrivVeh(OwnedVeh(vehicleid));
printf("=- Vehicle id: %i has changed colors to: %i - %i -=", OwnedVeh(vehicleid), color1, color2);
}
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
if(OwnedVeh(vehicleid) != 0)
{
vInfo[OwnedVeh(vehicleid)][vPaintJ] = paintjobid;
SavePrivVeh(OwnedVeh(vehicleid));
printf("=- Vehicle id: %i has changed paintjob to: %i -=", OwnedVeh(vehicleid), paintjobid);
}
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
new
Total_V_Mods = 0;
for(new i = 0; i < MAX_VEH_MODS; ++i)
{
if(vMods[OwnedVeh(vehicleid)][i] == 0)//Info[OwnedVeh(vehicleid)][vMods][i] == 0) If there's an empty mod slot
{
vMods[OwnedVeh(vehicleid)][i] = componentid;
SavePrivVeh(OwnedVeh(vehicleid));
printf("=- Vehicle id: %i has changed mod to: %i -=", OwnedVeh(vehicleid), componentid);
++ Total_V_Mods;
break;
}
}
if(Total_V_Mods == 0) SendClientMessage(playerid, COLOR_RED, "You cannot add more mods to your vehicle!");
return 1;
}
#if defined USE_MYSQL_VERSION
CMD:vcreate(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be admin to use this command!");
new
Float:Pos[4],
ivModel,
ivPrice,
ivColors[2],
Query[256],
iMsg[148];
if(sscanf(params, "iiii", ivModel, ivPrice, ivColors[0], ivColors[1])) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/VCreate < Vehicle Model > < Price > < Color 1 > < Color 2 >");
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
++ Total_Veh_Created;
vInfo[Total_Veh_Created][vModel] = ivModel;
vInfo[Total_Veh_Created][vColor1] = ivColors[0];
vInfo[Total_Veh_Created][vColor2] = ivColors[1];
vInfo[Total_Veh_Created][vPrice] = ivPrice;
vInfo[Total_Veh_Created][vPosX] = Pos[0];
vInfo[Total_Veh_Created][vPosY] = Pos[1];
vInfo[Total_Veh_Created][vPosZ] = Pos[2];
vInfo[Total_Veh_Created][vPosA] = Pos[3];
strmid(vInfo[Total_Veh_Created][vOwner], "Unbought", 0, 20, 20);
strmid(vInfo[Total_Veh_Created][vPlate], "ChangeME", 0, 32, 32);
vInfo[Total_Veh_Created][vPaintJ] = 0;
vInfo[Total_Veh_Created][vLocked] = 1;
for(new i = 0; i < MAX_VEH_MODS; ++i) vMods[Total_Veh_Created][i] = 0;
format(Query, sizeof(Query), "INSERT INTO `privateveh` (`vID`, `vModel`, `vColor1`, `vColor2`, `vPrice`, `vOwner`, `vPosX`, `vPosY`, `vPosZ`, `vPosA`, `vPlate`, `vPaintJ`) VALUES (%d, %d, %d, %d, %d, 'Unbought', %f, %f, %f, %f, 'ChangeME', 0)",
Total_Veh_Created,
ivModel,
ivColors[0],
ivColors[1],
ivPrice,
Pos[0],
Pos[1],
Pos[2],
Pos[3]);
mysql_query(Query);
new
cCar = CreateVehicle(ivModel, Pos[0], Pos[1], Pos[2], Pos[3], ivColors[0], ivColors[1], 500000);
SetVehicleNumberPlate(cCar, "ChangeME");
OwnedVeh(cCar) = Total_Veh_Created;
SavePrivVeh(Total_Veh_Created);
format(iMsg, sizeof(iMsg), ""#CYELLOW"Vehicle: "#CBLUE"%i (VID: %i) "#CYELLOW"has been created. Price: "#CBLUE"$%i "#CYELLOW"Plate: "#CBLUE"ChangeME", ivModel, Total_Veh_Created, ivPrice);
SendClientMessage(playerid, -1, iMsg);
return 1;
}
CMD:removeveh(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be admin to use this command!");
new
ivID = GetPlayerVehicleID(playerid);
if(OwnedVeh(ivID) != 0)
{
new
Query[80];
format(Query, sizeof(Query), "DELETE FROM `privateveh` WHERE `vID` = %i LIMIT 1", OwnedVeh(ivID));
mysql_query(Query);
vInfo[OwnedVeh(ivID)][vModel] = 0;
vInfo[OwnedVeh(ivID)][vPosX] = 0.0;
vInfo[OwnedVeh(ivID)][vPosY] = 0.0;
vInfo[OwnedVeh(ivID)][vPosZ] = 0.0;
vInfo[OwnedVeh(ivID)][vPosA] = 0.0;
vInfo[OwnedVeh(ivID)][vColor1] = 0;
vInfo[OwnedVeh(ivID)][vColor2] = 0;
vInfo[OwnedVeh(ivID)][vPrice] = 0;
strmid(vInfo[OwnedVeh(ivID)][vOwner], " ", 0, 5, 5);
strmid(vInfo[OwnedVeh(ivID)][vPlate], " ", 0, 5, 5);
vInfo[OwnedVeh(ivID)][vPaintJ] = 0;
vInfo[OwnedVeh(ivID)][vLocked] = 0;
DestroyVehicle(ivID);
OwnedVeh(OwnedVeh(ivID)) = 0;
-- Total_Veh_Created;
TogglePlayerControllable(playerid, true);
SendClientMessage(playerid, COLOR_GREY, "This vehicle has been removed!");
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not ownable!");
}
#else
CMD:vcreate(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be admin to use this command!");
new
Float:Pos[4],
ivModel,
ivPrice,
ivColors[2],
iMsg[148];
if(sscanf(params, "iiii", ivModel, ivPrice, ivColors[0], ivColors[1])) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/VCreate < Vehicle Model > < Price > < Color 1 > < Color 2 >");
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
++ Total_Veh_Created;
vInfo[Total_Veh_Created][vModel] = ivModel;
vInfo[Total_Veh_Created][vColor1] = ivColors[0];
vInfo[Total_Veh_Created][vColor2] = ivColors[1];
vInfo[Total_Veh_Created][vPrice] = ivPrice;
vInfo[Total_Veh_Created][vPosX] = Pos[0];
vInfo[Total_Veh_Created][vPosY] = Pos[1];
vInfo[Total_Veh_Created][vPosZ] = Pos[2];
vInfo[Total_Veh_Created][vPosA] = Pos[3];
strmid(vInfo[Total_Veh_Created][vOwner], "Unbought", 0, 20, 20);
strmid(vInfo[Total_Veh_Created][vPlate], "ChangeME", 0, 32, 32);
vInfo[Total_Veh_Created][vPaintJ] = 0;
vInfo[Total_Veh_Created][vLocked] = 1;
new
vFile[15];
format(vFile, sizeof(vFile), "%d.ini", Total_Veh_Created);
INI_Open(vFile);
INI_WriteInt("Model", vModel);
INI_WriteInt("Color1", ivColors[0]);
INI_WriteInt("Color2", ivColors[1]);
INI_WriteInt("Price", ivPrice);
INI_WriteString("Owner", "Unbought");
INI_WriteFloat("vPosX", Pos[0]);
INI_WriteFloat("vPosY", Pos[1]);
INI_WriteFloat("vPosZ", Pos[2]);
INI_WriteFloat("vPosA", Pos[3]);
INI_WriteString("Plate", "ChangeME");
INI_WriteInt("PaintJ", 0);
INI_Save();
INI_Close();
new
cCar = CreateVehicle(ivModel, Pos[0], Pos[1], Pos[2], Pos[3], ivColors[0], ivColors[1], 500000);
SetVehicleNumberPlate(cCar, "ChangeME");
OwnedVeh(cCar) = Total_Veh_Created;
SavePrivVeh(Total_Veh_Created);
format(iMsg, sizeof(iMsg), ""#CYELLOW"Vehicle: "#CBLUE"%i (VID: %i) "#CYELLOW"has been created. Price: "#CBLUE"$%i "#CYELLOW"Plate: "#CBLUE"ChangeME", ivModel, Total_Veh_Created, ivPrice);
SendClientMessage(playerid, -1, iMsg);
return 1;
}
CMD:removeveh(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be admin to use this command!");
new
ivID = GetPlayerVehicleID(playerid);
if(OwnedVeh(ivID) != 0)
{
new
vFile[12];
format(vFile, sizeof(vFile), "%d.ini", OwnedVeh(ivID));
INI_Remove(vFile);
vInfo[OwnedVeh(ivID)][vModel] = 0;
vInfo[OwnedVeh(ivID)][vPosX] = 0.0;
vInfo[OwnedVeh(ivID)][vPosY] = 0.0;
vInfo[OwnedVeh(ivID)][vPosZ] = 0.0;
vInfo[OwnedVeh(ivID)][vPosA] = 0.0;
vInfo[OwnedVeh(ivID)][vColor1] = 0;
vInfo[OwnedVeh(ivID)][vColor2] = 0;
vInfo[OwnedVeh(ivID)][vPrice] = 0;
strmid(vInfo[OwnedVeh(ivID)][vOwner], " ", 0, 5, 5);
strmid(vInfo[OwnedVeh(ivID)][vPlate], " ", 0, 5, 5);
vInfo[OwnedVeh(ivID)][vPaintJ] = 0;
vInfo[OwnedVeh(ivID)][vLocked] = 1;
DestroyVehicle(ivID);
OwnedVeh(OwnedVeh(ivID)) = 0;
-- Total_Veh_Created;
TogglePlayerControllable(playerid, true);
SendClientMessage(playerid, COLOR_GREY, "This vehicle has been removed!");
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not ownable!");
}
#endif
CMD:buyveh(playerid, params[])
{
for(new i = 0; i < MAX_BUYABLE_VEH; ++i)
{
if(strmatch(vInfo[i][vOwner], pName(playerid)))
{
Total_Player_Vehicles[playerid] = Total_Player_Vehicles[playerid] + 1;
}
}
if(Total_Player_Vehicles[playerid] >= MAX_OWNABLE_VEH) return SendClientMessage(playerid, -1, ""#CRED"You've reached the limit of "#CBLUE""#MAX_OWNABLE_VEH" "#CRED"ownable vehicles!!");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You need to be in a buyable vehicle to purchase it!");
new
ivID = GetPlayerVehicleID(playerid);
if(OwnedVeh(ivID) != 0)
{
if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid)))
{
SendClientMessage(playerid, COLOR_RED, "This vehicle already has an owner!");
return 1;
}
if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], "Unbought"))
{
if(vInfo[OwnedVeh(ivID)][vPrice] < GetPlayerMoney(playerid))
{
strmid(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid), 0, 128, 128);
new
Float:vPos[4];
GetVehiclePos(ivID, vPos[0], vPos[1], vPos[2]);
GetVehicleZAngle(ivID, vPos[3]);
strmid(vInfo[OwnedVeh(ivID)][vPlate], pName(playerid), 0, 32, 32);
vInfo[OwnedVeh(ivID)][vLocked] = 1;
SetVehicleNumberPlate(ivID, pName(playerid));
SetVehicleToRespawn(ivID);
SetVehiclePos(ivID, vPos[0], vPos[1], vPos[2]);
SetVehicleZAngle(ivID, vPos[3]);
PutPlayerInVehicle(playerid, ivID, 0);
GivePlayerMoney(playerid, - vInfo[OwnedVeh(ivID)][vPrice]);
SendClientMessage(playerid, -1, ""#CYELLOW"Have fun with your private vehicle!");
SendClientMessage(playerid, -1, ""#CBLUE"Your vehicle is "#CDGREEN"locked.");
TogglePlayerControllable(playerid, true);
SavePrivVeh(OwnedVeh(ivID));
printf("=- Vehicle id: %i has been bought by: %s -=", OwnedVeh(ivID), pName(playerid));
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash to purchase this vehicle!");
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not for sale!");
}
else return SendClientMessage(playerid, COLOR_RED, "This is not a buyable vehicle!");
}
CMD:sellveh(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
new
ivID = GetPlayerVehicleID(playerid),
Float:Pos[4];
GetVehiclePos(ivID, Pos[0], Pos[1], Pos[2]);
GetVehicleZAngle(ivID, Pos[3]);
if(OwnedVeh(ivID) != 0)
{
if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid)))
{
vInfo[OwnedVeh(ivID)][vPosX] = Pos[0];
vInfo[OwnedVeh(ivID)][vPosY] = Pos[1];
vInfo[OwnedVeh(ivID)][vPosZ] = Pos[2];
vInfo[OwnedVeh(ivID)][vPosA] = Pos[3];
vInfo[OwnedVeh(ivID)][vPrice] = vInfo[OwnedVeh(ivID)][vPrice];
strmid(vInfo[OwnedVeh(ivID)][vOwner], "Unbought", 0, 20, 20);
strmid(vInfo[OwnedVeh(ivID)][vPlate], "ChangeME", 0, 32, 32);
vInfo[OwnedVeh(ivID)][vLocked] = 1;
GivePlayerMoney(playerid, vInfo[OwnedVeh(ivID)][vPrice] - 10000);
SendClientMessage(playerid, COLOR_GREY, "You've sold this vehicle and the money has been given back!");
SetVehicleNumberPlate(ivID, "ChangeME");
SetVehicleToRespawn(ivID);
SetVehiclePos(ivID, Pos[0], Pos[1], Pos[2]);
SetVehicleZAngle(ivID, Pos[3]);
SavePrivVeh(OwnedVeh(ivID));
printf("=- Vehicle id: %i has been sold by: %s -=", OwnedVeh(ivID), pName(playerid));
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle does not belong to you!");
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not ownable!");
}
CMD:park(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
new
ivID = GetPlayerVehicleID(playerid),
Float:Pos[4];
if(OwnedVeh(ivID) != 0)
{
if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid)))
{
GetVehiclePos(ivID, Pos[0], Pos[1], Pos[2]);
GetVehicleZAngle(ivID, Pos[3]);
vInfo[OwnedVeh(ivID)][vPosX] = Pos[0];
vInfo[OwnedVeh(ivID)][vPosY] = Pos[1];
vInfo[OwnedVeh(ivID)][vPosZ] = Pos[2];
vInfo[OwnedVeh(ivID)][vPosA] = Pos[3];
SendClientMessage(playerid, COLOR_GREY, "This vehicle has been parked here. This will also be the spawn point!");
SavePrivVeh(OwnedVeh(ivID));
printf("=- Vehicle id: %i has been parked by: %s at: x: %.2f .. y: %.2f .. z: %.2f .. a: %.2f -=", OwnedVeh(ivID), pName(playerid), Pos[0], Pos[1], Pos[2], Pos[3]);
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle does not belong to you!");
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not ownable!");
}
CMD:removemods(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
new
ivID = GetPlayerVehicleID(playerid);
if(OwnedVeh(ivID) != 0)
{
if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid)))
{
for(new i = 0; i < MAX_VEH_MODS; ++i) vMods[OwnedVeh(ivID)][i] = 0;
SendClientMessage(playerid, COLOR_GREY, "All mods on this vehicle have been successfully removed!");
SavePrivVeh(OwnedVeh(ivID));
printf("=- Vehicle id: %i has had all its mods removed -=", OwnedVeh(ivID));
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle does not belong to you!");
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not ownable!");
}
CMD:plate(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
new
ivID = GetPlayerVehicleID(playerid),
iMsg[120];
if(isnull(params)) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/Plate < Plate Number / Name >");
if(strlen(params) < 0 || strlen(params) > 32) return SendClientMessage(playerid, COLOR_RED, "The plate number / name must be between 0 - 32 characters!");
if(OwnedVeh(ivID) != 0)
{
if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid)))
{
new
Float:vPos[4];
GetVehiclePos(ivID, vPos[0], vPos[1], vPos[2]);
GetVehicleZAngle(ivID, vPos[3]);
strmid(vInfo[OwnedVeh(ivID)][vPlate], params, 0, 32, 32);
SetVehicleNumberPlate(ivID, params);
SetVehicleToRespawn(ivID);
SetVehiclePos(ivID, vPos[0], vPos[1], vPos[2]);
SetVehicleZAngle(ivID, vPos[3]);
PutPlayerInVehicle(playerid, ivID, 0);
format(iMsg, sizeof(iMsg), ""#CBLUE"You've set your vehicle's plate number to: "#CDGREEN"%s", params);
SendClientMessage(playerid, -1, iMsg);
SavePrivVeh(ivID);
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle does not belong to you!");
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not ownable!");
}
CMD:lock(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
new
ivID = GetPlayerVehicleID(playerid);
if(OwnedVeh(ivID) != 0)
{
if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid)))
{
vInfo[OwnedVeh(ivID)][vLocked] = 1;
SendClientMessage(playerid, -1, ""#CBLUE"You've successfully "#CDGREEN"locked "#CBLUE"your vehicle!");
SavePrivVeh(OwnedVeh(ivID));
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle does not belong to you!");
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not ownable!");
}
CMD:unlock(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
new
ivID = GetPlayerVehicleID(playerid);
if(OwnedVeh(ivID) != 0)
{
if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid)))
{
vInfo[OwnedVeh(ivID)][vLocked] = 0;
SendClientMessage(playerid, -1, ""#CBLUE"You've successfully "#CRED"unlocked "#CBLUE"your vehicle!");
SavePrivVeh(OwnedVeh(ivID));
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle does not belong to you!");
}
else return SendClientMessage(playerid, COLOR_RED, "This vehicle is not ownable!");
}
CMD:vsetprice(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be admin to use this command!");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You need to be in a buyable vehicle to set a price!");
new
ivPrice = strval(params),
ivID = GetPlayerVehicleID(playerid),
iMsg[75];
if(isnull(params)) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/VSetPrice < Price >");
if(OwnedVeh(ivID) != 0)
{
vInfo[OwnedVeh(ivID)][vPrice] = ivPrice;
format(iMsg, sizeof(iMsg), ""#CDGREEN"The price for this vehicle has been set to: "#CBLUE"$%i", ivPrice);
SendClientMessage(playerid, -1, iMsg);
SavePrivVeh(OwnedVeh(ivID));
printf("=- Vehicle id: %i's price has been set to: $%i by: %s -=", OwnedVeh(ivID), ivPrice, pName(playerid));
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This is not a buyable vehicle!");
}
CMD:vsetowner(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be admin to use this command!");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You need to be in a vehicle to set an owner!");
new
nvOwner,
iMsg[95],
Float:aPos[3],
ivID = GetPlayerVehicleID(playerid);
if(sscanf(params, "u", nvOwner)) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/vSetOwner < New Owner >");
if(!IsPlayerConnected(nvOwner)) return SendClientMessage(playerid, COLOR_RED, "That user is not online!");
if(OwnedVeh(ivID) != 0)
{
strmid(vInfo[OwnedVeh(ivID)][vOwner], pName(nvOwner), 0, 24, 24);
strmid(vInfo[OwnedVeh(ivID)][vPlate], pName(nvOwner), 0, 32, 32);
format(iMsg, sizeof(iMsg), ""#CDGREEN"You've made: "#CBLUE"%s(%d) "#CDGREEN"owner of this vehicle!", pName(nvOwner), nvOwner);
SendClientMessage(playerid, -1, iMsg);
GetPlayerPos(playerid, aPos[0], aPos[1], aPos[2]);
format(iMsg, sizeof(iMsg), ""#CDGREEN"Admin: "#CBLUE"%s(%d) "#CDGREEN"has made you owner of vehicle id: "#CBLUE"%i", pName(playerid), playerid, OwnedVeh(ivID));
SendClientMessage(nvOwner, -1, iMsg);
SetPlayerPos(nvOwner, aPos[0], aPos[1], aPos[2]);
SavePrivVeh(OwnedVeh(ivID));
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This is not a buyable vehicle!");
}
CMD:vsetcolor(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be admin to use this command!");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to change its color!");
new
vColors[2],
iMsg[65],
ivID = GetPlayerVehicleID(playerid);
if(sscanf(params, "ii", vColors[0], vColors[1])) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/vSetColor < Color1 > < Color2 >");
if(OwnedVeh(ivID) != 0)
{
ChangeVehicleColor(OwnedVeh(ivID), vColors[0], vColors[1]);
vInfo[OwnedVeh(ivID)][vColor1] = vColors[0];
vInfo[OwnedVeh(ivID)][vColor2] = vColors[1];
format(iMsg, sizeof(iMsg), ""#CDGREEN"You've set this vehicle's color to: "#CBLUE"%i - %i", vColors[0], vColors[1]);
SendClientMessage(playerid, -1, iMsg);
SavePrivVeh(OwnedVeh(ivID));
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "This is not a buyable vehicle!");
}
CMD:vexit(playerid, params[])
{
if(ivCreated[GetPlayerVehicleID(playerid)] != 0)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, true);
}
return 1;
}
#if defined USE_MYSQL_VERSION
stock SavePrivVeh(iVehicleID)
{
new
Query[512],
SQL_vOwner[MAX_PLAYER_NAME],
SQL_vPlate[32];
mysql_real_escape_string(vInfo[iVehicleID][vOwner], SQL_vOwner);
mysql_real_escape_string(vInfo[iVehicleID][vPlate], SQL_vPlate);
format(Query, sizeof(Query), "UPDATE `privateveh` SET `vModel` = %i, `vColor1` = %i, `vColor2` = %i, `vPrice` = %i, `vOwner` = '%s', `vPosX` = %f, `vPosY` = %f, `vPosZ` = %f, `vPosA` = %f, `vPlate` = '%s', `vPaintJ` = %i,\
`vMod1` = %i, `vMod2` = %i, `vMod3` = %i, `vMod4` = %i, `vMod5` = %i, `vMod6` = %i, `vMod7` = %i, `vMod8` = %i, `vMod9` = %i, `vMod10` = %i, `vMod11` = %i, `vMod12` = %i, `Locked` = %i WHERE `vID` = %i LIMIT 1",
vInfo[iVehicleID][vModel],
vInfo[iVehicleID][vColor1],
vInfo[iVehicleID][vColor2],
vInfo[iVehicleID][vPrice],
SQL_vOwner,
vInfo[iVehicleID][vPosX],
vInfo[iVehicleID][vPosY],
vInfo[iVehicleID][vPosZ],
vInfo[iVehicleID][vPosA],
SQL_vPlate,
vInfo[iVehicleID][vPaintJ],
vMods[iVehicleID][0],
vMods[iVehicleID][1],
vMods[iVehicleID][2],
vMods[iVehicleID][3],
vMods[iVehicleID][4],
vMods[iVehicleID][5],
vMods[iVehicleID][6],
vMods[iVehicleID][7],
vMods[iVehicleID][8],
vMods[iVehicleID][9],
vMods[iVehicleID][10],
vMods[iVehicleID][11],
vInfo[iVehicleID][vLocked],
iVehicleID);
mysql_query(Query);
return 1;
}
stock LoadPVehicles()
{
new
Query[1024],
vModel2,
vC[2],
vPrice2,
vOwner2[MAX_PLAYER_NAME],
Float:Pos[4],
vID,
PlateNum[32],
vPaint_Job,
vModsToLoad[12],
vLock;
mysql_query("SELECT * FROM `privateveh` WHERE `vID` < "#MAX_BUYABLE_VEH" ORDER BY vID");
mysql_store_result();
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(Query))
{
print("\n==============================================================\n");
sscanf(Query, "p<|>iiiiis[24]ffffs[32]iiiiiiiiiiiiii",
vID, vModel2, vC[0], vC[1], vPrice2, vOwner2, Pos[0], Pos[1], Pos[2], Pos[3], PlateNum, vPaint_Job,
vModsToLoad[0], vModsToLoad[1], vModsToLoad[2], vModsToLoad[3], vModsToLoad[4], vModsToLoad[5],
vModsToLoad[6], vModsToLoad[7], vModsToLoad[8], vModsToLoad[9], vModsToLoad[10], vModsToLoad[11], vLock);
printf("VID:\t\t%i", vID);
vInfo[vID][vModel] = vModel2; printf("Model:\t\t%i", vModel2);
vInfo[vID][vColor1] = vC[0]; printf("Color 1:\t%i", vC[0]);
vInfo[vID][vColor2] = vC[1]; printf("Color 2:\t%i", vC[1]);
vInfo[vID][vPrice] = vPrice2; printf("Price:\t\t$%i", vPrice2);
strmid(vInfo[vID][vOwner], vOwner2, 0, 24, 24); printf("Owner:\t\t%s", vOwner2);
vInfo[vID][vPosX] = Pos[0]; printf("Spawn X:\t%f", Pos[0]);
vInfo[vID][vPosY] = Pos[1]; printf("Spawn Y:\t%f", Pos[1]);
vInfo[vID][vPosZ] = Pos[2]; printf("Spawn Z:\t%f", Pos[2]);
vInfo[vID][vPosA] = Pos[3]; printf("Spawn A:\t%f", Pos[3]);
strmid(vInfo[vID][vPlate], PlateNum, 0, 32, 32); printf("Plate:\t\t%s", PlateNum);
vInfo[vID][vPaintJ] = vPaint_Job; printf("PaintJ:\t\t%i", vPaint_Job);
vInfo[vID][vLocked] = vLock; printf("Locked:\t\t%i", vLock);
vMods[vID][0] = vModsToLoad[0]; printf("Mod 1:\t\t%i", vModsToLoad[0]);
vMods[vID][1] = vModsToLoad[1]; printf("Mod 2:\t\t%i", vModsToLoad[1]);
vMods[vID][2] = vModsToLoad[2]; printf("Mod 3:\t\t%i", vModsToLoad[2]);
vMods[vID][3] = vModsToLoad[3]; printf("Mod 4:\t\t%i", vModsToLoad[3]);
vMods[vID][4] = vModsToLoad[4]; printf("Mod 5:\t\t%i", vModsToLoad[4]);
vMods[vID][5] = vModsToLoad[5]; printf("Mod 6:\t\t%i", vModsToLoad[5]);
vMods[vID][6] = vModsToLoad[6]; printf("Mod 7:\t\t%i", vModsToLoad[6]);
vMods[vID][7] = vModsToLoad[7]; printf("Mod 8:\t\t%i", vModsToLoad[7]);
vMods[vID][8] = vModsToLoad[8]; printf("Mod 9:\t\t%i", vModsToLoad[8]);
vMods[vID][9] = vModsToLoad[9]; printf("Mod 10:\t\t%i", vModsToLoad[9]);
vMods[vID][10] = vModsToLoad[10]; printf("Mod 11:\t\t%i", vModsToLoad[10]);
vMods[vID][11] = vModsToLoad[11]; printf("Mod 12:\t\t%i", vModsToLoad[11]);
print("\n==============================================================\n");
new
vCarID = CreateVehicle(vInfo[vID][vModel], vInfo[vID][vPosX], vInfo[vID][vPosY], vInfo[vID][vPosZ], vInfo[vID][vPosA], vInfo[vID][vColor1], vInfo[vID][vColor2], 500000);
SetVehicleNumberPlate(vCarID, vInfo[vID][vPlate]);
ChangeVehiclePaintjob(vCarID, vInfo[vID][vPaintJ]);
for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
{
if(vMods[vCarID][iMod] > 0)
{
AddVehicleComponent(vCarID, vMods[vCarID][iMod]);
}
}
OwnedVeh(vCarID) = vID;
++ Total_Veh_Created;
}
}
mysql_free_result();
printf("** A total of: \"%i\" vehicle(s) were loaded!", Total_Veh_Created);
print("\n==============================================================");
print("Dynamic Vehicle Ownership By: [U]214 - MySQL Version Loaded...");
print("==============================================================\n");
return Total_Veh_Created;
}
#else
stock SavePrivVeh(iVehicleID)
{
new
iStr[15];
format(iStr, sizeof(iStr), "%d.ini", iVehicleID);
if(INI_Open(iStr))
{
INI_WriteInt("Model", vInfo[iVehicleID][vModel]);
INI_WriteInt("Color1", vInfo[iVehicleID][vColor1]);
INI_WriteInt("Color2", vInfo[iVehicleID][vColor2]);
INI_WriteInt("Price", vInfo[iVehicleID][vPrice]);
INI_WriteString("Owner", vInfo[iVehicleID][vOwner]);
INI_WriteFloat("vPosX", vInfo[iVehicleID][vPosX]);
INI_WriteFloat("vPosY", vInfo[iVehicleID][vPosY]);
INI_WriteFloat("vPosZ", vInfo[iVehicleID][vPosZ]);
INI_WriteFloat("vPosA", vInfo[iVehicleID][vPosA]);
INI_WriteString("Plate", vInfo[iVehicleID][vPlate]);
INI_WriteInt("PaintJ", vInfo[iVehicleID][vPaintJ]);
// Mod loading
INI_WriteInt("vMod1", vMods[iVehicleID][0]);
INI_WriteInt("vMod2", vMods[iVehicleID][1]);
INI_WriteInt("vMod3", vMods[iVehicleID][2]);
INI_WriteInt("vMod4", vMods[iVehicleID][3]);
INI_WriteInt("vMod5", vMods[iVehicleID][4]);
INI_WriteInt("vMod6", vMods[iVehicleID][5]);
INI_WriteInt("vMod7", vMods[iVehicleID][6]);
INI_WriteInt("vMod8", vMods[iVehicleID][7]);
INI_WriteInt("vMod9", vMods[iVehicleID][8]);
INI_WriteInt("vMod10", vMods[iVehicleID][9]);
INI_WriteInt("vMod11", vMods[iVehicleID][10]);
INI_WriteInt("vMod12", vMods[iVehicleID][11]);
INI_WriteInt("Locked", vInfo[iVehicleID][vLocked]);
INI_Save();
INI_Close();
}
return 1;
}
stock LoadPVehicles()
{
for(new i = 0; i < MAX_BUYABLE_VEH; ++i)
{
new
vFile[15];
format(vFile, sizeof(vFile), "%d.ini", i);
if(INI_Exist(vFile))
{
INI_Open(vFile);
print("\n=============================================================\n");
vInfo[i][vModel] = INI_ReadInt("Model"); printf("Model:\t\t%i", vInfo[i][vModel]);
vInfo[i][vColor1] = INI_ReadInt("Color1"); printf("Color 1:\t%i", vInfo[i][vColor1]);
vInfo[i][vColor2] = INI_ReadInt("Color2"); printf("Color 2:\t%i", vInfo[i][vColor2]);
vInfo[i][vPrice] = INI_ReadInt("Price"); printf("Price:\t\t$%i", vInfo[i][vPrice]);
INI_ReadString(vInfo[i][vOwner], "Owner", 24); printf("Owner:\t\t%s", vInfo[i][vOwner]);
vInfo[i][vPosX] = INI_ReadFloat("vPosX"); printf("Spawn X:\t%f", vInfo[i][vPosX]);
vInfo[i][vPosY] = INI_ReadFloat("vPosY"); printf("Spawn Y:\t%f", vInfo[i][vPosY]);
vInfo[i][vPosZ] = INI_ReadFloat("vPosZ"); printf("Spawn Z:\t%f", vInfo[i][vPosZ]);
vInfo[i][vPosA] = INI_ReadFloat("vPosA"); printf("Spawn A:\t%f", vInfo[i][vPosA]);
INI_ReadString(vInfo[i][vPlate], "Plate", 32); printf("Plate:\t\t%s", vInfo[i][vPlate]);
vInfo[i][vPaintJ] = INI_ReadInt("PaintJ"); printf("PaintJ:\t\t%i", vInfo[i][vPaintJ]);
vInfo[i][vLocked] = INI_ReadInt("Locked"); printf("Locked:\t\t%i", vInfo[i][vLocked]);
vMods[i][0] = INI_ReadInt("vMod1"); printf("Mod 1:\t\t%i", vMods[i][0]);
vMods[i][1] = INI_ReadInt("vMod2"); printf("Mod 2:\t\t%i", vMods[i][1]);
vMods[i][2] = INI_ReadInt("vMod3"); printf("Mod 3:\t\t%i", vMods[i][2]);
vMods[i][3] = INI_ReadInt("vMod4"); printf("Mod 4:\t\t%i", vMods[i][3]);
vMods[i][4] = INI_ReadInt("vMod5"); printf("Mod 5:\t\t%i", vMods[i][4]);
vMods[i][5] = INI_ReadInt("vMod6"); printf("Mod 6:\t\t%i", vMods[i][5]);
vMods[i][6] = INI_ReadInt("vMod7"); printf("Mod 7:\t\t%i", vMods[i][6]);
vMods[i][7] = INI_ReadInt("vMod8"); printf("Mod 8:\t\t%i", vMods[i][7]);
vMods[i][8] = INI_ReadInt("vMod9"); printf("Mod 9:\t\t%i", vMods[i][8]);
vMods[i][9] = INI_ReadInt("vMod10"); printf("Mod 10:\t\t%i", vMods[i][9]);
vMods[i][10] = INI_ReadInt("vMod11"); printf("Mod 11:\t\t%i", vMods[i][10]);
vMods[i][11] = INI_ReadInt("vMod12"); printf("Mod 12:\t\t%i", vMods[i][11]);
print("\n=============================================================\n");
new
vCarID = CreateVehicle(vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], 500000);
SetVehicleNumberPlate(vCarID, vInfo[i][vPlate]);
ChangeVehiclePaintjob(vCarID, vInfo[i][vPaintJ]);
for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
{
if(vMods[vCarID][iMod] > 0)
{
AddVehicleComponent(vCarID, vMods[vCarID][iMod]);
}
}
OwnedVeh(vCarID) = i;
++ Total_Veh_Created;
INI_Close();
}
}
printf("** A total of: \"%i\" vehicle(s) were loaded!", Total_Veh_Created);
print("\n=============================================================");
print("Dynamic Vehicle Ownership By: [U]214 - .INI Version Loaded...");
print("=============================================================\n");
return 1;
}
#endif
stock strmatch(const String1[], const String2[])
{
if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
{
return true;
}
else
{
return false;
}
}
stock pName(iPlayer)
{
new
iName[MAX_PLAYER_NAME];
GetPlayerName(iPlayer, iName, sizeof(iName));
return iName;
}
Fixed the problem but still not working ,still it goes in the place i createdit after respawning....