Ammunition pickup help?
#2

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 pickup
new
    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.
Reply


Messages In This Thread
Ammunition pickup help? - by Mach - 28.05.2014, 05:18
Re: Ammunition pickup help? - by Calgon - 28.05.2014, 05:41

Forum Jump:


Users browsing this thread: 1 Guest(s)