SA-MP Forums Archive
walk Playerid To X Y Z - 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: walk Playerid To X Y Z (/showthread.php?tid=527494)



walk Playerid To X Y Z - Pillhead2007 - 22.07.2014

is it possible to make the player use animation and set them to walk to specific x y z location and stop when they get to the location example if your press g it will find the nearest car go over to a passenger side of a vehicle and open door...

thanks
pillhead2007


Re: walk Playerid To X Y Z - Pillhead2007 - 22.07.2014

g only works if its locked how ever if your press enter to enter the car while its locked doesn't do anything
so I need to basically calculate distance to vehicle set the animation to walk set player to walk to nearest vehicle x y z location stop when reached and then apply the lock animation


Re: walk Playerid To X Y Z - Pillhead2007 - 23.07.2014

anyone know how this would be done in theory and practical code


Re: walk Playerid To X Y Z - Pillhead2007 - 23.07.2014

anyone out there , know the answer im looking for cause ****** ant sharing his info and expertise


Re: walk Playerid To X Y Z - Ihateyou - 23.07.2014

lol there is no efficient way to do this... i dont think its possible.

at least i never seen it done before

not the walking part but walking to the car's door


Re: walk Playerid To X Y Z - Beckett - 23.07.2014

Quote:
Originally Posted by Pillhead2007
Посмотреть сообщение
g only works if its locked how ever if your press enter to enter the car while its locked doesn't do anything
so I need to basically calculate distance to vehicle set the animation to walk set player to walk to nearest vehicle x y z location stop when reached and then apply the lock animation
Why you stick yourself in deepshit? it's already like that when you press G isn't it?


Re: walk Playerid To X Y Z - [NWA]Hannes - 23.07.2014

Set the facing angle of the player towards the location you want to walk to, apply a walkin animation and use a timer check like very 500 seconds to see if the player is in range of the point your walking to, if they are, stop the animation


Re: walk Playerid To X Y Z - Pillhead2007 - 24.07.2014

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;




Re: walk Playerid To X Y Z - Juvanii - 24.07.2014

Quote:
Originally Posted by Ihateyou
Посмотреть сообщение
lol there is no efficient way to do this... i dont think its possible.
Read this answer carefully:
Quote:
Originally Posted by ******
Посмотреть сообщение
Yes



Re: walk Playerid To X Y Z - Ihateyou - 24.07.2014

Quote:
Originally Posted by Juvanii
Посмотреть сообщение
Read this answer carefully:
yes but hes not asking to simulate 'g' button

plus his script probably 99% doesnt work exact correctly