Check side of vehicle
#1

How can i see if a player is standing near the right side or the left side of a vehicle?
Reply
#2

You can do it like this:

PHP код:
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_SIZEPos[0],Pos[1],Pos[2]);
    if(
Pos[6] >= &&  Pos[3] <= (Pos[1]/2) &&  Pos[3] >= (-Pos[1]/2))return 1//right
    
else if(Pos[6] <= &&  Pos[3] <= Pos[1]/&&  Pos[3] >= -Pos[1]/2)return 2//left
    
else if(Pos[3] >= && Pos[6] <= Pos[0]/&&  Pos[6] >= -Pos[0]/2)return 3// front
    
else if(Pos[3] <= && Pos[6] <= Pos[0]/&&  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");

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)