12.02.2010, 19:40
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:
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!
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;
}
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!