05.05.2016, 10:38
Hi, i got some problem over here with SQL and Plate. I have the plate database on table `cars` , column `carPlate`. The Problem is, everytime i respawn a car with this command, the car plate is not changing into the number on the Database, but went on 1 or 0, i'm guessing that was the carID instead of carPlate.
Now, the other problem is that, it works fine on loading the vehicle on player connect, when the player is connected and when the car shows up, it shows with the right plate, but when the vehicle being respawned, it changed like i explained above. No idea why.
Here is the /respawncar command.
RespawnVehicle code:
Car_Spawn code:
I'm asking for help over here, those who might judging my scripting skill instead of helping will be reported right away.
Now, the other problem is that, it works fine on loading the vehicle on player connect, when the player is connected and when the car shows up, it shows with the right plate, but when the vehicle being respawned, it changed like i explained above. No idea why.
Here is the /respawncar command.
Код:
CMD:respawncar(playerid, params[]) { new vehicleid; if (PlayerData[playerid][pAdmin] < 2) return SendErrorMessage(playerid, "You don't have permission to use this command."); if (sscanf(params, "d", vehicleid)) return SendSyntaxMessage(playerid, "/respawncar [veh]"); if (vehicleid < 1 || vehicleid > MAX_VEHICLES || !IsValidVehicle(vehicleid)) return SendErrorMessage(playerid, "You have specified an invalid vehicle ID."); Car_Save(vehicleid); RespawnVehicle(vehicleid); SendServerMessage(playerid, "You have respawned vehicle ID: %d.", vehicleid); return 1; }
Код:
stock RespawnVehicle(vehicleid) { new id = Car_GetID(vehicleid); if (id != -1) { Car_Spawn(id); } ResetVehicle(vehicleid); return 1; }
Код:
stock Car_Spawn(carid) { if (carid != -1 && CarData[carid][carExists]) { 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][carPos][0], CarData[carid][carPos][1], CarData[carid][carPos][2], CarData[carid][carPos][3], CarData[carid][carColor1], CarData[carid][carColor2], (CarData[carid][carOwner] != 0) ? (-1) : (1200000)); if (CarData[carid][carPlate] != -1) { new string[128], platen; CarData[carid][carPlate] = cache_get_field_int(carid, "carPlate"); platen = CarData[carid][carPlate]; format(string, sizeof(string),"LS-%d", platen); SetVehicleNumberPlate(CarData[carid][carVehicle], string); SetVehicleToRespawn(CarData[carid][carVehicle]); } if (CarData[carid][carVehicle] != INVALID_VEHICLE_ID) { if (CarData[carid][carPaintjob] != -1) { ChangeVehiclePaintjob(CarData[carid][carVehicle], CarData[carid][carPaintjob]); } if (CarData[carid][carLocked]) { new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(CarData[carid][carVehicle], engine, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(CarData[carid][carVehicle], engine, lights, alarm, 1, bonnet, boot, objective); } for (new i = 0; i < 14; i ++) { if (CarData[carid][carMods][i]) AddVehicleComponent(CarData[carid][carVehicle], CarData[carid][carMods][i]); } ResetVehicle(CarData[carid][carVehicle]); return 1; } } return 0; }