Script to "save" car not working?
#1

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;
	}
Reply
#2

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);
Reply
#3

Thanks, I can't believe I didn't notice that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)