Posts: 10
Threads: 5
Joined: May 2014
Reputation:
0
How can I create a pickup that checks how many current ammunition are available to a certain weapon(let's say AK) and adds a certain amount(20) to that weapons ammunition stockpile? I know about the SetPlayerAmmo system, but it doesn't help for it just sets ammo for a weapon, not add.
Also, is it possible to stream a player's in-hand weapon as invisible to make the possibility of using beta weapon objects?
Posts: 6,129
Threads: 36
Joined: Jan 2009
I've written some code below which should help explain how it can be done. See the comments for an explanation.
pawn Код:
// Create a variable to handle the ID of the pickupnew iWeaponPickup;
public OnGameModeInit
() { // Create the pickup with the AK-47 model (you will have to change this if you want different weapons) // You can find a model list here: https://sampwiki.blast.hk/wiki/Pickup_IDs iWeaponPickup
= CreatePickup
(355,
2,
0.0,
0.0,
9.0);
return 1;
}public OnPlayerPickUpPickup
(playerid, pickupid
) { // Use the iWeaponPickup variable to TRACK the ID of the pickup if(pickupid
== iWeaponPickup
) { // Create a variable to store the information we get from GetPlayerWeaponData new iWeaponData
[2];
// 0 - Weapon ID, 1 - Weapon Ammo // Check weapon slot 5 (which holds the AK-47) for the weapon ID and the ammo amount // Weapon Slot List: https://sampwiki.blast.hk/wiki/Weapons GetPlayerWeaponData
(playerid,
5, iWeaponData
[0], iWeaponData
[1]);
// Check if the weapon in the slot specified is the AK-47, if so, add 100 to their ammo if(iWeaponData
[0] == WEAPON_AK47
) SetPlayerAmmo
(playerid, WEAPON_AK47, iWeaponData
[1]+20);
} return 1;
}
As for hiding player weapons and still making them usable, I'm not quite sure that's possible but it might be possible to hide player objects over the weapon.