spawn weapon on ground?
#1

Hi,

I'm wanting to spawn a weapon on the ground that players will be able to pickup.

I am currently using this code:
Код:
   if(pickupid == Gnade1)
    {
        Gnade1 = CreatePickup(342,1,2000.6320,1566.6492,15.3671);
	GivePlayerWeapon(playerid, 342, 1); // 342 - Frag Grenade | playerid | weaponid | ammo |
        return 1;
	}
The item is picked up but does not get given to the player, any ideas? Thanks.
Reply
#2

where did u add this code in like
pawn Код:
OnPlayerDeath?
Reply
#3

This is what I have: (hope it helps explain it better)


Код:
new Gnade1;
Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{

   if(pickupid == Gnade1)
    {
        Gnade1 = CreatePickup(342,1,2000.6320,1566.6492,15.3671);
	GivePlayerWeapon(playerid, 342, 1); //342 - Frag Grenade | playerid | weaponid | ammo |
        return 1;
	}
}

Код:
public OnGameModeInit()
{
Gnade1 = CreatePickup(342,1,2000.6320,1566.6492,15.3671);
return 1;
}
Reply
#4

'342' isn't a valid weapon ID.

The weapon id of the grenade is 16, change it to that.
https://sampwiki.blast.hk/wiki/WeaponID
Reply
#5

I put the model number. Didn't even realise! Thanks
Reply
#6

Im not sure but try this

Remove new Gnade1;

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{

   if(pickupid == 342)
    {
        CreatePickup(342,1,2000.6320,1566.6492,15.3671);
    GivePlayerWeapon(playerid, 342, 1); //342 - Frag Grenade | playerid | weaponid | ammo |
        return 1;
    }
}
pawn Код:
public OnGameModeInit()
{
CreatePickup(342,1,2000.6320,1566.6492,15.3671);
return 1;
}
Reply
#7

This....
Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{

   if(pickupid == 342)
    {
        CreatePickup(342,1,2000.6320,1566.6492,15.3671);
    GivePlayerWeapon(playerid, 342, 1); //342 - Frag Grenade | playerid | weaponid | ammo |
        return 1;
    }
..should be this:

Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{

   if(pickupid == 342)
    {
        CreatePickup(342,1,2000.6320,1566.6492,15.3671);
    GivePlayerWeapon(playerid, 16, 1); //342 - Frag Grenade | playerid | weaponid | ammo |
        return 1;
    }
dam my sleepness. Thanks for all the replies!
Reply
#8

pawn Код:
if(pickupid == 16)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)