27.12.2014, 06:02
forward LoadStock();
forward InsertCar(playerid,model,value,namecar[],type,stockid);
forward LoadStock();
enum vInfo
{
vID,
vStock,
vPrice
};
new Stock[46][vInfo];
public LoadStock()
{
new result[100],index = 0;
mysql_query(SQL,"SELECT * FROM `stock` ORDER BY `stock`.`ID` ASC");
mysql_store_result();
while(mysql_retrieve_row())
{
index++;
new i = index;
mysql_get_field("ID", result); Stock[i][vID] = strval(result);
mysql_get_field("Stock", result); Stock[i][vStock] = strval(result);
mysql_get_field("Price", result); Stock[i][vPrice] = strval(result);
}
mysql_free_result();
return 1;
}
CMD:buycar(playerid, params[])
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_WHITE,"{FFB870}Please get out of the car.");
if(IsPlayerInRangeOfPoint(playerid, 7.0, 1110.3126,-1796.9833,16.593)
{
if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_WHITE, "{FFB870}You need to be level 3 to buy a vehicle.");
ShowPlayerDialog(playerid,DIALOG_CARBUY, DIALOG_STYLE_LIST, "Vehicle:", "Low Vehicles\nMedium Vehicle\nSport Vehicles\nBike\nAir vehicles\nSpecial Vehicles", "Select", "Close");
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}You are not the place where you can buy a car.");
return 1;
}
CMDetcar(playerid, params[])
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 6) return SCM(playerid,COLOR_WHITE,AdminOnly);
new model[10],test,tableid,string[64];
if(sscanf(params, "s[10]ii",model,test,tableid)) return SendClientMessage(playerid, 0xFFFFFFFF, "{B8DBFF}Syntax: /setcar <Stock-Price> <Ammount> <Table ID>");
if(strcmp(model,"stock",true) == 0)
{
Stock[tableid][vStock] = test;
format(string,sizeof(string),"You set the stock to %d.",test);
SCM(playerid,COLOR_WHITE,string);
format(string, sizeof(string), "UPDATE stock SET Stock='%d' WHERE ID=%d", Stock[tableid][vStock], tableid);
mysql_query(SQL,string);
return 1;
}
if(strcmp(model,"price",true) == 0)
{
Stock[tableid][vPrice] = test;
format(string,sizeof(string),"You set the price to %s.",FormatNumber(test));
SCM(playerid,COLOR_WHITE,string);
format(string, sizeof(string), "UPDATE stock SET Price='%d' WHERE ID=%d", Stock[tableid][vPrice], tableid);
mysql_query(SQL,string);
return 1;
}
}
return 1;
}
public InsertCar(playerid,model,value,namecar[],type,stockid)
{
new string[128],sendername[25];
new idd = Findcar();
GetPlayerName(playerid,sendername,sizeof(sendernam e));
if(idd != 0)
{
if(GetPlayerCash(playerid) < value) return SCM(playerid,COLOR_WHITE,"{FFB870}You do not have enough money.");
if(type == 1)
{
if(PlayerInfo[playerid][pPcarkey] == 0)
{
PlayerInfo[playerid][pPcarkey] = idd;
Update(playerid,pPcarkeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else
{
if(PlayerInfo[playerid][pPremiumAccount] == 1)
{
if(PlayerInfo[playerid][pprcarkey] == 0)
{
PlayerInfo[playerid][pprcarkey] = idd;
Update(playerid,pprcarkeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a premium car.");
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}You own a car and for own two cars you need Premium Account.");
}
}
else if(type == 2)
{
if(PlayerInfo[playerid][pmotokey] == 0)
{
PlayerInfo[playerid][pmotokey] = idd;
Update(playerid,pmotokeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a bike.");
}
else if(type == 3)
{
if(PlayerInfo[playerid][phelikey] == 0)
{
PlayerInfo[playerid][phelikey] = idd;
Update(playerid,phelikeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a plane.");
}
Stock[stockid][vStock]--;
format(string, sizeof(string), "UPDATE stock SET Stock='%d' WHERE ID='%d'", Stock[stockid][vStock],stockid);
mysql_query(SQL,string);
if(personalcar[playerid] != 0)
{
DestroyVehicle(personalcar[playerid]);
OwnedVeh(personalcar[playerid]) = 0;
personalcar[playerid] = 0;
}
GivePlayerCash(playerid,-value);
Update(playerid,pCashx);
CarInfo[idd][cSell] = 1;
CarInfo[idd][cID] = idd;
CarInfo[idd][cModel] = model;
CarInfo[idd][cColorOne] = 1;
CarInfo[idd][cColorTwo] = 1;
strmid(CarInfo[idd][cOwner], sendername, 0, strlen(sendername), 255);
strmid(CarInfo[idd][cDescription],namecar, 0, strlen(namecar), 255);
CarInfo[idd][cValue] = value;
strmid(CarInfo[idd][cLicense], "NewCar", 0, 6, 255);
CarInfo[idd][cOwned] = 1;
CarInfo[idd][cLock] = 0;
CarInfo[idd][cTimed] = 0;
CarInfo[idd][cInscarprice] = 100;
CarInfo[idd][cInsurancecar] = 4;
CarInfo[idd][cKM] = 0.0;
CarInfo[idd][cPaintJ] = 6;
CarInfo[idd][mod1] = 0;
CarInfo[idd][mod2] = 0;
CarInfo[idd][mod3] = 0;
CarInfo[idd][mod4] = 0;
CarInfo[idd][mod5] = 0;
CarInfo[idd][mod6] = 0;
CarInfo[idd][mod7] = 0;
CarInfo[idd][mod8] = 0;
CarInfo[idd][mod9] = 0;
CarInfo[idd][mod10] = 0;
CarInfo[idd][mod11] = 0;
CarInfo[idd][mod12] = 0;
CarInfo[idd][mod13] = 0;
CarInfo[idd][mod14] = 0;
CarInfo[idd][mod15] = 0;
CarInfo[idd][mod16] = 0;
CarInfo[idd][mod17] = 0;
vUpdate(idd, cModsx); //
vUpdate(idd, cPaintJx); //
vUpdate(idd, cSellx); //
vUpdate(idd, cLocationxx); //
vUpdate(idd, cLocationyx); //
vUpdate(idd, cLocationzx); //
vUpdate(idd, cAnglex); //
vUpdate(idd, cModelx); //
vUpdate(idd, cColorOnex); //
vUpdate(idd, cColorTwox); //
vUpdate(idd, cOwnerx); //
vUpdate(idd, cValuex); //
vUpdate(idd, cLicensex); //
vUpdate(idd, cDescriptionx); //
vUpdate(idd, cLockx); //
vUpdate(idd, cTimedx); //
vUpdate(idd, cInscarpricex); //
vUpdate(idd, cInsurancecarx); //
vUpdate(idd, cKMx); //
vUpdate(idd, cOwnedx); //
new car = CreateVehicle(CarInfo[idd][cModel],CarInfo[idd][cLocationx],CarInfo[idd][cLocationy],CarInfo[idd][cLocationz],CarInfo[idd][cAngle],1,1,500000);
SetVehicleNumberPlate(car,CarInfo[idd][cLicense]);
new disp[184];
format(disp,sizeof(disp),"You bought %s.Please take your car and park it elsewhere.",CarInfo[idd][cDescription]);
SCM(playerid,COLOR_LIGHTBLUE,disp);
OwnedVeh(car) = idd;
personalcar[playerid] = car;
masini++;
SwitchKey[playerid] = 1;
}
if(idd == 0)
{
mysql_query(SQL,"SELECT * FROM `cars`");
mysql_store_result();
idd = mysql_num_rows()+1;
mysql_free_result();
if(type == 1)
{
if(PlayerInfo[playerid][pPcarkey] == 0)
{
PlayerInfo[playerid][pPcarkey] = idd;
Update(playerid,pPcarkeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else
{
if(PlayerInfo[playerid][pPremiumAccount] == 1)
{
if(PlayerInfo[playerid][pprcarkey] == 0)
{
PlayerInfo[playerid][pprcarkey] = idd;
Update(playerid,pprcarkeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a premium car.");
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}You own a car and for own two cars you need Premium Account.");
}
}
else if(type == 2)
{
if(PlayerInfo[playerid][pmotokey] == 0)
{
PlayerInfo[playerid][pmotokey] = idd;
Update(playerid,pmotokeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a bike.");
}
else if(type == 3)
{
if(PlayerInfo[playerid][phelikey] == 0)
{
PlayerInfo[playerid][phelikey] = idd;
Update(playerid,phelikeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a plane.");
}
if(personalcar[playerid] != 0)
{
DestroyVehicle(personalcar[playerid]);
OwnedVeh(personalcar[playerid]) = 0;
personalcar[playerid] = 0;
}
CarInfo[idd][cID] = idd;
CarInfo[idd][cModel] = model;
CarInfo[idd][cColorOne] = 1;
CarInfo[idd][cColorTwo] = 1;
strmid(CarInfo[idd][cOwner], sendername, 0, strlen(sendername), 255);
strmid(CarInfo[idd][cDescription],namecar, 0, strlen(namecar), 255);
CarInfo[idd][cValue] = value;
strmid(CarInfo[idd][cLicense], "NewCar", 0, 6, 255);
CarInfo[idd][cOwned] = 1;
CarInfo[idd][cLock] = 0;
CarInfo[idd][cTimed] = 0;
CarInfo[idd][cInscarprice] = 100;
CarInfo[idd][cInsurancecar] = 4;
CarInfo[idd][cKM] = 0.0;
CarInfo[idd][cSell] = 1;
CarInfo[idd][cPaintJ] = 6;
CarInfo[idd][mod1] = 0;
CarInfo[idd][mod2] = 0;
CarInfo[idd][mod3] = 0;
CarInfo[idd][mod4] = 0;
CarInfo[idd][mod5] = 0;
CarInfo[idd][mod6] = 0;
CarInfo[idd][mod7] = 0;
CarInfo[idd][mod8] = 0;
CarInfo[idd][mod9] = 0;
CarInfo[idd][mod10] = 0;
CarInfo[idd][mod11] = 0;
CarInfo[idd][mod12] = 0;
CarInfo[idd][mod13] = 0;
CarInfo[idd][mod14] = 0;
CarInfo[idd][mod15] = 0;
CarInfo[idd][mod16] = 0;
CarInfo[idd][mod17] = 0;
format(string, sizeof(string),"INSERT INTO cars (ID, Model) VALUES (%d, %d)", idd, CarInfo[idd][cModel]);
mysql_query(SQL,string);
vUpdate(idd, cModsx); //
vUpdate(idd, cPaintJx); //
vUpdate(idd, cSellx); //
vUpdate(idd, cLocationxx); //
vUpdate(idd, cLocationyx); //
vUpdate(idd, cLocationzx); //
vUpdate(idd, cAnglex); //
vUpdate(idd, cColorOnex); //
vUpdate(idd, cColorTwox); //
vUpdate(idd, cOwnerx); //
vUpdate(idd, cValuex); //
vUpdate(idd, cLicensex); //
vUpdate(idd, cDescriptionx); //
vUpdate(idd, cLockx); //
vUpdate(idd, cTimedx); //
vUpdate(idd, cInscarpricex); //
vUpdate(idd, cInsurancecarx); //
vUpdate(idd, cKMx); //
vUpdate(idd, cOwnedx); //
new car = CreateVehicle(CarInfo[idd][cModel],CarInfo[idd][cLocationx],CarInfo[idd][cLocationy],CarInfo[idd][cLocationz],CarInfo[idd][cAngle],1,1,500000);
SetVehicleNumberPlate(car,CarInfo[idd][cLicense]);
new disp[184];
format(disp,sizeof(disp),"You bought %s.Please take your car and park it elsewhere.",CarInfo[idd][cDescription]);
SCM(playerid,COLOR_LIGHTBLUE,disp);
OwnedVeh(car) = idd;
personalcar[playerid] = car;
masini++;
SwitchKey[playerid] = 1;
}
return 1;
}
public vUpdate(vehicleid, type)
{
new gQuery[1024];
switch(type)
{
case cLocationxx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Locationx`='%f' WHERE `ID`='%d'",CarInfo[vehicleid][cLocationx],vehicleid);
mysql_query(SQL, gQuery);
}
case cLocationyx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Locationy`='%f' WHERE `ID`='%d'",CarInfo[vehicleid][cLocationy],vehicleid);
mysql_query(SQL, gQuery);
}
case cLocationzx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Locationz`='%f' WHERE `ID`='%d'",CarInfo[vehicleid][cLocationz],vehicleid);
mysql_query(SQL, gQuery);
}
case cAnglex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Angle`='%f' WHERE `ID`='%d'",CarInfo[vehicleid][cAngle],vehicleid);
mysql_query(SQL, gQuery);
}
case cModelx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Model`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cModel],vehicleid);
mysql_query(SQL, gQuery);
}
case cColorOnex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `ColorOne`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cColorOne],vehicleid);
mysql_query(SQL, gQuery);
}
case cColorTwox:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `ColorTwo`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cColorTwo],vehicleid);
mysql_query(SQL, gQuery);
}
case cOwnerx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Owner`='%s' WHERE `ID`='%d'",CarInfo[vehicleid][cOwner],vehicleid);
mysql_query(SQL, gQuery);
}
case cValuex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Value`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cValue],vehicleid);
mysql_query(SQL, gQuery);
}
case cLicensex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `License`='%s' WHERE `ID`='%d'",CarInfo[vehicleid][cLicense],vehicleid);
mysql_query(SQL, gQuery);
}
case cDescriptionx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Description`='%s' WHERE `ID`='%d'",CarInfo[vehicleid][cDescription],vehicleid);
mysql_query(SQL, gQuery);
}
case cLockx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Lockk`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cLock],vehicleid);
mysql_query(SQL, gQuery);
}
case cTimedx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Timed`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cTimed],vehicleid);
mysql_query(SQL, gQuery);
}
case cInscarpricex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Inscarprice`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cInscarprice],vehicleid);
mysql_query(SQL, gQuery);
}
case cInsurancecarx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Insurancecar`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cInsurancecar],vehicleid);
mysql_query(SQL, gQuery);
}
case cKMx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `KM`='%.2f' WHERE `ID`='%d'",CarInfo[vehicleid][cKM],vehicleid);
mysql_query(SQL, gQuery);
}
case cOwnedx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Owned`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cOwned],vehicleid);
mysql_query(SQL, gQuery);
}
case cSellx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Sell`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cSell],vehicleid);
mysql_query(SQL, gQuery);
}
case cModsx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `mod1`='%d',`mod2`='%d',`mod3`='%d',`mod4`='%d',`m od5`='%d',`mod6`='%d',`mod7`='%d',`mod8`='%d',`mod 9`='%d',`mod10`='%d',`mod11`='%d',`mod12`='%d',`mo d13`='%d',`mod14`='%d',`mod15`='%d',`mod16`='%d',` mod17`='%d' WHERE `ID`='%d'",
CarInfo[vehicleid][mod1],
CarInfo[vehicleid][mod2],
CarInfo[vehicleid][mod3],
CarInfo[vehicleid][mod4],
CarInfo[vehicleid][mod5],
CarInfo[vehicleid][mod6],
CarInfo[vehicleid][mod7],
CarInfo[vehicleid][mod8],
CarInfo[vehicleid][mod9],
CarInfo[vehicleid][mod10],
CarInfo[vehicleid][mod11],
CarInfo[vehicleid][mod12],
CarInfo[vehicleid][mod13],
CarInfo[vehicleid][mod14],
CarInfo[vehicleid][mod15],
CarInfo[vehicleid][mod16],
CarInfo[vehicleid][mod17],
vehicleid);
mysql_query(SQL, gQuery);
}
case cPaintJx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `PaintJ`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cPaintJ],vehicleid);
mysql_query(SQL, gQuery);
}
}
return 1;
}
forward InsertCar(playerid,model,value,namecar[],type,stockid);
forward LoadStock();
enum vInfo
{
vID,
vStock,
vPrice
};
new Stock[46][vInfo];
public LoadStock()
{
new result[100],index = 0;
mysql_query(SQL,"SELECT * FROM `stock` ORDER BY `stock`.`ID` ASC");
mysql_store_result();
while(mysql_retrieve_row())
{
index++;
new i = index;
mysql_get_field("ID", result); Stock[i][vID] = strval(result);
mysql_get_field("Stock", result); Stock[i][vStock] = strval(result);
mysql_get_field("Price", result); Stock[i][vPrice] = strval(result);
}
mysql_free_result();
return 1;
}
CMD:buycar(playerid, params[])
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_WHITE,"{FFB870}Please get out of the car.");
if(IsPlayerInRangeOfPoint(playerid, 7.0, 1110.3126,-1796.9833,16.593)
{
if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_WHITE, "{FFB870}You need to be level 3 to buy a vehicle.");
ShowPlayerDialog(playerid,DIALOG_CARBUY, DIALOG_STYLE_LIST, "Vehicle:", "Low Vehicles\nMedium Vehicle\nSport Vehicles\nBike\nAir vehicles\nSpecial Vehicles", "Select", "Close");
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}You are not the place where you can buy a car.");
return 1;
}
CMDetcar(playerid, params[])
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 6) return SCM(playerid,COLOR_WHITE,AdminOnly);
new model[10],test,tableid,string[64];
if(sscanf(params, "s[10]ii",model,test,tableid)) return SendClientMessage(playerid, 0xFFFFFFFF, "{B8DBFF}Syntax: /setcar <Stock-Price> <Ammount> <Table ID>");
if(strcmp(model,"stock",true) == 0)
{
Stock[tableid][vStock] = test;
format(string,sizeof(string),"You set the stock to %d.",test);
SCM(playerid,COLOR_WHITE,string);
format(string, sizeof(string), "UPDATE stock SET Stock='%d' WHERE ID=%d", Stock[tableid][vStock], tableid);
mysql_query(SQL,string);
return 1;
}
if(strcmp(model,"price",true) == 0)
{
Stock[tableid][vPrice] = test;
format(string,sizeof(string),"You set the price to %s.",FormatNumber(test));
SCM(playerid,COLOR_WHITE,string);
format(string, sizeof(string), "UPDATE stock SET Price='%d' WHERE ID=%d", Stock[tableid][vPrice], tableid);
mysql_query(SQL,string);
return 1;
}
}
return 1;
}
public InsertCar(playerid,model,value,namecar[],type,stockid)
{
new string[128],sendername[25];
new idd = Findcar();
GetPlayerName(playerid,sendername,sizeof(sendernam e));
if(idd != 0)
{
if(GetPlayerCash(playerid) < value) return SCM(playerid,COLOR_WHITE,"{FFB870}You do not have enough money.");
if(type == 1)
{
if(PlayerInfo[playerid][pPcarkey] == 0)
{
PlayerInfo[playerid][pPcarkey] = idd;
Update(playerid,pPcarkeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else
{
if(PlayerInfo[playerid][pPremiumAccount] == 1)
{
if(PlayerInfo[playerid][pprcarkey] == 0)
{
PlayerInfo[playerid][pprcarkey] = idd;
Update(playerid,pprcarkeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a premium car.");
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}You own a car and for own two cars you need Premium Account.");
}
}
else if(type == 2)
{
if(PlayerInfo[playerid][pmotokey] == 0)
{
PlayerInfo[playerid][pmotokey] = idd;
Update(playerid,pmotokeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a bike.");
}
else if(type == 3)
{
if(PlayerInfo[playerid][phelikey] == 0)
{
PlayerInfo[playerid][phelikey] = idd;
Update(playerid,phelikeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a plane.");
}
Stock[stockid][vStock]--;
format(string, sizeof(string), "UPDATE stock SET Stock='%d' WHERE ID='%d'", Stock[stockid][vStock],stockid);
mysql_query(SQL,string);
if(personalcar[playerid] != 0)
{
DestroyVehicle(personalcar[playerid]);
OwnedVeh(personalcar[playerid]) = 0;
personalcar[playerid] = 0;
}
GivePlayerCash(playerid,-value);
Update(playerid,pCashx);
CarInfo[idd][cSell] = 1;
CarInfo[idd][cID] = idd;
CarInfo[idd][cModel] = model;
CarInfo[idd][cColorOne] = 1;
CarInfo[idd][cColorTwo] = 1;
strmid(CarInfo[idd][cOwner], sendername, 0, strlen(sendername), 255);
strmid(CarInfo[idd][cDescription],namecar, 0, strlen(namecar), 255);
CarInfo[idd][cValue] = value;
strmid(CarInfo[idd][cLicense], "NewCar", 0, 6, 255);
CarInfo[idd][cOwned] = 1;
CarInfo[idd][cLock] = 0;
CarInfo[idd][cTimed] = 0;
CarInfo[idd][cInscarprice] = 100;
CarInfo[idd][cInsurancecar] = 4;
CarInfo[idd][cKM] = 0.0;
CarInfo[idd][cPaintJ] = 6;
CarInfo[idd][mod1] = 0;
CarInfo[idd][mod2] = 0;
CarInfo[idd][mod3] = 0;
CarInfo[idd][mod4] = 0;
CarInfo[idd][mod5] = 0;
CarInfo[idd][mod6] = 0;
CarInfo[idd][mod7] = 0;
CarInfo[idd][mod8] = 0;
CarInfo[idd][mod9] = 0;
CarInfo[idd][mod10] = 0;
CarInfo[idd][mod11] = 0;
CarInfo[idd][mod12] = 0;
CarInfo[idd][mod13] = 0;
CarInfo[idd][mod14] = 0;
CarInfo[idd][mod15] = 0;
CarInfo[idd][mod16] = 0;
CarInfo[idd][mod17] = 0;
vUpdate(idd, cModsx); //
vUpdate(idd, cPaintJx); //
vUpdate(idd, cSellx); //
vUpdate(idd, cLocationxx); //
vUpdate(idd, cLocationyx); //
vUpdate(idd, cLocationzx); //
vUpdate(idd, cAnglex); //
vUpdate(idd, cModelx); //
vUpdate(idd, cColorOnex); //
vUpdate(idd, cColorTwox); //
vUpdate(idd, cOwnerx); //
vUpdate(idd, cValuex); //
vUpdate(idd, cLicensex); //
vUpdate(idd, cDescriptionx); //
vUpdate(idd, cLockx); //
vUpdate(idd, cTimedx); //
vUpdate(idd, cInscarpricex); //
vUpdate(idd, cInsurancecarx); //
vUpdate(idd, cKMx); //
vUpdate(idd, cOwnedx); //
new car = CreateVehicle(CarInfo[idd][cModel],CarInfo[idd][cLocationx],CarInfo[idd][cLocationy],CarInfo[idd][cLocationz],CarInfo[idd][cAngle],1,1,500000);
SetVehicleNumberPlate(car,CarInfo[idd][cLicense]);
new disp[184];
format(disp,sizeof(disp),"You bought %s.Please take your car and park it elsewhere.",CarInfo[idd][cDescription]);
SCM(playerid,COLOR_LIGHTBLUE,disp);
OwnedVeh(car) = idd;
personalcar[playerid] = car;
masini++;
SwitchKey[playerid] = 1;
}
if(idd == 0)
{
mysql_query(SQL,"SELECT * FROM `cars`");
mysql_store_result();
idd = mysql_num_rows()+1;
mysql_free_result();
if(type == 1)
{
if(PlayerInfo[playerid][pPcarkey] == 0)
{
PlayerInfo[playerid][pPcarkey] = idd;
Update(playerid,pPcarkeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else
{
if(PlayerInfo[playerid][pPremiumAccount] == 1)
{
if(PlayerInfo[playerid][pprcarkey] == 0)
{
PlayerInfo[playerid][pprcarkey] = idd;
Update(playerid,pprcarkeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a premium car.");
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}You own a car and for own two cars you need Premium Account.");
}
}
else if(type == 2)
{
if(PlayerInfo[playerid][pmotokey] == 0)
{
PlayerInfo[playerid][pmotokey] = idd;
Update(playerid,pmotokeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a bike.");
}
else if(type == 3)
{
if(PlayerInfo[playerid][phelikey] == 0)
{
PlayerInfo[playerid][phelikey] = idd;
Update(playerid,phelikeyx);
CarInfo[idd][cLocationx] = 1098.5378;
CarInfo[idd][cLocationy] = -1769.7567;
CarInfo[idd][cLocationz] = 13.0752;
CarInfo[idd][cAngle] = 89.8502;
}
else return SCM(playerid,COLOR_WHITE,"{FFB870}Already own a plane.");
}
if(personalcar[playerid] != 0)
{
DestroyVehicle(personalcar[playerid]);
OwnedVeh(personalcar[playerid]) = 0;
personalcar[playerid] = 0;
}
CarInfo[idd][cID] = idd;
CarInfo[idd][cModel] = model;
CarInfo[idd][cColorOne] = 1;
CarInfo[idd][cColorTwo] = 1;
strmid(CarInfo[idd][cOwner], sendername, 0, strlen(sendername), 255);
strmid(CarInfo[idd][cDescription],namecar, 0, strlen(namecar), 255);
CarInfo[idd][cValue] = value;
strmid(CarInfo[idd][cLicense], "NewCar", 0, 6, 255);
CarInfo[idd][cOwned] = 1;
CarInfo[idd][cLock] = 0;
CarInfo[idd][cTimed] = 0;
CarInfo[idd][cInscarprice] = 100;
CarInfo[idd][cInsurancecar] = 4;
CarInfo[idd][cKM] = 0.0;
CarInfo[idd][cSell] = 1;
CarInfo[idd][cPaintJ] = 6;
CarInfo[idd][mod1] = 0;
CarInfo[idd][mod2] = 0;
CarInfo[idd][mod3] = 0;
CarInfo[idd][mod4] = 0;
CarInfo[idd][mod5] = 0;
CarInfo[idd][mod6] = 0;
CarInfo[idd][mod7] = 0;
CarInfo[idd][mod8] = 0;
CarInfo[idd][mod9] = 0;
CarInfo[idd][mod10] = 0;
CarInfo[idd][mod11] = 0;
CarInfo[idd][mod12] = 0;
CarInfo[idd][mod13] = 0;
CarInfo[idd][mod14] = 0;
CarInfo[idd][mod15] = 0;
CarInfo[idd][mod16] = 0;
CarInfo[idd][mod17] = 0;
format(string, sizeof(string),"INSERT INTO cars (ID, Model) VALUES (%d, %d)", idd, CarInfo[idd][cModel]);
mysql_query(SQL,string);
vUpdate(idd, cModsx); //
vUpdate(idd, cPaintJx); //
vUpdate(idd, cSellx); //
vUpdate(idd, cLocationxx); //
vUpdate(idd, cLocationyx); //
vUpdate(idd, cLocationzx); //
vUpdate(idd, cAnglex); //
vUpdate(idd, cColorOnex); //
vUpdate(idd, cColorTwox); //
vUpdate(idd, cOwnerx); //
vUpdate(idd, cValuex); //
vUpdate(idd, cLicensex); //
vUpdate(idd, cDescriptionx); //
vUpdate(idd, cLockx); //
vUpdate(idd, cTimedx); //
vUpdate(idd, cInscarpricex); //
vUpdate(idd, cInsurancecarx); //
vUpdate(idd, cKMx); //
vUpdate(idd, cOwnedx); //
new car = CreateVehicle(CarInfo[idd][cModel],CarInfo[idd][cLocationx],CarInfo[idd][cLocationy],CarInfo[idd][cLocationz],CarInfo[idd][cAngle],1,1,500000);
SetVehicleNumberPlate(car,CarInfo[idd][cLicense]);
new disp[184];
format(disp,sizeof(disp),"You bought %s.Please take your car and park it elsewhere.",CarInfo[idd][cDescription]);
SCM(playerid,COLOR_LIGHTBLUE,disp);
OwnedVeh(car) = idd;
personalcar[playerid] = car;
masini++;
SwitchKey[playerid] = 1;
}
return 1;
}
public vUpdate(vehicleid, type)
{
new gQuery[1024];
switch(type)
{
case cLocationxx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Locationx`='%f' WHERE `ID`='%d'",CarInfo[vehicleid][cLocationx],vehicleid);
mysql_query(SQL, gQuery);
}
case cLocationyx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Locationy`='%f' WHERE `ID`='%d'",CarInfo[vehicleid][cLocationy],vehicleid);
mysql_query(SQL, gQuery);
}
case cLocationzx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Locationz`='%f' WHERE `ID`='%d'",CarInfo[vehicleid][cLocationz],vehicleid);
mysql_query(SQL, gQuery);
}
case cAnglex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Angle`='%f' WHERE `ID`='%d'",CarInfo[vehicleid][cAngle],vehicleid);
mysql_query(SQL, gQuery);
}
case cModelx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Model`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cModel],vehicleid);
mysql_query(SQL, gQuery);
}
case cColorOnex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `ColorOne`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cColorOne],vehicleid);
mysql_query(SQL, gQuery);
}
case cColorTwox:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `ColorTwo`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cColorTwo],vehicleid);
mysql_query(SQL, gQuery);
}
case cOwnerx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Owner`='%s' WHERE `ID`='%d'",CarInfo[vehicleid][cOwner],vehicleid);
mysql_query(SQL, gQuery);
}
case cValuex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Value`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cValue],vehicleid);
mysql_query(SQL, gQuery);
}
case cLicensex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `License`='%s' WHERE `ID`='%d'",CarInfo[vehicleid][cLicense],vehicleid);
mysql_query(SQL, gQuery);
}
case cDescriptionx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Description`='%s' WHERE `ID`='%d'",CarInfo[vehicleid][cDescription],vehicleid);
mysql_query(SQL, gQuery);
}
case cLockx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Lockk`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cLock],vehicleid);
mysql_query(SQL, gQuery);
}
case cTimedx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Timed`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cTimed],vehicleid);
mysql_query(SQL, gQuery);
}
case cInscarpricex:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Inscarprice`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cInscarprice],vehicleid);
mysql_query(SQL, gQuery);
}
case cInsurancecarx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Insurancecar`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cInsurancecar],vehicleid);
mysql_query(SQL, gQuery);
}
case cKMx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `KM`='%.2f' WHERE `ID`='%d'",CarInfo[vehicleid][cKM],vehicleid);
mysql_query(SQL, gQuery);
}
case cOwnedx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Owned`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cOwned],vehicleid);
mysql_query(SQL, gQuery);
}
case cSellx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `Sell`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cSell],vehicleid);
mysql_query(SQL, gQuery);
}
case cModsx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `mod1`='%d',`mod2`='%d',`mod3`='%d',`mod4`='%d',`m od5`='%d',`mod6`='%d',`mod7`='%d',`mod8`='%d',`mod 9`='%d',`mod10`='%d',`mod11`='%d',`mod12`='%d',`mo d13`='%d',`mod14`='%d',`mod15`='%d',`mod16`='%d',` mod17`='%d' WHERE `ID`='%d'",
CarInfo[vehicleid][mod1],
CarInfo[vehicleid][mod2],
CarInfo[vehicleid][mod3],
CarInfo[vehicleid][mod4],
CarInfo[vehicleid][mod5],
CarInfo[vehicleid][mod6],
CarInfo[vehicleid][mod7],
CarInfo[vehicleid][mod8],
CarInfo[vehicleid][mod9],
CarInfo[vehicleid][mod10],
CarInfo[vehicleid][mod11],
CarInfo[vehicleid][mod12],
CarInfo[vehicleid][mod13],
CarInfo[vehicleid][mod14],
CarInfo[vehicleid][mod15],
CarInfo[vehicleid][mod16],
CarInfo[vehicleid][mod17],
vehicleid);
mysql_query(SQL, gQuery);
}
case cPaintJx:
{
format(gQuery,sizeof(gQuery),"UPDATE `cars` SET `PaintJ`='%d' WHERE `ID`='%d'",CarInfo[vehicleid][cPaintJ],vehicleid);
mysql_query(SQL, gQuery);
}
}
return 1;
}