28.09.2011, 14:40
Hello,
I need help to fix my problem.
I have a problem with my vehicle plate saving, Its work with the state vehicle I mean my plate system is not working on Owner vehicles. When I'll add plate vehicle in game it works completely my car is re-spawn. But the problem is that when I'll restart the server from the file I got problem that my vehicle plate is not saved and the oldest XYZ.-- plate is added.
Can some one help me with that??
Here is my code:
I need help to fix my problem.
I have a problem with my vehicle plate saving, Its work with the state vehicle I mean my plate system is not working on Owner vehicles. When I'll add plate vehicle in game it works completely my car is re-spawn. But the problem is that when I'll restart the server from the file I got problem that my vehicle plate is not saved and the oldest XYZ.-- plate is added.
Can some one help me with that??
Here is my code:
pawn Код:
if(strcmp(cmd, "/vregister",true)== 0)
{
new ID = GetPlayerVehicleID(playerid);
new strings[256];
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x00FFFFFF, "You're not in a vehicle");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /vregister <License Plate>");
else
{
format(strings, sizeof(strings), "%s",tmp);
SetVehicleNumberPlate(ID,strings);
strmid(CarInfo[VehicleOwned[ID]][cLicense], strings, 0, strlen(strings), 255);
SetVehicleToRespawn(ID);
format(strings,sizeof(strings),"{00C0FF}You've changed your plate name to %s please spawn your vehicle again",tmp);
SendClientMessage(playerid, COLOR_LIGHTRED, strings);
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
SaveCars();
}
return 1;
}
pawn Код:
public OnVehicleSpawn(vehicleid)
{
VehicleEngine[vehicleid] = 0;
VehicleWindows[vehicleid] = 0;
CarRadio[vehicleid] = 0;
SetVehicleNumberPlate(vehicleid,CarInfo[VehicleOwned[vehicleid]][cLicense]);
if(VehicleOwned[vehicleid] != SCRIPT_CARS)
{
if(VehSpawned[vehicleid] == 0)
{
VehicleOwned[vehicleid] = SCRIPT_CARS;
DestroyVehicle(vehicleid);
VehSpawned[vehicleid] = 0;
}
else
{
VehSpawned[vehicleid] = 0;
}
}
else if(CopInfo[vehicleid][Created] == 1)
{
strmid(CopInfo[vehicleid][Owner], "None", 0, strlen("None"), 255);
CopInfo[vehicleid][Created]=0;
DestroyVehicle(vehicleid);
}
return 1;
}