17.07.2015, 11:32
How can i see if a player is standing near the right side or the left side of a vehicle?
stock GetPlayerPositionNextToACar(playerid,carid){
if(!GetPlayerVehicleID(playerid))return 0;
new Float:Pos[7];
GetVehiclePos(carid,Pos[0],Pos[1],Pos[2]);
GetVehicleZAngle(carid,Pos[3]);
GetPlayerPos(playerid,Pos[4],Pos[5],Pos[6]);
Pos[6] = ((Pos[4] - Pos[0])*floatcos(Pos[3],degrees)+(Pos[5] - Pos[1])*floatsin(Pos[3],degrees));
Pos[3] = ((-(Pos[4] - Pos[0]))*floatsin(Pos[3],degrees)+(Pos[5] - Pos[1])*floatcos(Pos[3],degrees));
GetVehicleModelInfo(GetVehicleModel(carid), VEHICLE_MODEL_INFO_SIZE, Pos[0],Pos[1],Pos[2]);
if(Pos[6] >= 0 && Pos[3] <= (Pos[1]/2) && Pos[3] >= (-Pos[1]/2))return 1; //right
else if(Pos[6] <= 0 && Pos[3] <= Pos[1]/2 && Pos[3] >= -Pos[1]/2)return 2; //left
else if(Pos[3] >= 0 && Pos[6] <= Pos[0]/2 && Pos[6] >= -Pos[0]/2)return 3; // front
else if(Pos[3] <= 0 && Pos[6] <= Pos[0]/2 && Pos[6] >= -Pos[0]/2)return 4; // behind
return 0;
}
switch(GetPlayerPositionNextACar(playerid,1)){
case 1:SendClientMessage(playerid,-1,"Right");
case 2:SendClientMessage(playerid,-1,"Left");
case 3:SendClientMessage(playerid,-1,"Front");
case 4:SendClientMessage(playerid,-1,"Behind");
}