Weapon drop..
#1

I'm using Double-O-Seven's weapon drop and I have a problem..

The weapons don't show for ID 0..

Here's the code:

Код:
#define MAX_PICKUPS 400
#define PICKUP_TYPE_WEAPON 1

new PickupType[MAX_PICKUPS];
new PickupWeapon[MAX_PICKUPS];
new PickupAmmo[MAX_PICKUPS];
new DestroyPickupTimer[MAX_PICKUPS];

forward DropWeapons(playerid);
public DropWeapons(playerid)
{
	if(IsPlayerConnected(playerid))
	{
	  #define MAX 300
	  new weaponid,ammo,modelid,pickupid;
	  new success=false;
	  new Float:x,Float:y,Float:z;
	  GetPlayerPos(playerid,x,y,z);
	  for(new i=1;i<12;i++)
	  {
			GetPlayerWeaponData(playerid,i,weaponid,ammo);
			if(weaponid)
			{
				if(ammo>MAX)
				  ammo=MAX;
				modelid=GetWeaponModel(weaponid);
				if(modelid)
				{
				  pickupid=CreatePickup(modelid,1,x+(random(10)-random(10)),y+(random(10)-random(10)),z);
				  PickupType[pickupid]=PICKUP_TYPE_WEAPON;
					PickupWeapon[pickupid]=weaponid;
					PickupAmmo[pickupid]=ammo;
					DestroyPickupTimer[pickupid]=SetTimerEx("DestroyWeaponPickup",10000+random(1000),false,"i",pickupid);
					success=true;
				}
			}
	  }
	  ResetPlayerWeapons(playerid);
	  #undef MAX
	  return success;
	}
	return 0;
}

forward DestroyWeaponPickup(pickupid);
public DestroyWeaponPickup(pickupid)
{
	if(PickupType[pickupid]==PICKUP_TYPE_WEAPON)
	{
	  PickupType[pickupid]=PICKUP_TYPE_NONE;
	  PickupWeapon[pickupid]=0;
		PickupAmmo[pickupid]=0;
		DestroyPickup(pickupid);
		return 1;
	}
	return 0;
}

stock GetWeaponModel(weaponid)
{
	switch(weaponid)
	{
	  case 1:
	    return 331;
	    
		case 2..8:
		  return weaponid+331;
		  
    case 9:
		  return 341;
		  
		case 10..15:
			return weaponid+311;
		  
		case 16..18:
		  return weaponid+326;

		case 22..29:
		  return weaponid+324;
		  
		case 30,31:
		  return weaponid+325;
		  
		case 32:
		  return 372;
		  
		case 33..45:
		  return weaponid+324;
		  
		case 46:
		  return 371;
	}
	return 0;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	switch(PickupType[pickupid])
	{
	  case PICKUP_TYPE_WEAPON:
	  {
	    GivePlayerWeapon(playerid,PickupWeapon[pickupid],PickupAmmo[pickupid]);
  	  KillTimer(DestroyPickupTimer[pickupid]);
	    DestroyWeaponPickup(pickupid);
	  }
	}
	return 1;
}
Reply
#2

Код:
#include <a_samp>
#define PICKUP_TYPE_NONE 0
#define PICKUP_TYPE_WEAPON 1

new PickupType[MAX_PICKUPS];
new PickupWeapon[MAX_PICKUPS];
new PickupAmmo[MAX_PICKUPS];
new DestroyPickupTimer[MAX_PICKUPS];

forward DropWeapons(playerid);
public DropWeapons(playerid)
{
	if(IsPlayerConnected(playerid))
	{
	  #define MAX 300
	  new weaponid,ammo,modelid,pickupid;
	  new success=false;
	  new Float:x,Float:y,Float:z;
	  GetPlayerPos(playerid,x,y,z);
	  for(new i=1;i<12;i++)
	  {
			GetPlayerWeaponData(playerid,i,weaponid,ammo);
			if(weaponid)
			{
				if(ammo>MAX)
				  ammo=MAX;
				modelid=GetWeaponModel(weaponid);
				if(modelid)
				{
				  pickupid=CreatePickup(modelid,1,x+(random(10)-random(10)),y+(random(10)-random(10)),z);
				  PickupType[pickupid]=PICKUP_TYPE_WEAPON;
					PickupWeapon[pickupid]=weaponid;
					PickupAmmo[pickupid]=ammo;
					DestroyPickupTimer[pickupid]=SetTimerEx("DestroyWeaponPickup",10000+random(1000),false,"i",pickupid);
					success=true;
				}
			}
	  }
	  ResetPlayerWeapons(playerid);
	  #undef MAX
	  return success;
	}
	return 0;
}

forward DestroyWeaponPickup(pickupid);
public DestroyWeaponPickup(pickupid)
{
	if(PickupType[pickupid]==PICKUP_TYPE_WEAPON)
	{
	  PickupType[pickupid]=PICKUP_TYPE_NONE;
	  PickupWeapon[pickupid]=0;
		PickupAmmo[pickupid]=0;
		DestroyPickup(pickupid);
		return 1;
	}
	return 0;
}

stock GetWeaponModel(weaponid)
{
	switch(weaponid)
	{
	  case 1:
	    return 331;

		case 2..8:
		  return weaponid+331;

    case 9:
		  return 341;

		case 10..15:
			return weaponid+311;

		case 16..18:
		  return weaponid+326;

		case 22..29:
		  return weaponid+324;

		case 30,31:
		  return weaponid+325;

		case 32:
		  return 372;

		case 33..45:
		  return weaponid+324;

		case 46:
		  return 371;
	}
	return 0;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	switch(PickupType[pickupid])
	{
	  case PICKUP_TYPE_WEAPON:
	  {
	    GivePlayerWeapon(playerid,PickupWeapon[pickupid],PickupAmmo[pickupid]);
  	  KillTimer(DestroyPickupTimer[pickupid]);
	    DestroyWeaponPickup(pickupid);
	  }
	}
	return 1;
}

PLAY!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)