SetVehicleNumberPlate after car restore - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SetVehicleNumberPlate after car restore (
/showthread.php?tid=631783)
SetVehicleNumberPlate after car restore -
NBass - 04.04.2017
Hello,
i'm trying to get the SetVehicleNumberPlate back on vehicle after vehicle restore, but seems not working. I did a command to set a vehicle number, and it save's to PlayerDB, but can't get it work, when the vehicle is destroyed, and get them back after restore. I tried to do something, and can be some unlogical, and useless code. Any ideas?
License plate saved on carnumeris in playerDB:
HTML Code:
playerDB[playerid][carnumeris]
HTML Code:
if(!strcmp(cmdtext, "/restore", true,7))
{
if (Carlist[playerid][Typ]!=-1)
{
if (Carlist[playerid][Status]==0)
{
new reparatur = Buylist[Carlist[playerid][Typ]][Repair];
if (reparatur <= GetPlayerMoneyA(playerid))
{
new carnr[7];
Carlist[playerid][Status]=1;
playerDB[playerid][carnumeris] = strval(carnr);
SetVehicleNumberPlate(Carlist[playerid][Carid],carnr);
SetVehicleToRespawn(Carlist[playerid][Carid]);
Carlist[playerid][Carid]=CreateTunedCar(playerid);
GivePlayerMoneyA(playerid, - reparatur);
format(string, 128, "Vehicle restored for %i USD!", reparatur);
SendClientMessage(playerid, RED, string);
vehicleDB[GetPlayerVehicleID(playerid)][gas]=35;
}
else
{
format(string, 128, "For the vehicle Restore, you need %i USD!", reparatur); SendClientMessage(playerid, COLOR_LIGHTRED, string);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Wait a moment, to /restore");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Do you even have a car?!");
}
return 1;
}
HTML Code:
public CreateTunedCar(playerid)
{
if(IsPlayerConnected(playerid) && Carlist[playerid][Typ]!=-1)
{
new carid=CreateVehicle(Buylist[Carlist[playerid][Typ]][Modelid],Carlist[playerid][X],Carlist[playerid][Y],Carlist[playerid][Z],Carlist[playerid][Rotation],-1,-1,-1);
new carnr[7];
playerDB[playerid][carnumeris] = strlen(carnr);
SetVehicleNumberPlate(carid,carnr);
if(Carlist[playerid][Lock]==1)
{
SetVehicleParamsForAll(carid,0,1);
SetVehicleParamsForPlayer(carid,playerid,0,0);
}
if(playerDB[playerid][carnumeris]!=-1) { SetVehicleNumberPlate(carid,playerDB[playerid][carnumeris]);}
if(Carlist[playerid][mod1]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod1]); }
if(Carlist[playerid][mod2]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod2]); }
if(Carlist[playerid][mod3]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod3]); }
if(Carlist[playerid][mod4]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod4]); }
if(Carlist[playerid][mod5]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod5]); }
if(Carlist[playerid][mod6]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod6]); }
if(Carlist[playerid][mod7]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod7]); }
if(Carlist[playerid][mod8]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod8]); }
if(Carlist[playerid][mod9]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod9]); }
if(Carlist[playerid][mod10]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod10]); }
if(Carlist[playerid][mod11]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod11]); }
if(Carlist[playerid][mod12]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod12]); }
if(Carlist[playerid][mod13]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod13]); }
if(Carlist[playerid][mod14]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod14]); }
if(Carlist[playerid][mod15]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod15]); }
if(Carlist[playerid][mod16]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod16]); }
if(Carlist[playerid][mod17]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod17]); }
if(Carlist[playerid][mod18]!=-1) { AddVehicleComponent(carid,Carlist[playerid][mod18]); }
if(Carlist[playerid][Paintjob]!=-1) { ChangeVehiclePaintjob(carid,Carlist[playerid][Paintjob]); }
if(Carlist[playerid][Color1]!=-1) { ChangeVehicleColor(carid,Carlist[playerid][Color1],Carlist[playerid][Color2]);}
if(Carlist[playerid][gas]!=-1) { vehicleDB[carid][gas] = Carlist[playerid][gas]; }
SetVehicleToRespawn(carid);
return carid;
}
return -1;
}
Thanks in anyway!
Re: SetVehicleNumberPlate after car restore -
NBass - 05.04.2017
*bump