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
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(vehicleid, playerid)
{
new modelid = GetVehicleModel(vehicleid);
switch(modelid)
{
case 417:
{
GetVehiclePos(vehicleid, MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]);
Rope[playerid] = CreateObject(19087, MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]-0.0, 0.0, 0.0, 0.0, 300);
Magnet4Players[playerid] = CreateObject(3053, MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]-0.0, 0.0, 0.0, 0.0, 300);
AttachObjectToVehicle(Rope[playerid], vehicleid, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
MagnetInfo[playerid][MagnetZPos] = 2.5;
AttachObjectToObject(Magnet4Players[playerid], Rope[playerid], 0.0, 0.0, -MagnetInfo[playerid][MagnetZPos], 0.0, 0.0, 0.0, 1);
//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], vehicleid, 0.0, 0.0, MagnetInfo[playerid][MagnetZPos], 0.0, 0.0, 0.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], vehicleid, 0.0, 0.0, MagnetInfo[playerid][MagnetZPos], 0.0, 0.0, 0.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], vehicleid, 0.0, 0.0, MagnetInfo[playerid][MagnetZPos], 0.0, 0.0, 0.0);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
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(playerid, newstate, oldstate)
{
if(newstate == 2 && oldstate == 1)
{
new vehicleid = GetPlayerVehicleID(playerid);
CreateHelicopterMagnet(vehicleid, playerid);
}
if(newstate == 1 && oldstate == 2)
{
DestroyHelicopterMagnet(playerid);
}
return 1;
}
public OnPlayerUpdate(playerid)
{
if(MagnetInfo[playerid][IsMagnetActive] == 2 && MagnetInfo[playerid][Touched] == 1)
{
new Float:Pos[4];
new Float:RotX, Float:RotY, Float:RotZ;
new vehicleid = GetPlayerVehicleID(playerid);
GetObjectPos(Magnet4Players[playerid], MagnetInfo[playerid][X], MagnetInfo[playerid][Y], MagnetInfo[playerid][Z]);
GetObjectRot(Magnet4Players[playerid], RotX, RotY, RotZ);
GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
GetVehicleZAngle(vehicleid, Pos[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(vehicleid, playerid)
{
new Float:VPos[7];
//new CurrentVehicle = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, VPos[0], VPos[1], VPos[2]);
GetVehicleZAngle(vehicleid, VPos[3]);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, VPos[4], VPos[5], VPos[6]);
if(MagnetInfo[playerid][IsMagnetActive] == 1 && MagnetInfo[playerid][Touched] == 0)
{
MagnetInfo[playerid][Touched] = 1;
MagnetInfo[playerid][IsMagnetActive] = 2;
TempVehicle[playerid] = vehicleid;
MagnetInfo[playerid][VehicleRoofMagnetZOffSet] = VPos[6] / 2 + 0.21;
MagnetYOffset = - 0.4;
AttachObjectToVehicle(Magnet4Players[playerid], TempVehicle[playerid], 0.0, MagnetYOffset, MagnetInfo[playerid][VehicleRoofMagnetZOffSet], 0.0, 0.0, 0.0);
}
return 1;
}
been more than 48 hrs im gonna bump this post ssomeone with knowledge please help thanks
cant believe this no1 helped me out and then someone goes and releases their own filterscript