This can be locked.
#1

Hello guys,
I got 2 problems
I am making a script with which I can attach the skycrane magnet to a player and detach it.
This is my code:

pawn Код:
// On top of my script
#define ID_CARGOBOB 548

new CargobobMagnet[MAX_PLAYERS];
new HasMagnet[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{
    HasMagnet[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(HasMagnet[playerid] != 0)
    {
    DestroyObject(CargobobMagnet[playerid]);
    }
    return 1;
}
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == ID_CARGOBOB)
    {
        if(HasMagnet[playerid] != 0)
        {
            if(newkeys & KEY_FIRE)
            {
            DestroyObject(CargobobMagnet[playerid]);
            print("Magnet destroyed");
            HasMagnet[playerid] = 0;
            }
        }
        if(HasMagnet[playerid] == 0)
        {
            if(newkeys & KEY_FIRE)
            {
            CargobobMagnet[playerid] = CreateObject(3053, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
            AttachObjectToPlayer(CargobobMagnet[playerid], playerid, 0.0, 0.0, -2.5, 0.0, 0.0, 0.0);
            print("Magnet created");
            HasMagnet[playerid] = 1;
            }
        }
    }
   
    return 1;
}
Now there's 2 problems:
1) I cannot pick up any vehicles with the magnet, it doesnt have 'magnetic powers'
2) If i press the fire key when I have a magnet, it DOES print Magnet destroyed, but it does not actually destroy the magnet.

So, can you help me?
Thanks!
Reply
#2

Somebody please help me, this is kinda urgent!
Reply
#3

Quote:

b) Do not bump
Some people apparently think they are important enough to bump their own topic after 10 minutes.
You can bump topics when the last reply is at least 12 hours old.

Not sure why your object can't be destroyed.
and, you are attaching the object to the player, not the player to the object. so of course it won't pick them up.

The only way to make a magnet would be to create a n object and repeatedly set player position to right below the object.
Reply
#4

Oh so the magnet object doesnt actually work as a magnet?
And I fixed the not-deleting thingy.
Well then, this thread can be closed.
Reply
#5

Good.

But you understand how you can get the magnet to "work" right?

Here is an example of a helicopter magnet system that you could adapt.
http://forum.sa-mp.com/index.php?topic=117991.0
Reply
#6

Quote:
Originally Posted by mansonh
Good.

But you understand how you can get the magnet to "work" right?
I suppose he does as he asked for this thread to be closed.
Reply
#7

Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by mansonh
Good.

But you understand how you can get the magnet to "work" right?
I suppose he does as he asked for this thread to be closed.
Can't be too certain, the last thing he said was:
Oh so the magnet object doesnt actually work as a magnet?
So he may just be giving up on he idea.
Reply
#8

Yeah, I had already seen that topic, but I thought the magnet would really work, but it didn't.
Ill make it with a timer then
Reply
#9


Although to make it smooth between the magnet and the car attach the magnet like you already have. then just set player position, then there will be less "lag" between the car and the magnet.
-would have to test this to be sure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)