More ammo more i buy

Started by Nihongo^, Jul 10, 2023, 07:15 PM

Previous topic - Next topic

Nihongo^

How do i make give you more ammo for the Rocket Launcher or remote when you buy more rockets/remote
else if (cmd == "buywep")
{
    if (!text)
        return ErrorMessage("[#FF0000][Server] - [#FFFFFF]/" + cmd + " <remote/rocket>", player);
    else if (status[player.ID].buywep == false)
        MessagePlayer("[#FF0000][Error] - [#FFFFFF] You must be at ammunation to buy this wep", player);
    else
    {
        if (text == "remote")
        {
            if (player.Cash >= 20000)
            {
                ClientMessage("-> [#daff00]** Successfully purchased Remote Grenade", player, 255, 0, 102);
                player.SetWeapon(13, 10);
                RemoveCash(player, 20000);
            }
            else
            {
                MessagePlayer("[#FF0000]You need at least $20000 to buy remote grenade", player);
            }
        }
        else if (text == "rocket")
        {
            if (player.Cash >= 10000)
            {
                ClientMessage("-> [#daff00]** Successfully purchased Rocket Launcher", player, 255, 0, 102);
                player.SetWeapon(30, 10);
                RemoveCash(player, 10000);
            }
            else
            {
                MessagePlayer("[#FF0000]You need at least $10000 to buy Rocket Launcher", player);
            }
        }
    }
}

habi

#1
you give it by adding ammo to current ammo:
player.SetWeapon(13, 10 + player.GetAmmoAtSlot(2));
For rocket, slot is 7.

Nihongo^

Quote from: habi on Jul 11, 2023, 04:35 AMFor the rocket, the slot is 7.

Thank you so much
 How do I know about other weapons slots? Can you please show me where I can get the list?

habi

Quote from: Nihongo^ on Jul 11, 2023, 09:11 AM
Quote from: habi on Jul 11, 2023, 04:35 AMFor the rocket, the slot is 7.

Thank you so much
 How do I know about other weapons slots? Can you please show me where I can get the list?
See the get GetSlot function in https://forum.vc-mp.org/index.php?topic=7567.msg47551#msg47551

Another way is to use player.Slot

Xmair

Quote from: habi on Jul 11, 2023, 04:35 AMyou give it by adding ammo to current ammo:
player.SetWeapon(13, 10 + player.GetAmmoAtSlot(2));
For rocket, slot is 7.
Better version:
player.GiveWeapon(13, 10);

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD