Script to "save" car not working? - 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: Script to "save" car not working? (
/showthread.php?tid=632731)
Script to "save" car not working? -
Zolika1351 - 18.04.2017
I host a server that is soon going to be populated by my classmates, and I added a lot of parked cars, with respawn times. I want to get players to be able to "save" a car, which means respawning the original, then spawning an exact copy of the car they were in that doesn't respawn. I tried coding this myself, but all it does is respawn the car. What did I do wrong?
Код:
if (!strcmp(cmdtext, "/save_car", true))
{
new savecar_model;
new savecar_id;
new savecar_color1;
new savecar_color2;
new Float:savecar_x;
new Float:savecar_y;
new Float:savecar_z;
new Float:savecar_angle;
// Model
savecar_model = GetVehicleModel(savecar_id);
// ID
savecar_id = GetPlayerVehicleID(playerid);
// Angle
GetVehicleZAngle(savecar_id, savecar_angle);
// Position
GetVehiclePos(savecar_id, savecar_x, savecar_y, savecar_z);
// Color
GetVehicleColor(savecar_id, savecar_color1, savecar_color2);
// Create saved vehicle
CreateVehicle(savecar_model, savecar_x, savecar_y, savecar_z, savecar_angle, savecar_color1, savecar_color2, -1);
// Respawn old vehicle
SetVehicleToRespawn(savecar_id);
return 1;
}
Re: Script to "save" car not working? -
LEOTorres - 18.04.2017
You're acquiring the model of the vehicle before you are assigning the vehicle ID:
Swap these two around to the following:
Код:
// ID
savecar_id = GetPlayerVehicleID(playerid);
// Model
savecar_model = GetVehicleModel(savecar_id);
Re: Script to "save" car not working? -
Zolika1351 - 18.04.2017
Thanks, I can't believe I didn't notice that.