17.11.2017, 09:22
I'm editing a script, this one: https://sampforum.blast.hk/showthread.php?tid=641235
I want to make it where if you spawn/buy a vehicle the vehicle ID of said vehicle gets saved in the mySQL
for buying vehicles it works fine, but when I create a new personal vehicle (spawning one in) it does not work. For some reason it does not recognize the [ID] on the "LoadPirvateVehicle" Query but it does work on the "OnPlayerVehiclePurchase" Query. I hope I'm making any sense because I do not quite know how to explain this.
Thanks in advance!
Here it does not work:
( PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid; >> undefined symbol "id" )
Here it does work:
( PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid; >> Saves the vehicle ID in the mySQL under pOwnedVehiclesID[1 or 2 or 3 or 4 or 5] )
I want to make it where if you spawn/buy a vehicle the vehicle ID of said vehicle gets saved in the mySQL
for buying vehicles it works fine, but when I create a new personal vehicle (spawning one in) it does not work. For some reason it does not recognize the [ID] on the "LoadPirvateVehicle" Query but it does work on the "OnPlayerVehiclePurchase" Query. I hope I'm making any sense because I do not quite know how to explain this.
Thanks in advance!
Here it does not work:
( PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid; >> undefined symbol "id" )
PHP код:
function:Query_LoadPrivateVehicle(playerid)
{
if(!cache_num_rows())
return SendErrorMessage(playerid, "An error occurred while loading your vehicle.");
new rows, fields; cache_get_data(rows, fields, ourConnection);
new str[128], vehicleid = INVALID_VEHICLE_ID;
for (new i = 0; i < rows && i < MAX_VEHICLES; i++)
{
vehicleid = CreateVehicle(cache_get_field_content_int(i, "VehicleModel", ourConnection),
cache_get_field_content_float(i, "VehicleParkPosX", ourConnection),
cache_get_field_content_float(i, "VehicleParkPosY", ourConnection),
cache_get_field_content_float(i, "VehicleParkPosZ", ourConnection),
cache_get_field_content_float(i, "VehicleParkPosA", ourConnection),
cache_get_field_content_int(i, "VehicleColor1", ourConnection),
cache_get_field_content_int(i, "VehicleColor2", ourConnection),
-1,
0);
if(vehicleid != INVALID_VEHICLE_ID)
{
VehicleInfo[vehicleid][eVehicleExists] = true;
VehicleInfo[vehicleid][eVehicleDBID] = cache_get_field_content_int(i, "VehicleDBID", ourConnection);
VehicleInfo[vehicleid][eVehicleOwnerDBID] = cache_get_field_content_int(i, "VehicleOwnerDBID", ourConnection);
VehicleInfo[vehicleid][eVehicleFaction] = cache_get_field_content_int(i, "VehicleFaction", ourConnection);
VehicleInfo[vehicleid][eVehicleModel] = cache_get_field_content_int(i, "VehicleModel", ourConnection);
VehicleInfo[vehicleid][eVehicleColor1] = cache_get_field_content_int(i, "VehicleColor1", ourConnection);
VehicleInfo[vehicleid][eVehicleColor2] = cache_get_field_content_int(i, "VehicleColor2", ourConnection);
VehicleInfo[vehicleid][eVehicleParkPos][0] = cache_get_field_content_float(i, "VehicleParkPosX", ourConnection);
VehicleInfo[vehicleid][eVehicleParkPos][1] = cache_get_field_content_float(i, "VehicleParkPosY", ourConnection);
VehicleInfo[vehicleid][eVehicleParkPos][2] = cache_get_field_content_float(i, "VehicleParkPosZ", ourConnection);
VehicleInfo[vehicleid][eVehicleParkPos][3] = cache_get_field_content_float(i, "VehicleParkPosA", ourConnection);
VehicleInfo[vehicleid][eVehicleParkInterior] = cache_get_field_content_int(i, "VehicleParkInterior", ourConnection);
VehicleInfo[vehicleid][eVehicleParkWorld] = cache_get_field_content_int(i, "VehicleParkWorld", ourConnection);
cache_get_field_content(i, "VehiclePlates", VehicleInfo[vehicleid][eVehiclePlates], ourConnection, 32);
VehicleInfo[vehicleid][eVehicleLocked] = bool:cache_get_field_content_int(i, "VehicleLocked", ourConnection);
VehicleInfo[vehicleid][eVehicleImpounded] = bool:cache_get_field_content_int(i, "VehicleImpounded", ourConnection);
VehicleInfo[vehicleid][eVehicleImpoundPos][0] = cache_get_field_content_float(i, "VehicleImpoundPosX", ourConnection);
VehicleInfo[vehicleid][eVehicleImpoundPos][1] = cache_get_field_content_float(i, "VehicleImpoundPosY", ourConnection);
VehicleInfo[vehicleid][eVehicleImpoundPos][2] = cache_get_field_content_float(i, "VehicleImpoundPosZ", ourConnection);
VehicleInfo[vehicleid][eVehicleImpoundPos][3] = cache_get_field_content_float(i, "VehicleImpoundPosA", ourConnection);
VehicleInfo[vehicleid][eVehicleFuel] = cache_get_field_content_int(i, "VehicleFuel", ourConnection);
VehicleInfo[vehicleid][eVehicleHasXMR] = bool:cache_get_field_content_int(i, "VehicleXMR", ourConnection);
VehicleInfo[vehicleid][eVehicleTimesDestroyed] = cache_get_field_content_int(i, "VehicleTimesDestroyed", ourConnection);
VehicleInfo[vehicleid][eVehicleEngine] = cache_get_field_content_float(i, "VehicleEngine", ourConnection);
VehicleInfo[vehicleid][eVehicleBattery] = cache_get_field_content_float(i, "VehicleBattery", ourConnection);
VehicleInfo[vehicleid][eVehicleAlarmLevel] = cache_get_field_content_int(i, "VehicleAlarmLevel", ourConnection);
VehicleInfo[vehicleid][eVehicleLockLevel] = cache_get_field_content_int(i, "VehicleLockLevel", ourConnection);
VehicleInfo[vehicleid][eVehicleImmobLevel] = cache_get_field_content_int(i, "VehicleImmobLevel", ourConnection);
for(new j = 1; j < 6; j++)
{
format(str, sizeof(str), "VehicleWeapons%d", j);
VehicleInfo[vehicleid][eVehicleWeapons][j] = cache_get_field_content_int(i, str, ourConnection);
format(str, sizeof(str), "VehicleWeaponsAmmo%d", j);
VehicleInfo[vehicleid][eVehicleWeaponsAmmo][j] = cache_get_field_content_int(i, str, ourConnection);
}
for(new d = 1; d < 5; d++)
{
format(str, sizeof(str), "VehicleLastDrivers%d", d);
VehicleInfo[vehicleid][eVehicleLastDrivers][d] = cache_get_field_content_int(i, str, ourConnection);
format(str, sizeof(str), "VehicleLastPassengers%d", d);
VehicleInfo[vehicleid][eVehicleLastPassengers][d] = cache_get_field_content_int(i, str, ourConnection);
}
if(VehicleInfo[vehicleid][eVehicleParkInterior] != 0)
{
LinkVehicleToInterior(vehicleid, VehicleInfo[vehicleid][eVehicleParkInterior]);
SetVehicleVirtualWorld(vehicleid, VehicleInfo[vehicleid][eVehicleParkWorld]);
}
if(!isnull(VehicleInfo[vehicleid][eVehiclePlates]))
{
SetVehicleNumberPlate(vehicleid, VehicleInfo[vehicleid][eVehiclePlates]);
SetVehicleToRespawn(vehicleid);
}
if(VehicleInfo[vehicleid][eVehicleImpounded] == true)
{
SetVehiclePos(vehicleid, VehicleInfo[vehicleid][eVehicleImpoundPos][0], VehicleInfo[vehicleid][eVehicleImpoundPos][1], VehicleInfo[vehicleid][eVehicleImpoundPos][2]);
SetVehicleZAngle(vehicleid, VehicleInfo[vehicleid][eVehicleImpoundPos][3]);
}
if(VehicleInfo[vehicleid][eVehicleLocked] == false)
SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
else SetVehicleParamsEx(vehicleid, 0, 0, 0, 1, 0, 0, 0);
VehicleInfo[vehicleid][eVehicleAdminSpawn] = false;
if(HasNoEngine(playerid))
ToggleVehicleEngine(vehicleid, true);
}
}
PlayerInfo[playerid][pVehicleSpawnedID] = vehicleid;
PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid;
SendClientMessageEx(playerid, COLOR_DARKGREEN, "%s has been spawned at its parking place.", ReturnVehicleName(vehicleid));
SendClientMessageEx(playerid, COLOR_WHITE, "Lifespan: Engine Life[%.2f], Battery Life[%.2f], Times Destroyed[%d]", VehicleInfo[vehicleid][eVehicleEngine], VehicleInfo[vehicleid][eVehicleBattery], VehicleInfo[vehicleid][eVehicleTimesDestroyed]);
if(VehicleInfo[vehicleid][eVehicleImpounded]) SendClientMessage(playerid, COLOR_RED, "Your vehicle is impounded.");
SendClientMessage(playerid, 0xFF00FFFF, "Hint: Follow the red marker to your parking place.");
SetPlayerCheckpoint(playerid, VehicleInfo[vehicleid][eVehicleParkPos][0], VehicleInfo[vehicleid][eVehicleParkPos][1], VehicleInfo[vehicleid][eVehicleParkPos][2], 3.0);
PlayerCheckpoint[playerid] = 1;
SaveCharacter(playerid);
return 1;
}
( PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid; >> Saves the vehicle ID in the mySQL under pOwnedVehiclesID[1 or 2 or 3 or 4 or 5] )
PHP код:
function:OnPlayerVehiclePurchase(playerid, id, plates[], Float:x, Float:y, Float:z, Float:a)
{
new
vehicleid = INVALID_VEHICLE_ID
;
DestroyVehicle(DealershipPlayerCar[playerid]);
vehicleid =
CreateVehicle(g_aDealershipData[SubDealershipHolder[playerid]][eDealershipModelID], x, y, z, a, DealershipCarColors[playerid][0], DealershipCarColors[playerid][1], -1);
SetVehicleNumberPlate(vehicleid, plates);
SetVehicleToRespawn(vehicleid);
PutPlayerInVehicle(playerid, vehicleid, 0);
PlayerInfo[playerid][pOwnedVehicles][id] = cache_insert_id();
PlayerInfo[playerid][pOwnedVehiclesID][id] = vehicleid;
if(vehicleid != INVALID_VEHICLE_ID)
{
VehicleInfo[vehicleid][eVehicleDBID] = cache_insert_id();
VehicleInfo[vehicleid][eVehicleOwnerDBID] = PlayerInfo[playerid][pDBID];
VehicleInfo[vehicleid][eVehicleModel] = g_aDealershipData[SubDealershipHolder[playerid]][eDealershipModelID];
VehicleInfo[vehicleid][eVehicleColor1] = DealershipCarColors[playerid][0];
VehicleInfo[vehicleid][eVehicleColor2] = DealershipCarColors[playerid][1];
VehicleInfo[vehicleid][eVehiclePaintjob] = -1;
VehicleInfo[vehicleid][eVehicleParkPos][0] = x;
VehicleInfo[vehicleid][eVehicleParkPos][1] = y;
VehicleInfo[vehicleid][eVehicleParkPos][2] = z;
VehicleInfo[vehicleid][eVehicleParkPos][3] = a;
format(VehicleInfo[vehicleid][eVehiclePlates], 32, "%s", plates);
VehicleInfo[vehicleid][eVehicleLocked] = false;
VehicleInfo[vehicleid][eVehicleEngineStatus] = false;
VehicleInfo[vehicleid][eVehicleFuel] = 50;
VehicleInfo[vehicleid][eVehicleBattery] = 100.0;
VehicleInfo[vehicleid][eVehicleEngine] = 100.0;
VehicleInfo[vehicleid][eVehicleHasXMR] = bool:DealershipXMR[playerid];
VehicleInfo[vehicleid][eVehicleTimesDestroyed] = 0;
VehicleInfo[vehicleid][eVehicleAlarmLevel] = DealershipAlarmLevel[playerid];
VehicleInfo[vehicleid][eVehicleLockLevel] = DealershipLockLevel[playerid];
VehicleInfo[vehicleid][eVehicleImmobLevel] = DealershipImmobLevel[playerid];
for(new i = 1; i< 6; i++)
{
VehicleInfo[vehicleid][eVehicleWeapons][i] = 0;
VehicleInfo[vehicleid][eVehicleWeaponsAmmo][i] = 0;
}
SaveVehicle(vehicleid);
}
SendClientMessageEx(playerid, 0xB9E35EFF, "PROCESSED: You successfully bought a %s for $%s.", ReturnVehicleName(vehicleid), MoneyFormat(DealershipTotalCost[playerid]));
cmd_v(playerid, "stats");
PlayerPurchasingVehicle[playerid] = false;
ResetDealershipVars(playerid);
return 1;
}