28.11.2015, 02:19
Okay so the problem is preety simple.
So when you purchase a vehicle, yourr vehicle ID is 0 for some reason, meanwhile when is loadas it later on from SQL it works fine.
Aka Im not storing VID properly inside VehInfo[vehicleid][VID].
VehInfo[vehicleid][VID] should store SQL ID inside of it, instead it saves 0.
So overall I know whats the problem line
But how do I do it differently?
It stores everything into the SQL perfectly, but the problem is, lets say I buy the car now and I want to /park it, it will recognize me as owner, but it wont find the SQL ID where it should store it so it will store it under SQL ID:0
But if I restart the server, it will all be cool
So when you purchase a vehicle, yourr vehicle ID is 0 for some reason, meanwhile when is loadas it later on from SQL it works fine.
Aka Im not storing VID properly inside VehInfo[vehicleid][VID].
VehInfo[vehicleid][VID] should store SQL ID inside of it, instead it saves 0.
pawn Код:
if(playertextid == TXD_DealershipBuyButton[playerid]) {
new string[128], calc = GetVehiclePrice(PlayerDealershipID[playerid]) - AccInfo[playerid][PocketMoney],query[512];
format(string,sizeof(string),"You dont have enough money. You are missing %i to buy this vehicle",calc);
if(AccInfo[playerid][vOwnedTotal] >= 4) return SendClientMessage(playerid,COLOR_RED,"You already have 3 vehicles");
if(AccInfo[playerid][PocketMoney] < GetVehiclePrice(PlayerDealershipID[playerid])) return SendClientMessage(playerid,COLOR_RED,string);
mysql_format(mysql, query, sizeof(query),"INSERT INTO `vehicles` (`MasterID`,`ModelID`,`Color1`,`Color2`,`PosX`,`PosY`,`PosZ`,`PosA`,`RespawnTime`,`Price`,`Damage`,`FuelStatus`,`EngineStatus`,`Kilometrage`,`Siren`,`Owned`,`VirtualWorld`,`Interior`) VALUES ('%i','%i','%i','%i','%f','%f','%f','%f','%i','%i','%i','%i','%i','%f','%i',1,0,0)",\
AccInfo[playerid][ID],PlayerDealershipID[playerid],0,0,509.9833,-1294.7455,16.9693,305.0121,0,GetVehiclePrice(PlayerDealershipID[playerid]),0,0,0,0);
mysql_tquery(mysql, query, "OnVehicleCreation", "i", playerid);
SetCameraBehindPlayer(playerid);
SetPlayerVirtualWorld(playerid,0);
SetPlayerPos(playerid,520.5632,-1292.3516,17.2422);
InDealership[playerid] = 0;
HideDealershipTextdraws(playerid);
CancelSelectTextDraw(playerid);
format(string,sizeof(string),"You have purchased vehicle Model ID: %i for %i",PlayerDealershipID[playerid],GetVehiclePrice(PlayerDealershipID[playerid]));
SendClientMessage(playerid,COLOR_GREEN,string);
AccInfo[playerid][vOwnedTotal] += 1;
GivePlayerMoney(playerid,-GetVehiclePrice(PlayerDealershipID[playerid]));
AccInfo[playerid][PocketMoney] -= GetVehiclePrice(PlayerDealershipID[playerid]);
new vehicleid = CreateVehicle(PlayerDealershipID[playerid], 509.9833,-1294.7455,16.9693,305.0121,0,0,0,0);
VehInfo[vehicleid][VID] = lastveh; // problematic line
VehInfo[vehicleid][VehMasterID] = AccInfo[playerid][ID];
VehInfo[vehicleid][ModelID] = PlayerDealershipID[playerid];
VehInfo[vehicleid][Color1] = 0;
VehInfo[vehicleid][Color2] = 0;
VehInfo[vehicleid][VehPosX] = 509.9833;
VehInfo[vehicleid][VehPosY] = -1294.7455;
VehInfo[vehicleid][VehPosZ] = 16.9693;
VehInfo[vehicleid][VehPosA] = 305.0121;
PutPlayerInVehicle(playerid,vehicleid,0);
printf("New vehicle purchased. Server ID: %i. Master ID: %i",GetPlayerVehicleID(playerid),VehInfo[vehicleid][VehMasterID]);
SendClientMessage(playerid,COLOR_RED,"Collisions are now disabled for you for next 15 seconds so you can move your vehicle");
}
pawn Код:
public OnVehicleCreation() {
VehInfo[veh][VID] = cache_insert_id();
lastveh = VehInfo[veh][VID];
return 1;
}
So overall I know whats the problem line
pawn Код:
VehInfo[vehicleid][VID] = lastveh; // problematic line
It stores everything into the SQL perfectly, but the problem is, lets say I buy the car now and I want to /park it, it will recognize me as owner, but it wont find the SQL ID where it should store it so it will store it under SQL ID:0
But if I restart the server, it will all be cool