How to enter and exit a garage with a car?
#1

Enter garage code
Код:
for(new idx=1; idx<MAX_GARAGES; idx++) // Dynamic Garages
	{
		if(IsPlayerInRangeOfPoint(playerid, 2, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]))
	    {
		    if(!GarageInfo[idx][gStatus] && PlayerInfo[playerid][pGarage] != idx && PlayerInfo[playerid][pVGarage] != idx) return SendClientMessage(playerid, COLOR_GREY, "This garage is locked.");
    		if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	        format(string, sizeof(string), "* %s pushes the garage door button and enters the Garage.", RPN(playerid));
			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	        SetPlayerVirtualWorld(playerid, idx+500);
			if(GarageInfo[idx][gLevel] == 1)
			{
				SetPlayerPos(playerid, 2238.33,2191.08,103.94);
		        SetPlayerFacingAngle(playerid, 267.0980);
		        SetCameraBehindPlayer(playerid);
		        SetPlayerInterior(playerid, 0);
			}
			else if(GarageInfo[idx][gLevel] == 2)
			{
				SetPlayerPos(playerid, 2259.6702,-1135.8542,1050.6328);
		        SetPlayerFacingAngle(playerid, 267.3974);
		        SetCameraBehindPlayer(playerid);
		        SetPlayerInterior(playerid, 0);
			}
			else if(GarageInfo[idx][gLevel] == 3)
			{
				SetPlayerPos(playerid, 404.98,2457.82,16.50);
		        SetPlayerFacingAngle(playerid, 359.8550);
		        SetCameraBehindPlayer(playerid);
		        SetPlayerInterior(playerid, 0);

			}
		}
	}
Exit garage code
Код:
	if(IsPlayerInRangeOfPoint(playerid, 2, 2238.40,2191.07,103.94) || IsPlayerInRangeOfPoint(playerid, 2, 2259.6702,-1135.8542,1050.6328) || IsPlayerInRangeOfPoint(playerid, 2, 404.98,2457.82,16.50)) // Garages
	{
 		new idx;
		idx = GetPlayerVirtualWorld(playerid)-500;
		if(!done && idx < MAX_GARAGES && GarageInfo[idx][gLevel])
		{
			format(string, sizeof(string), "* %s pushes the garage door button and exits the garage.", RPN(playerid));
			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	        SetPlayerPos(playerid, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]);
	        SetPlayerInterior(playerid, 0);
	        SetPlayerVirtualWorld(playerid, 0);
	        done = 1;
        }
	}
Thank you everyone who has helped me on my past post to help me get my garage working.
Reply
#2

Hmm maybe
pawn Код:
for(new idx=1; idx<MAX_GARAGES; idx++) // Dynamic Garages
    {
        if(IsPlayerInRangeOfPoint(playerid, 2, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]))
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            if(!GarageInfo[idx][gStatus] && PlayerInfo[playerid][pGarage] != idx && PlayerInfo[playerid][pVGarage] != idx) return SendClientMessage(playerid, COLOR_GREY, "This garage is locked.");
            if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            format(string, sizeof(string), "* %s pushes the garage door button and enters the Garage.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SetPlayerVirtualWorld(playerid, idx+500);
            if(GarageInfo[idx][gLevel] == 1)
            {
                SetVehiclePos(vehicleid, 2238.33,2191.08,103.94);
                SetVehicleZAngle(vehicleid, 267.0980);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 0);
            }
            else if(GarageInfo[idx][gLevel] == 2)
            {
                SetVehiclePos(vehicleid, 2259.6702,-1135.8542,1050.6328);
                SetVehicleZAngle(vehicleid, 267.3974);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 0);
            }
            else if(GarageInfo[idx][gLevel] == 3)
            {
                SetVehiclePos(vehicleid, 404.98,2457.82,16.50);
                SetVehicleZAngle(vehicleid, 359.8550);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 0);

            }
        }
    }
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 2, 2238.40,2191.07,103.94) || IsPlayerInRangeOfPoint(playerid, 2, 2259.6702,-1135.8542,1050.6328) || IsPlayerInRangeOfPoint(playerid, 2, 404.98,2457.82,16.50)) // Garages
    {
        new idx;
        new vehicleid = GetPlayerVehicleID(playerid);
        idx = GetPlayerVirtualWorld(playerid)-500;
        if(!done && idx < MAX_GARAGES && GarageInfo[idx][gLevel])
        {
            format(string, sizeof(string), "* %s pushes the garage door button and exits the garage.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SetVehiclePos(vehicleid, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]);
            SetPlayerInterior(playerid, 0);
            SetVehicleVirtualWorld(vehicleid);
            done = 1;
        }
    }
(untested)
Reply
#3

Nope, Just gave me errors
Reply
#4

Post the errors so i can continue providing help
EDIT: Try this
pawn Код:
for(new idx=1; idx<MAX_GARAGES; idx++) // Dynamic Garages
    {
        if(IsPlayerInRangeOfPoint(playerid, 2, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]))
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            if(!GarageInfo[idx][gStatus] && PlayerInfo[playerid][pGarage] != idx && PlayerInfo[playerid][pVGarage] != idx) return SendClientMessage(playerid, COLOR_GREY, "This garage is locked.");
            if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            format(string, sizeof(string), "* %s pushes the garage door button and enters the Garage.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SetPlayerVirtualWorld(playerid, idx+500);
            if(GarageInfo[idx][gLevel] == 1)
            {
                SetVehiclePos(vehicleid, 2238.33,2191.08,103.94);
                SetVehicleZAngle(vehicleid, 267.0980);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 0);
            }
            else if(GarageInfo[idx][gLevel] == 2)
            {
                SetVehiclePos(vehicleid, 2259.6702,-1135.8542,1050.6328);
                SetVehicleZAngle(vehicleid, 267.3974);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 0);
            }
            else if(GarageInfo[idx][gLevel] == 3)
            {
                SetVehiclePos(vehicleid, 404.98,2457.82,16.50);
                SetVehicleZAngle(vehicleid, 359.8550);
                SetCameraBehindPlayer(playerid);
                SetPlayerInterior(playerid, 0);

            }
        }
    }
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 2, 2238.40,2191.07,103.94) || IsPlayerInRangeOfPoint(playerid, 2, 2259.6702,-1135.8542,1050.6328) || IsPlayerInRangeOfPoint(playerid, 2, 404.98,2457.82,16.50)) // Garages
    {
        new idx;
        new vehicleid = GetPlayerVehicleID(playerid);
        idx = GetPlayerVirtualWorld(playerid)-500;
        if(!done && idx < MAX_GARAGES && GarageInfo[idx][gLevel])
        {
            format(string, sizeof(string), "* %s pushes the garage door button and exits the garage.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SetVehiclePos(vehicleid, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]);
            SetPlayerInterior(playerid, 0);
            SetVehicleVirtualWorld(vehicleid,idx);
            done = 1;
        }
    }
Reply
#5

It lets me enter but still wont TP the car with me
Reply
#6

Does anyone else know how to?
Reply
#7

You don't seem to be changing the virtual world of the vehicle alongside with the player. Just saying...

EDIT: Also your conditional here:
pawn Код:
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
Isn't enclosed, so even if the player isn't in a vehicle, the rest of the code is being ran.
Reply
#8

Can someone help me do this over skype? I still cant get this.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)