PDA

View Full Version : Garage interior.


Laure
03/05/2014, 06:48 AM
Hey guys i made a garage system for my server but the problem is i am confused how can i take the vehicle inside the garage yet its only possible for the player to enter the garage heres my command please modify it as so if the players in a vehicle the player enters the garage along with the vehicle
CMD:entergarage(playerid, params[])
{
new done, string[128];
if(IsPlayerInRangeOfPoint(playerid, 3, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]))
{
new idx;
idx = GetPlayerVirtualWorld(playerid)-500;
if(!done && idx < MAX_GARAGES && GarageInfo[idx][gLevel])
{
format(string, sizeof(string), "** %s pushes the shutter up and exits the garage.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
done = 1;
}
}
return 1;
}

Noliax8
03/05/2014, 07:13 AM
SetPlayerPos is use to teleport a player, but not to teleport a vehicle, use SetVehiclePos, you can retrieve the vehicle ID via GetPlayerVehicleID(playerid) : return ID of the vehicle or 0 if not in a vehicle

Jonas

Laure
04/05/2014, 05:52 AM
I tried it somehow but it still seems not be working here is my pawn hope you guys will modify it as so it works fine.
CMD:entergarage(playerid, params[])
{
new idx, vehid, string[128];
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 by its owner.");
format(string, sizeof(string), "** %s pushes the shutter and enters the garage.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetPlayerVirtualWorld(playerid, idx+500);
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);

if(IsPlayerInVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetPlayerVehicleID(playerid);
SetVehiclePos(vehid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
return 1;
}

}
return 1;
}

superrobot48
04/05/2014, 05:58 AM
its like
vehid = GetPlayerVehicleID(playerid);

Laure
04/05/2014, 06:04 AM
didnt work

superrobot48
04/05/2014, 06:21 AM
Try This?

CMD:entergarage(playerid, params[])
{
new idx, vehid, string[128];
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 by its owner.");
format(string, sizeof(string), "** %s pushes the shutter and enters the garage.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
vehid = GetPlayerVehicleID(playerid);
SetPlayerVirtualWorld(playerid, idx+500);
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);

if(IsPlayerInVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(vehid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
return 1;
}

}
return 1;
}

Dignity
04/05/2014, 06:30 AM
CMD:entergarage(playerid, params[])
{
new idx, string[128], vehid = GetPlayerVehicleID(playerid);

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 by its owner.");

format(string, sizeof(string), "** %s pushes the shutter and enters the garage.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);

if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
}

else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(vehid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
}

SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
SetPlayerVirtualWorld(playerid, idx+500);
}

return 1;
}

Laure
04/05/2014, 06:38 AM
nope didnt work

PinEvil
04/05/2014, 06:42 AM
So you want vehicles able to enter/exit the garage?

If so, You could use check points with vehicle positions attached. And use a progress bar or something to get in with the vehicle..

Dignity
04/05/2014, 06:45 AM
nope didnt work

The code should work. Do you have MAX_GARAGES defined? If so, use a loop and go through it's value instead of defining idx. idx is nothing if you simply do "new idx;"

So you want vehicles able to enter/exit the garage?

If so, You could use check points with vehicle positions attached. And use a progress bar or something to get in with the vehicle..

..What?

Laure
04/05/2014, 07:03 AM
Yep i have defined max garages but i didnt understand what you mean i am just a beginner to scripting :)

Dignity
04/05/2014, 07:05 AM
CMD:entergarage(playerid, params[])
{
new string[128], vehid = GetPlayerVehicleID(playerid);

for(new idx = 0; idx < MAX_GARAGES; idx ++)
{
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 by its owner.");

format(string, sizeof(string), "** %s pushes the shutter and enters the garage.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);

if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
}

else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(vehid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
}

SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
SetPlayerVirtualWorld(playerid, idx+500);
}
}

return 1;
}

Laure
04/05/2014, 07:13 AM
on using the recent code now the command /entergarage works but though i am in my car it only tps me to the garage

Dignity
04/05/2014, 07:17 AM
I've had the same issue with my housing system. Try doing something like this:


CMD:entergarage(playerid, params[])
{
new string[128], vehid = GetPlayerVehicleID(playerid), neargarage[MAX_PLAYERS] = 999;

for(new idx = 0; idx < MAX_GARAGES; idx ++)
{
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 by its owner.");

neargarage[playerid] = idx;
}
}

if(neargarage[playerid] != 999)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
}

else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(vehid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
}

format(string, sizeof(string), "** %s pushes the shutter and enters the garage.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);

SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
SetPlayerVirtualWorld(playerid, idx+500);
}

else if(neargarage[playerid] == 999) return SendClientMessage(playerid, COLOR_GREY, "You're not near a garage!");

return 1;
}

Laure
04/05/2014, 07:24 AM
Ops i think i got the solution the players int is supposed to be 0. thanks for helping ++