Why if i press behind button(mmb) i get the error:You must be in a vehicle if you want to sell one.Its needs to be if you press 2. And when i am in vehicle and i press 2 i dont get error that i need to be in cp.
Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_SECONDARY_ATTACK && PlayerToPoint(1.0, playerid, -1619.1694,689.5911,7.1875)) //SFPD Shutter Inside
{
if(gTeam[playerid] != TEAM_COP)
{
SendClientMessage(playerid,COLOR_RED,"Access Denied");
return 1;
}
SetPlayerPos(playerid, -1619.1694,689.5911,7.1875);
SetPlayerFacingAngle(playerid, 269.9927);
LoopingAnim(playerid, "HEIST9", "Use_SwipeCard", 3.0, 0, 0, 0, 0, 0);
if(SFPDShutterOpen == 0)
{
MoveObject(SFPDShutter, -1620.61669922,688.17712402,12.80728531, 4);
SendClientMessage(playerid, COLOR_DODGERBLUE, "Access Granted");
SFPDShutterOpen =1;
return 1;
}
if(SFPDShutterOpen == 1)
{
MoveObject(SFPDShutter, -1620.61669922,688.17712402,7.80728531, 4);
SFPDShutterOpen =0;
return 1;
}
return 1;
}
if (newkeys == KEY_SUBMISSION/* && IsPlayerInAnyVehicle(playerid)*/)
{
if(gTeam[playerid]==TEAM_COP && GetPlayerState(playerid)==PLAYER_STATE_DRIVER )
{
new ID = GetClosestPlayerToPlayer(playerid);
dcmd_arrestkey(playerid, IntToStr(GetClosestPlayerToPlayer(playerid)));
dcmd_ticketkey(playerid, IntToStr(GetClosestPlayerToPlayer(playerid)));
if(GetPlayerWantedLevel(ID)==0 && GetDistanceBetweenPlayers(playerid,ID) > 4)
{
SendClientMessage(playerid,COLOR_RED,"No Suspect In Range!");
return 1;
}
return 1;
}
if(gTeam[playerid]!=TEAM_COP && gTeam[playerid]!=TEAM_SECRETAGENT)
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,COLOR_RED,"You must be in a vehicle if you want to sell one.");
return 1;
}
if(getCheckpointType(playerid) != CP_ShipYard)
{
SendClientMessage(playerid,COLOR_RED,"You can only sell the car at the Shipyard!");
return 1;
}
dcmd_sellcarkey(playerid, IntToStr(playerid));
return 1;
}
return 1;
}
if (newkeys == KEY_FIRE)
{
TextDrawHideForPlayer(playerid,TextDraw1);
TextDrawHideForPlayer(playerid,TextDraw2);
TextDrawHideForPlayer(playerid,TextDraw3);
TextDrawHideForPlayer(playerid,TextDraw4);
TextDrawHideForPlayer(playerid,TextDraw5);
TextDrawHideForPlayer(playerid,TextDraw6);
TextDrawHideForPlayer(playerid,TextDraw7);
return 1;
}
if(newkeys == KEY_LOOK_BEHIND)
{
new ID = GetClosestPlayerToPlayer(playerid);
dcmd_arrestkey(playerid, IntToStr(GetClosestPlayerToPlayer(playerid)));
dcmd_ticketkey(playerid, IntToStr(GetClosestPlayerToPlayer(playerid)));
if(GetPlayerWantedLevel(ID)==0 && GetDistanceBetweenPlayers(playerid,ID) > 4)
{
SendClientMessage(playerid,COLOR_RED,"No Suspect In Range!");
return 1;
}
return 1;
}
if(newkeys & KEY_SECONDARY_ATTACK && PlayerToPoint(1.0, playerid, -1622.1335,687.1992,7.1875)) //SFPD Shutter Outside
{
if(gTeam[playerid] != TEAM_COP)
{
SendClientMessage(playerid,COLOR_RED,"Access Denied");
return 1;
}
SetPlayerPos(playerid, -1622.1335,687.1992,7.1875);
SetPlayerFacingAngle(playerid, 0.2336);
LoopingAnim(playerid, "HEIST9", "Use_SwipeCard", 3.0, 0, 0, 0, 0, 0);
if(SFPDShutterOpen == 0)
{
MoveObject(SFPDShutter, -1620.61669922,688.17712402,12.80728531, 4);
SendClientMessage(playerid, COLOR_DODGERBLUE, "Access Granted");
SFPDShutterOpen =1;
return 1;
}
if(SFPDShutterOpen == 1)
{
MoveObject(SFPDShutter, -1620.61669922,688.17712402,7.80728531, 4);
SFPDShutterOpen =0;
return 1;
}
return 1;
}
return 1;
}