SA-MP Forums Archive
This can be locked. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: This can be locked. (/showthread.php?tid=127288)



This can be locked. - Rzzr - 12.02.2010

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!


Re: Attaching and destroying magnet object, help! - Rzzr - 12.02.2010

Somebody please help me, this is kinda urgent!


Re: Attaching and destroying magnet object, help! - mansonh - 12.02.2010

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.


Re: Attaching and destroying magnet object, help! - Rzzr - 12.02.2010

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.


Re: This can be locked. - mansonh - 12.02.2010

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


Re: This can be locked. - MenaceX^ - 12.02.2010

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.


Re: This can be locked. - mansonh - 12.02.2010

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.


Re: This can be locked. - Rzzr - 12.02.2010

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


Re: This can be locked. - mansonh - 12.02.2010


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.