11.07.2010, 13:23
DoesPlayerHaveAnyWeapon(playerid)
DoesPlayerHaveWeapon(playerid, weaponid, slot)
I could've discluded the slot parameter to make this function much easier to use, however for it's initial use it required it. I could remove it and have it check that itself (with ease) but I'm too lazy.
RemovePlayerWeapon(playerid, weaponid)
Note that this doesn't have a return value.
From one of my old projects. Will post more later on, I'm not going to use them so I might as well post some here.
pawn Код:
stock DoesPlayerHaveAnyWeapon(playerid)
{
new
iWeaponID,
iAmmo;
for(new i =0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, iWeaponID, iAmmo);
if(iWeaponID > 0 && iAmmo > 0)
{
return 1;
}
}
return 0;
}
DoesPlayerHaveWeapon(playerid, weaponid, slot)
I could've discluded the slot parameter to make this function much easier to use, however for it's initial use it required it. I could remove it and have it check that itself (with ease) but I'm too lazy.
pawn Код:
stock DoesPlayerHaveWeapon(playerid, weaponid, slot)
{
if(weaponid < 0 || weaponid > 50)
return 0;
static iWeaponData[2];
// 0 = weapon
// 1 = ammo
GetPlayerWeaponData(playerid, slot, iWeaponData[0], iWeaponData[1]);
if(iWeaponData[0] == weaponid && iWeaponData[1] > 0)
{
return 1;
}
return 0;
}
Note that this doesn't have a return value.
pawn Код:
stock RemovePlayerWeapon(playerid, iWeaponID)
{
if(iWeaponID < 0 || iWeaponID > 50)
{
return;
}
new
iWeapon[13],
iAmmo[13];
for(new iSlot; iSlot < 13; iSlot++)
{
GetPlayerWeaponData(playerid, iSlot, iWeapon[iSlot], iAmmo[iSlot]);
}
ResetPlayerWeapons(playerid);
for(new iSlot; iSlot < 13; iSlot++)
{
if(iAmmo[iSlot] == 0 || iWeapon[iSlot] == iWeaponID)
continue;
GivePlayerWeapon(playerid, iWeapon[iSlot], iAmmo[iSlot]);
}
}
From one of my old projects. Will post more later on, I'm not going to use them so I might as well post some here.