*** This topic title sucks, "help me" is not descriptive. -
Laure - 05.11.2012
I have a problem with /enter cmd for my garage yeah i can enter it but only when i am not in a car.If i am in a car i cant enter the garage.The Codes.
Код:
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 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);
if(GarageInfo[idx][gLevel] == 1)
{
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
}
else if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), 1515.2551,-1666.3148,14.0469);
}
return 1;
}
}
Help will be appreciated.And you will be reputed,Thanks in advance.
Re: Small Help Here. -
AIped - 05.11.2012
you need IsPlayerInVehicle instead of IsplayerInAnyVehicle because you can define the players car there.
then you also need PutPlayerInVehicle
Basicly you teleport the vehicle and the player appart from eachother and then put the player in the vehicle again with putplayerinvehicle
Re: Small Help Here. -
Neeraz_Nepal - 05.11.2012
Thank you AIped i could learn as well i had the same prob and Imperor as well.
Re: Small Help Here. -
AIped - 05.11.2012
Your welcome, if its still not working just ask...btw i forgot that you also have to link the vehicle into the interior and put it into the same virtual world. I just saw that Imperor has that implented for the player.
Re: Small Help Here. -
Laure - 05.11.2012
This time neither i nor the vehicle can enter check out whats wrong now.
Код:
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 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);
if(GarageInfo[idx][gLevel] == 1)
{
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
}
else if(IsPlayerInVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), 1515.2551,-1666.3148,14.0469);
}
return 1;
}
}
Re: Small Help Here. -
AIped - 05.11.2012
this should be the car part see the difference ?
pawn Код:
new yourcar=GetPlayerVehicleID(playerid);
else if(IsPlayerInVehicle(playerid,yourcar)&&GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
{
SetVehiclePos(yourcar 1515.2551,-1666.3148,14.0469);
LinkVehicleToInterior(yourcar,idx+500);//whatever your idx+500 is
SetVehicleVirtualWorld(yourcar,idx+500);
SetPlayerVirtualWorld(playerid, idx+500);
SetPlayerInterior(playerid, idx+500);
PutPlayerInVehicle(yourcar,0);
}
Re: Small Help Here. -
Danyal - 05.11.2012
pawn Код:
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 by its owner.");
if(GarageInfo[idx][gLevel] == 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
new veh = GetPlayerVehicleID(playerid);
SetVehiclePos(veh, 1515.2551,-1666.3148,14.0469);
LinkVehicleToInterior(veh, 1);
SetVehicleVirtualWorld(veh,idx+500);
SetPlayerVirtualWorld(playerid, idx+500);
SetPlayerInterior(playerid, 1);
}
else
{
SetPlayerPos(playerid, -72.5507,-20.3314,972.5516);
SetPlayerFacingAngle(playerid, 267.0980);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
SetPlayerVirtualWorld(playerid, idx+500);
}
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);
return 1;
}
}
}
try this...
EDIT CODE UPDATED