Please Help
#1

Hello Guys....I Found a Bug in PPC Housing Please Help me how to get rid of it.
The Bug is-
When a Players enters a House Car and /park Immidiately before he gets out of the car then he park that Vehicle and Drive it too no matter he is not owner of that Vehicle.

Please Help-
Here is the Code of /park (Please Verify the Owner before he types /park)
Код:
COMMAND:park(playerid, params[])
{
	// Setup local variables
	new Float:x, Float:y, Float:z, Float:rot, vid, HouseID, Msg[128];
	new engine,lights,alarm,doors,bonnet,boot,objective;

	// If a player hasn't logged in properly, he cannot use this command
	if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;

	// Check if the player is inside a vehicle (he must be the driver)
	if (GetPlayerVehicleSeat(playerid) == 0)
	{
		// Get the vehicle-id
		vid = GetPlayerVehicleID(playerid);
		// Get the HouseID to which this vehicle belongs
		HouseID = AVehicleData[vid][BelongsToHouse];

		// Check if this vehicle belongs to a house (if not, the vehicle cannot be parked, as it's not a house-vehicle)
		if (HouseID != 0)
		{
			// Check if the vehicle is in range of the house-entrance (you cannot park a vehicle further away from your house than 150m)
			if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
			{
				// Get the player's position and angle
				GetVehiclePos(vid, x, y, z);
				GetVehicleZAngle(vid, rot);
				// Save those values for the vehicle
				AVehicleData[vid][SpawnX] = x;
				AVehicleData[vid][SpawnY] = y;
				AVehicleData[vid][SpawnZ] = z;
				AVehicleData[vid][SpawnRot] = rot;

				// Loop through all carslots of this house to find the vehicle-id
				for (new CarSlot; CarSlot < 10; CarSlot++)
				{
					// Check if this carslot holds the same vehicle-id
				    if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid)
				    {
	                    House_ReplaceVehicle(HouseID, CarSlot); // Re-create the vehicle at the same spot the player wants to park his vehicle
	                    PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
						// Turn on the engine and lights
						GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
						SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, 1, alarm, doors, bonnet, boot, objective);
	                    break; // Stop the for-loop
					}
				}

				// Let the player know he parked his vehicle
				SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've parked your vehicle");

				// Save the housefile
				HouseFile_Save(HouseID);
			}
			else
			{
			    format(Msg, 128, "{FF0000}You need to be within {FFFF00}%im{FF0000} of your house to park this vehicle", ParkRange);
			    SendClientMessage(playerid, 0xFFFFFFFF, Msg);
			}
		}
		else
		    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot park a vehicle that's not owned by you");
	}
	else
	    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be driving a vehicle you own to park it");

	// Let the server know that this was a valid command
	return 1;
}
And here is the function when a players enters a house car.
Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
	// Setup local variables
	new vid, Name[24], Msg[128], engine, lights, alarm, doors, bonnet, boot, objective;

	// Check if the player became the driver of a vehicle
	if (newstate == PLAYER_STATE_DRIVER)
	{
		// Get the ID of the player's vehicle
		vid = GetPlayerVehicleID(playerid);
		// Get the player's name
		GetPlayerName(playerid, Name, sizeof(Name));

		// Check if the vehicle is owned
		if (AVehicleData[vid][Owned] == true)
		{
			// Check if the vehicle is owned by somebody else (strcmp will not be 0)
			if (strcmp(AVehicleData[vid][Owner], Name, false) != 0)
			{
				// Force the player out of the vehicle
				RemovePlayerFromVehicle(playerid);
				// Turn off the lights and engine
				GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
				SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
				// Let the player know he cannot use somebody else's vehicle
				format(Msg, 128, "{FF0000}You cannot use this vehicle, it's owned by \"{FFFF00}%s{FF0000}\"", AVehicleData[vid][Owner]);
				SendClientMessage(playerid, 0xFFFFFFFF, Msg);
			}
		}
	}

	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)