SA-MP Forums Archive
Check side of vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Check side of vehicle (/showthread.php?tid=582020)



Check side of vehicle - Jhon_Night - 17.07.2015

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


AW: Check side of vehicle - Kaliber - 17.07.2015

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");