heli magnet bug
#1

hi samp users

ive created a helicopter magnet with movement and up and down with the magnet ive got 2 bugs basically when the magnet active the car goes above the helicopter blades only at start up of the server after that its all good and the second bug is when you let go off the vehicle in air before it reaches ground you reactive the magnet it comes bk to magnet please see video anyone got any ideas
thanks video below
https://vid.me/3W5S
sorry for how crap video is
PHP код:
#include <a_samp>
#define WHITE 0xFFFFFFFF
//---[Keys]
#define HOLDING(%0) \
    
((newkeys & (%0)) == (%0))
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
forward MagnetMovementUp(playerid);
forward MagnetMovementDown(playerid);
new 
Magnet4Players[MAX_PLAYERS];
new 
Rope[MAX_PLAYERS];
new 
TempVehicle[MAX_PLAYERS];
new 
MagnetTimer;
new 
Float:MagnetYOffset;
enum MInfo
{
  
Float:X,
  
Float:Y,
  
Float:Z,
  
Float:MagnetZPos,
  
Float:VehicleRoofMagnetZOffSet,
  
IsMagnetActive,
  
Touched,
};
new 
MagnetInfo[MAX_PLAYERS][MInfo];
stock CreateHelicopterMagnet(vehicleidplayerid)
{
  new 
modelid GetVehicleModel(vehicleid);
  switch(
modelid)
  {
    case 
417:
    {
      
GetVehiclePos(vehicleidMagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]);
      
Rope[playerid] = CreateObject(19087MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]-0.00.00.00.0300);
      
Magnet4Players[playerid] = CreateObject(3053MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]-0.00.00.00.0300);
      
AttachObjectToVehicle(Rope[playerid], vehicleid0.00.00.00.00.00.0);
      
MagnetInfo[playerid][MagnetZPos] = 2.5;
      
AttachObjectToObject(Magnet4Players[playerid], Rope[playerid], 0.00.0, -MagnetInfo[playerid][MagnetZPos], 0.00.00.01);
      
//AttachObjectToVehicle(Magnet4Players[playerid], vehicleid, 0.0, 0.0, MagnetInfo[playerid][MagnetZPos], 0.0, 0.0, 0.0);
      
MagnetInfo[playerid][IsMagnetActive] = 0;
    }
  }
  return 
1;
}
stock DestroyHelicopterMagnet(playerid)
{
  if(
IsValidObject(Magnet4Players[playerid]))
  {
    
DestroyObject(Magnet4Players[playerid]);
    
MagnetInfo[playerid][IsMagnetActive] = 0;
  }
  return 
1;
}
public 
MagnetMovementUp(playerid)
{
  new 
vehicleid GetPlayerVehicleID(playerid);
  if(
MagnetInfo[playerid][MagnetZPos] <= -1.4)
  {
    
GetObjectPos(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]);
    
MagnetInfo[playerid][MagnetZPos] = MagnetInfo[playerid][MagnetZPos]+0.1;
    if(
MagnetInfo[playerid][MagnetZPos] >= -1.5)
    {
      
MagnetInfo[playerid][MagnetZPos] = -1.5;
    }
    
MoveObject(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][MagnetZPos],1.0);
    
AttachObjectToVehicle(Magnet4Players[playerid], vehicleid0.00.0MagnetInfo[playerid][MagnetZPos], 0.00.00.0);
    
SetCameraBehindPlayer(playerid);
  }
  return 
1;
}
public 
MagnetMovementDown(playerid)
{
  new 
vehicleid GetPlayerVehicleID(playerid);
  if(
MagnetInfo[playerid][MagnetZPos] <= 0.0)
  {
    
GetObjectPos(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]);
    
MagnetInfo[playerid][MagnetZPos] = MagnetInfo[playerid][MagnetZPos]-0.1;
    
MoveObject(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][MagnetZPos],1.0);
    
AttachObjectToVehicle(Magnet4Players[playerid], vehicleid0.00.0MagnetInfo[playerid][MagnetZPos], 0.00.00.0);
    
SetCameraBehindPlayer(playerid);
  }
  else if(
MagnetInfo[playerid][MagnetZPos] >= 1.5)
  {
    
GetObjectPos(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]);
    
MagnetInfo[playerid][MagnetZPos] = -1.5;
    
MoveObject(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][MagnetZPos],1.0);
    
AttachObjectToVehicle(Magnet4Players[playerid], vehicleid0.00.0MagnetInfo[playerid][MagnetZPos], 0.00.00.0);
  }
  return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
  if(
PRESSED(KEY_ANALOG_UP))
  {
    if(
IsValidObject(Magnet4Players[playerid]))
    {
      
KillTimer(MagnetTimer);
      
MagnetTimer SetTimer("MagnetMovementUp",30,1);
    }
    return 
1;
  }
  if(
PRESSED(KEY_ANALOG_DOWN))
  {
    if(
IsValidObject(Magnet4Players[playerid]))
    {
      
KillTimer(MagnetTimer);
      
MagnetTimer SetTimer("MagnetMovementDown",30,1);
    }
    return 
1;
  }
  if(
RELEASED(KEY_ANALOG_UP))
  {
    if(
IsValidObject(Magnet4Players[playerid]))
    {
      
KillTimer(MagnetTimer);
      return 
1;
    }
  }
  if(
RELEASED(KEY_ANALOG_DOWN))
  {
    if(
IsValidObject(Magnet4Players[playerid]))
    {
      
KillTimer(MagnetTimer);
    }
    return 
1;
  }
  if(
PRESSED(KEY_CROUCH))
  {
    if(
MagnetInfo[playerid][IsMagnetActive] == 0)
    {
      
MagnetInfo[playerid][IsMagnetActive] = 1;
      
GetObjectPos(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]);
    }
    else
    {
      
TempVehicle[playerid] = 0;
      
MagnetInfo[playerid][Touched] = 0;
      
MagnetInfo[playerid][IsMagnetActive] = 0;
    }
  }
  return 
1;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
  if(
newstate == && oldstate == 1)
  {
    new 
vehicleid GetPlayerVehicleID(playerid);
    
CreateHelicopterMagnet(vehicleidplayerid);
  }
  if(
newstate == && oldstate == 2)
  {
    
DestroyHelicopterMagnet(playerid);
  }
  return 
1;
}
public 
OnPlayerUpdate(playerid)
{
  if(
MagnetInfo[playerid][IsMagnetActive] == && MagnetInfo[playerid][Touched] == 1)
  {
    new 
Float:Pos[4];
    new 
Float:RotXFloat:RotYFloat:RotZ;
    new 
vehicleid GetPlayerVehicleID(playerid);
    
GetObjectPos(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]);
    
GetObjectRot(Magnet4Players[playerid], RotXRotYRotZ);
    
GetVehiclePos(vehicleidPos[0], Pos[1], Pos[2]);
    
GetVehicleZAngle(vehicleidPos[3]);
    
SetVehiclePos(TempVehicle[playerid], Pos[0], Pos[1], Pos[2]+MagnetInfo[playerid][MagnetZPos]+MagnetInfo[playerid][VehicleRoofMagnetZOffSet]);
    
//SetVehicleZAngle(TempVehicle[playerid], RotX);
  
}
  
//if(MagnetInfo[playerid][IsMagnetActive] == 0)
  //{
  //}
  
return 1;
}
public 
OnUnoccupiedVehicleUpdate(vehicleidplayerid)
{
  new 
Float:VPos[7];
  
//new CurrentVehicle = GetPlayerVehicleID(playerid);
  
GetVehiclePos(vehicleidVPos[0], VPos[1], VPos[2]);
  
GetVehicleZAngle(vehicleidVPos[3]);
  
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZEVPos[4], VPos[5], VPos[6]);
  if(
MagnetInfo[playerid][IsMagnetActive] == && MagnetInfo[playerid][Touched] == 0)
  {
      
MagnetInfo[playerid][Touched] = 1;
      
MagnetInfo[playerid][IsMagnetActive] = 2;
      
TempVehicle[playerid] = vehicleid;
      
MagnetInfo[playerid][VehicleRoofMagnetZOffSet] = VPos[6] / 0.21;
      
MagnetYOffset = - 0.4;
      
AttachObjectToVehicle(Magnet4Players[playerid], TempVehicle[playerid], 0.0MagnetYOffsetMagnetInfo[playerid][VehicleRoofMagnetZOffSet], 0.00.00.0);
  }
  return 
1;

a base script work in progress
Reply
#2

been more than 48 hrs im gonna bump this post ssomeone with knowledge please help thanks
Reply
#3

cant believe this no1 helped me out and then someone goes and releases their own filterscript https://sampforum.blast.hk/showthread.php?tid=565570 Bul****
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)