walk Playerid To X Y Z
#8

thanks matey , already had the facing angle that kept changing if i wasn't looking right anyways got it to work its almost perfect script nearly there need a few touches there is 1 bug when car is locked and the car respawns and your at the same co ords as vehicle respawns and it still detects as locked when you face and press enter it will go over to it then look another direction and carry on running with a loop and wont stop until you press a button ermmm
also if you go over to the right hand side of vehicle it will use LHS door locked anim will need to find a way around this
anyways if any one wants a basic script for car lock with animation here it is

PHP код:
stock IsPlayerFacingVehicle(playeridvehicleid)
{
  new 
Float:pX,Float:pY,Float:pZ,Float:X,Float:Y,Float:Z,Float:ang;
  
GetVehiclePos(vehicleidXYZ);
  
GetPlayerPos(playeridpXpYpZ);
  if( 
pY ang = (-acos((pX) / floatsqroot((pX)*(pX) + (pY)*(pY))) - 90.0);
  else if( 
pY && pX ang = (acos((pX) / floatsqroot((pX)*(pX) + (pY)*(pY))) - 450.0);
  else if( 
pY ang = (acos((pX) / floatsqroot((pX)*(pX) + (pY)*(pY))) - 90.0);
  if(
pXang = (floatabs(floatabs(ang) + 180.0));
  else 
ang = (floatabs(ang) - 180.0);
  new 
Float:russia;
  
GetPlayerFacingAngle(playerid,russia);
  if(
ang-russia<-130 || ang-russia>130) return 0;
  else return 
1;
}
stock IsVehicleOccupied(vehicleidseatid)
{
  for(new 
0MAX_PLAYERSi++)
  {
    if(
GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == seatid)
    {
      return 
1;
    }
  }
  return 
0;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
  new 
playerstate GetPlayerState(playerid);
  if(
playerstate == PLAYER_STATE_ONFOOT)
  {
    for(new 
0MAX_VEHICLESi++)
    {
      if(!
IsVehicleOccupied(i0))
      {
        new 
Float:XFloat:YFloat:ZFloat:Zangle;
        new 
Float:AngleFloat:Pos[3];
        
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
        
GetVehiclePos(iXYZ);
        
GetPlayerFacingAngle(playeridAngle);
        
GetVehicleZAngle(iZangle);
        if(
PRESSED(KEY_SECONDARY_ATTACK))
        {
          if(
IsPlayerInRangeOfPoint(playerid10XYZ))
          {
            if(
IsPlayerFacingVehicle(playerid,i))
            {
              
ApplyAnimation(playerid,"PED","RUN_PLAYER",4.1,0,1,1,0,1000,0);
              if(
IsPlayerInRangeOfPoint(playerid1.56XYZ))
              {
                if(
VehicleInfo[i][Lock] == 1)
                {
                    
SetPlayerFacingAngle(playeridZangle);
                    
ApplyAnimation(playerid,"PED","CAR_doorlocked_LHS" ,4.1,0,0,0,0,0,1);
                }
              }
            }
          }
        }
      }
    }
  }
  return 
1;

Reply


Messages In This Thread
walk Playerid To X Y Z - by Pillhead2007 - 22.07.2014, 23:16
Re: walk Playerid To X Y Z - by Pillhead2007 - 22.07.2014, 23:21
Re: walk Playerid To X Y Z - by Pillhead2007 - 23.07.2014, 07:09
Re: walk Playerid To X Y Z - by Pillhead2007 - 23.07.2014, 21:27
Re: walk Playerid To X Y Z - by Ihateyou - 23.07.2014, 21:35
Re: walk Playerid To X Y Z - by DaniceMcHarley - 23.07.2014, 21:55
Re: walk Playerid To X Y Z - by [NWA]Hannes - 23.07.2014, 21:56
Re: walk Playerid To X Y Z - by Pillhead2007 - 24.07.2014, 00:38
Re: walk Playerid To X Y Z - by Juvanii - 24.07.2014, 04:54
Re: walk Playerid To X Y Z - by Ihateyou - 24.07.2014, 06:20

Forum Jump:


Users browsing this thread: 4 Guest(s)