park command problem
#1

Hello Sir
when I /park the car the vehicle get parked but it also get repaired but I don't want that on /park. Here is the code


Код:
if(strcmp(cmd, "/park", true) == 0 || strcmp(cmd, "/pv", true) == 0) // Parking the car.
	{
		new vehicleid = GetPlayerVehicleID(playerid);
	 	if(IsPlayerConnected(playerid))
	    {
			if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == 2)
			{
				GetPlayerVehicleMods(playerid);
				if(PlayerVehicleID1[playerid] == vehicleid)
				{
					GetVehiclePos(vehicleid, PlayerInfo[playerid][PlayerVehiclePosX1], PlayerInfo[playerid][PlayerVehiclePosY1], PlayerInfo[playerid][PlayerVehiclePosZ1]);
    				GetVehicleZAngle(vehicleid, PlayerInfo[playerid][PlayerVehicleFacing1]);
					DestroyVehicle(PlayerVehicleID1[playerid]);
					PlayerInfo[playerid][PlayerVehicle1VirWorld] = GetPlayerVirtualWorld(playerid);
            		PlayerInfo[playerid][PlayerVehicle1Interior] = GetPlayerInterior(playerid);
				    CreatePlayerVehicle(playerid,1);
					PutPlayerInVehicle(playerid,PlayerVehicleID1[playerid],0);
				}
				else if(PlayerVehicleID2[playerid] == vehicleid)
				{
					GetVehiclePos(vehicleid, PlayerInfo[playerid][PlayerVehiclePosX2], PlayerInfo[playerid][PlayerVehiclePosY2], PlayerInfo[playerid][PlayerVehiclePosZ2]);
			       	GetVehicleZAngle(vehicleid, PlayerInfo[playerid][PlayerVehicleFacing2]);
					DestroyVehicle(PlayerVehicleID2[playerid]);
					PlayerInfo[playerid][PlayerVehicle2VirWorld] = GetPlayerVirtualWorld(playerid);
            		PlayerInfo[playerid][PlayerVehicle2Interior] = GetPlayerInterior(playerid);
				    CreatePlayerVehicle(playerid,2);
					PutPlayerInVehicle(playerid,PlayerVehicleID2[playerid],0);
				}
				else if(PlayerVehicleID3[playerid] == vehicleid)
				{
					GetVehiclePos(vehicleid, PlayerInfo[playerid][PlayerVehiclePosX3], PlayerInfo[playerid][PlayerVehiclePosY3], PlayerInfo[playerid][PlayerVehiclePosZ3]);
			       	GetVehicleZAngle(vehicleid, PlayerInfo[playerid][PlayerVehicleFacing3]);
					DestroyVehicle(PlayerVehicleID3[playerid]);
					PlayerInfo[playerid][PlayerVehicle3VirWorld] = GetPlayerVirtualWorld(playerid);
            		PlayerInfo[playerid][PlayerVehicle3Interior] = GetPlayerInterior(playerid);
				    CreatePlayerVehicle(playerid,3);
					PutPlayerInVehicle(playerid,PlayerVehicleID3[playerid],0);
				}
				else if(PlayerVehicleID4[playerid] == vehicleid)
				{
					GetVehiclePos(vehicleid, PlayerInfo[playerid][PlayerVehiclePosX4], PlayerInfo[playerid][PlayerVehiclePosY4], PlayerInfo[playerid][PlayerVehiclePosZ4]);
			       	GetVehicleZAngle(vehicleid, PlayerInfo[playerid][PlayerVehicleFacing4]);
					DestroyVehicle(PlayerVehicleID4[playerid]);
					PlayerInfo[playerid][PlayerVehicle4VirWorld] = GetPlayerVirtualWorld(playerid);
            		PlayerInfo[playerid][PlayerVehicle4Interior] = GetPlayerInterior(playerid);
					CreatePlayerVehicle(playerid,4);
					PutPlayerInVehicle(playerid,PlayerVehicleID4[playerid],0);
				}
				else if(PlayerVehicleID5[playerid] == vehicleid)
				{
					GetVehiclePos(vehicleid, PlayerInfo[playerid][PlayerVehiclePosX5], PlayerInfo[playerid][PlayerVehiclePosY5], PlayerInfo[playerid][PlayerVehiclePosZ5]);
			      	GetVehicleZAngle(vehicleid, PlayerInfo[playerid][PlayerVehicleFacing5]);
					DestroyVehicle(PlayerVehicleID5[playerid]);
					PlayerInfo[playerid][PlayerVehicle5VirWorld] = GetPlayerVirtualWorld(playerid);
            		PlayerInfo[playerid][PlayerVehicle5Interior] = GetPlayerInterior(playerid);
					CreatePlayerVehicle(playerid,5);
					PutPlayerInVehicle(playerid,PlayerVehicleID5[playerid],0);
				}
				else
				{
					SendClientMessage(playerid,COLOR_GREY,"	You are not in a vehicle that you own.");
				}
			}
			else
			{
				SendClientMessage(playerid,COLOR_GREY,"	You are not driving a vehicle.");
			}
		}
	    return 1;
	}
Reply
#2

From what I understand you are destroying the player's vehicle and then you are creating it again, I think this causes the repairing (actually theres no repairing involved since you are spawning a new fresh vehicle). I think you will need to store the vehicles health in a variable.
example:
pawn Код:
new Float:health;//a variable to store the health in
//this goes above new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicleid, health);//we detect the vehicle health and store it in the "health" variable
//and this under DestroyVehicle
//then under CreatePlayerVehicle
SetVehicleHealth(vehicleid, health);
I'm not 100% sure this will work but it should look like this, Good luck!
Reply
#3

Quote:
Originally Posted by Voxel
Посмотреть сообщение
From what I understand you are destroying the player's vehicle and then you are creating it again, I think this causes the repairing (actually theres no repairing involved since you are spawning a new fresh vehicle). I think you will need to store the vehicles health in a variable.
example:
pawn Код:
new Float:health;//a variable to store the health in
//this goes above new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicleid, health);//we detect the vehicle health and store it in the "health" variable
//and this under DestroyVehicle
//then under CreatePlayerVehicle
SetVehicleHealth(vehicleid, health);
I'm not 100% sure this will work but it should look like this, Good luck!
when i /park then the vehicle get destroyed with fire.
Reply
#4

Quote:
Originally Posted by Voxel
Посмотреть сообщение
From what I understand you are destroying the player's vehicle and then you are creating it again, I think this causes the repairing (actually theres no repairing involved since you are spawning a new fresh vehicle). I think you will need to store the vehicles health in a variable.
example:
pawn Код:
new Float:health;//a variable to store the health in
//this goes above new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicleid, health);//we detect the vehicle health and store it in the "health" variable
//and this under DestroyVehicle
//then under CreatePlayerVehicle
SetVehicleHealth(vehicleid, health);
I'm not 100% sure this will work but it should look like this, Good luck!
Thank you sir got fixed i have to put GetVehicleHealth(vehicleid, health); above DestroyVehicle..
Reply
#5

Good job ! glad I could help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)