22.03.2014, 17:25
Bom estou com um problema no drop de armas ao morrer, peguei esse cуdigo aqui no forum samp mesmo. O player consegue pegar a arma normalmente na pickup, ela tб lб nos slots do jogo, mais nгo dб pra usar ela, o que pode ser?
Cуdigo:
Cуdigo:
pawn Code:
#define MAX_WEAPONS_DROPPED 20
#define REMOVE_WEAPONS_DROPPED_TIMER 20000
#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];
public OnPlayerDeath(playerid, killerid, reason)
{
DropWeapons(playerid);
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
switch(PickupType[pickupid])
{
case PICKUP_TYPE_WEAPON:
{
GivePlayerWeapon(playerid, PickupWeapon[pickupid], PickupAmmo[pickupid]);
KillTimer(DestroyPickupTimer[pickupid]);
DestroyWeaponPickup(pickupid);
}
}
return 1;
}
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;
}