Small problem with the script
#1

Код:
new EngineStatus[MAX_PLAYERS], LightsStatus[MAX_PLAYERS], AlarmStatus[MAX_PLAYERS], DoorsStatus[MAX_PLAYERS], BonnetStatus[MAX_PLAYERS], BootStatus[MAX_PLAYERS], ObjectiveStatus[MAX_PLAYERS];

public OnGameModeInit()
{
    ManualVehicleEngineAndLights();
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

CMD:car(playerid, params[])
{
	new engine,lights,alarm,doors,bonnet,boot,objective,veh; veh = GetPlayerVehicleID(playerid);
	if(strcmp(params, "Engine", true) == 0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
	 		if(veh != INVALID_VEHICLE_ID)
			{
				if(VehicleInfo[playerid][Engine] == 0)
				{
					GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
					SetVehicleParamsEx(veh,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
					VehicleInfo[playerid][Engine] = 1;
					SendClientMessage(playerid, MSGCOMM_COLOR, "You've turned the vehicle's engine on!");
				}
				else if(VehicleInfo[playerid][Engine] == 1)
				{
					GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
					SetVehicleParamsEx(veh,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
					VehicleInfo[playerid][Engine] = 0;
					SendClientMessage(playerid, MSGCOMM_COLOR, "You've turned the vehicle's engine off!");
				}
			}
		}
		else {
		SendClientMessage(playerid, MSGFAIL_COLOR, "You are not in a vehicle!");
		}
	}
I have this vehicle control system but when i do /car engine in one car it turns the engine on! But when i go into another and and do /car engine it says engine is turned off, So i am needed to do /car engine 2 times to start the engine why is this happening it is so annoying how to amend it?
Reply
#2

This is because for some obscure reason you are using the playerid to store the vehicle variables, rather than the vehicleid.

Use this:
pawn Код:
VehicleInfo[GetPlayerVehicleID(playerid)]
Etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)