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


Messages In This Thread
This can be locked. - by Rzzr - 12.02.2010, 19:40
Re: Attaching and destroying magnet object, help! - by Rzzr - 12.02.2010, 21:02
Re: Attaching and destroying magnet object, help! - by mansonh - 12.02.2010, 21:46
Re: Attaching and destroying magnet object, help! - by Rzzr - 12.02.2010, 21:56
Re: This can be locked. - by mansonh - 12.02.2010, 22:00
Re: This can be locked. - by MenaceX^ - 12.02.2010, 22:04
Re: This can be locked. - by mansonh - 12.02.2010, 22:07
Re: This can be locked. - by Rzzr - 12.02.2010, 22:07
Re: This can be locked. - by mansonh - 12.02.2010, 22:09

Forum Jump:


Users browsing this thread: 2 Guest(s)