GMS 2 Problem With Array list of weapons

H2S04

Member
Hi, i have a problem with my weapons arrays. When i want to shot, my weapon ammo change from 5 to 4 and back to 5, then i can't shot anymore, when i change my weapon to a Bow, reload (auto reload) cant be completed and start over an over. When i reload, my ammo is subtraction from EQ but Weapon mag is still on 5...
What i do wrong? (Sorry for my english is bad i know that :p )

PS. Sorry for primweapon and specweapon array code comments in Polish, but arrays is same :)

EDIT: I repair a shot problem, but still have problem with ammo;
Could problem be with varible Weapon? to change the array to secweapon, primweapon, specweapon?

GML:
CREATE:

#region //Weapons
#region //Secondray Weapons
/*
secweapon[,0] = "Metal Made Pistol"; //Weapon Name
secweapon[,1] = 0.3; //Shot speed * room_speed // 1 = 1sec;
secweapon[,2] = 1.5; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[,3] = 3; //Min Armor Penetration
secweapon[,4] = 8; //Max Armor Penetration
secweapon[,5] = 2; //Ammo Type ////        9mm
secweapon[,6] = 0; //Amount of ammo in mag
secweapon[,7] = 20; //Max Ammount of ammo in mag
*/


secweapon[0,0] = "EMPTY";  //Weapon Name
secweapon[0,1] = 0; //Shot speed * room_speed // 1 = 1sec;
secweapon[0,2] = 0; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[0,3] = 0; //Min Armor Penetration
secweapon[0,4] = 0; //Max Armor Penetration
secweapon[0,5] = 0; //Typ Używanej Amunicji ////
secweapon[0,6] = 0; //Ilość Amunicji w Magazynku
secweapon[0,7] = 0; //Max Ammount of ammo in mag

secweapon[1,0] = "Wood Made Pistol";  //Weapon Name
secweapon[1,1] = 0.3; //Shot speed * room_speed // 1 = 1sec;
secweapon[1,2] = 2;  //Reload Speed * room_Speed // 1 = 1sec;
secweapon[1,3] = 3; //Min Armor Penetration
secweapon[1,4] = 5; //Max Armor Penetration
secweapon[1,5] = 2; //Ammo Type ////        9mm
secweapon[1,6] = 5; //Amount of ammo in mag
secweapon[1,7] = 15; //Max Ammount of ammo in mag

secweapon[2,0] = "Metal Made Pistol";  //Weapon Name
secweapon[2,1] = 0.3; //Shot speed * room_speed // 1 = 1sec;
secweapon[2,2] = 1.8; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[2,3] = 3; //Min Armor Penetration
secweapon[2,4] = 8; //Max Armor Penetration
secweapon[2,5] = 2; //Ammo Type ////        9mm
secweapon[2,6] = 0; //Amount of ammo in mag
secweapon[2,7] = 20; //Max Ammount of ammo in mag

secweapon[3,0] = "Normal Pistol";  //Weapon Name
secweapon[3,1] = 0.15; //Shot speed * room_speed // 1 = 1sec;
secweapon[3,2] = 1.7; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[3,3] = 5; //Min Armor Penetration
secweapon[3,4] = 10; //Max Armor Penetration
secweapon[3,5] = 2; //Ammo Type ////        9mm
secweapon[3,6] = 0; //Amount of ammo in mag
secweapon[3,7] = 25; //Max Ammount of ammo in mag

secweapon[4,0] = "Better Pistol";  //Weapon Name
secweapon[4,1] = 0.15; //Shot speed * room_speed // 1 = 1sec;
secweapon[4,2] = 1.5; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[4,3] = 7; //Min Armor Penetration
secweapon[4,4] = 12; //Max Armor Penetration
secweapon[4,5] = 2; //Ammo Type ////        9mm
secweapon[4,6] = 0; //Amount of ammo in mag
secweapon[4,7] = 30; //Max Ammount of ammo in mag

secweapon[5,0] = "Police Pistol";  //Weapon Name
secweapon[5,1] = 0.15; //Shot speed * room_speed // 1 = 1sec;
secweapon[5,2] = 1.5; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[5,3] = 8; //Min Armor Penetration
secweapon[5,4] = 14; //Max Armor Penetration
secweapon[5,5] = 2; //Ammo Type ////        9mm
secweapon[5,6] = 0; //Amount of ammo in mag
secweapon[5,7] = 25; //Max Ammount of ammo in mag

secweapon[6,0] = "Special Forces Pistol";  //Weapon Name
secweapon[6,1] = 0.15; //Shot speed * room_speed // 1 = 1sec;
secweapon[6,2] = 1.5; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[6,3] = 8; //Min Armor Penetration
secweapon[6,4] = 18; //Max Armor Penetration
secweapon[6,5] = 3; //Ammo Type ////        5.56mm
secweapon[6,6] = 0; //Amount of ammo in mag
secweapon[6,7] = 20; //Max Ammount of ammo in mag

secweapon[7,0] = "Metal Made Pistol";  //Weapon Name
secweapon[7,1] = 0.4; //Shot speed * room_speed // 1 = 1sec;
secweapon[7,2] = 2; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[7,3] = 15; //Min Armor Penetration
secweapon[7,4] = 25; //Max Armor Penetration
secweapon[7,5] = 4; //Ammo Type ////        7.62mm
secweapon[7,6] = 0; //Amount of ammo in mag
secweapon[7,7] = 10; //Max Ammount of ammo in mag

#endregion

#region //Primary Weapons
/*
primweapon[,0] = "Metal Made Pistol"; //Nazwa Broni
primweapon[,1] = 0.3; //Szybkośc Strzelania * room_speed // 1 = 1sec;
primweapon[,2] = 1.5; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
primweapon[,3] = 3; //Minimalna Penetracja Pancerza
primweapon[,4] = 8; //Maksymalna Penetracja Pancerza
primweapon[,5] = 2; //Typ Używanej Amunicji //// 
primweapon[,6] = 0; //Ilość Amunicji w Magazynku
primweapon[,7] = 20; //Maksymalna Ilość Amunicji w Magazynku
*/

primweapon[0,0] = "EMPTY"; //Nazwa Broni
primweapon[0,1] = 0; //Szybkośc Strzelania * room_speed // 1 = 1sec;
primweapon[0,2] = 0; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
primweapon[0,3] = 0; //Minimalna Penetracja Pancerza
primweapon[0,4] = 0; //Maksymalna Penetracja Pancerza
primweapon[0,5] = 0; //Typ Używanej Amunicji ////
primweapon[0,6] = 0; //Ilość Amunicji w Magazynku
primweapon[0,7] = 0; //Maksymalna Ilość Amunicji w Magazynku

primweapon[1,0] = "BOW"; //Nazwa Broni
primweapon[1,1] = 1; //Szybkośc Strzelania * room_speed // 1 = 1sec;
primweapon[1,2] = 1; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
primweapon[1,3] = 5; //Minimalna Penetracja Pancerza
primweapon[1,4] = 15; //Maksymalna Penetracja Pancerza
primweapon[1,5] = 1; //Typ Używanej Amunicji ////        Arrows
primweapon[1,6] = 0; //Ilość Amunicji w Magazynku
primweapon[1,7] = 1; //Maksymalna Ilość Amunicji w Magazynku

primweapon[2,0] = "Small PM"; //Nazwa Broni
primweapon[2,1] = 0.1; //Szybkośc Strzelania * room_speed // 1 = 1sec;
primweapon[2,2] = 2; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
primweapon[2,3] = 5; //Minimalna Penetracja Pancerza
primweapon[2,4] = 12; //Maksymalna Penetracja Pancerza
primweapon[2,5] = 2; //Typ Używanej Amunicji ////        9mm
primweapon[2,6] = 0; //Ilość Amunicji w Magazynku
primweapon[2,7] = 30; //Maksymalna Ilość Amunicji w Magazynku

primweapon[3,0] = "Rifle 74"; //Nazwa Broni
primweapon[3,1] = 0.3; //Szybkośc Strzelania * room_speed // 1 = 1sec;
primweapon[3,2] = 1.5; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
primweapon[3,3] = 3; //Minimalna Penetracja Pancerza
primweapon[3,4] = 8; //Maksymalna Penetracja Pancerza
primweapon[3,5] = 4; //Typ Używanej Amunicji ////        7.62mm
primweapon[3,6] = 0; //Ilość Amunicji w Magazynku
primweapon[3,7] = 30; //Maksymalna Ilość Amunicji w Magazynku

#endregion

#region //Special Weapons
/*
specweapon[,0] = "Metal Made Pistol"; //Nazwa Broni
specweapon[,1] = 0.3; //Szybkośc Strzelania * room_speed // 1 = 1sec;
specweapon[,2] = 1.5; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
specweapon[,3] = 3; //Minimalna Penetracja Pancerza
specweapon[,4] = 8; //Maksymalna Penetracja Pancerza
specweapon[,5] = 2; //Typ Używanej Amunicji ////        9mm
specweapon[,6] = 0; //Ilość Amunicji w Magazynku
specweapon[,7] = 20; //Maksymalna Ilość Amunicji w Magazynku
*/

specweapon[0,0] = "EMPTY"; //Nazwa Broni
specweapon[0,1] = 0; //Szybkośc Strzelania * room_speed // 1 = 1sec;
specweapon[0,2] = 0; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
specweapon[0,3] = 0; //Minimalna Penetracja Pancerza
specweapon[0,4] = 0; //Maksymalna Penetracja Pancerza
specweapon[0,5] = 0; //Typ Używanej Amunicji ////
specweapon[0,6] = 0; //Ilość Amunicji w Magazynku
specweapon[0,7] = 0; //Maksymalna Ilość Amunicji w Magazynku

specweapon[1,0] = "Wood Rifle"; //Nazwa Broni
specweapon[1,1] = 1; //Szybkośc Strzelania * room_speed // 1 = 1sec;
specweapon[1,2] = 2; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
specweapon[1,3] = 8; //Minimalna Penetracja Pancerza
specweapon[1,4] = 25; //Maksymalna Penetracja Pancerza
specweapon[1,5] = 3; //Typ Używanej Amunicji ////        9mm
specweapon[1,6] = 0; //Ilość Amunicji w Magazynku
specweapon[1,7] = 10; //Maksymalna Ilość Amunicji w Magazynku

specweapon[2,0] = "Pipe Pump"; //Nazwa Broni
specweapon[2,1] = 1; //Szybkośc Strzelania * room_speed // 1 = 1sec;
specweapon[2,2] = 1; //Szybkość Przeładowania * room_Speed // 1 = 1sec;
specweapon[2,3] = 3; //Minimalna Penetracja Pancerza
specweapon[2,4] = 8; //Maksymalna Penetracja Pancerza
specweapon[2,5] = 2; //Typ Używanej Amunicji ////        9mm
specweapon[2,6] = 0; //Ilość Amunicji w Magazynku
specweapon[2,7] = 5; //Maksymalna Ilość Amunicji w Magazynku

#endregion


#region //Ammunition
/*
ammunition[,0] = "EMPTY"; //Ammo Name
ammunition[,1] = 0; //Amount what i have
ammunition[,2] = 0; //Max Amount in EQ
ammunition[,3] = 0; //Penetration
ammunition[,4] = 0; //Min DMG
ammunition[,5] = 0; //Max DMG
ammunition[,6] = 0; //Speed
*/

ammunition[0,0] = "EMPTY"; //Ammo Name
ammunition[0,1] = 0; //Amount what i have
ammunition[0,2] = 0; //Max Amount in EQ
ammunition[0,3] = 0; //Penetration
ammunition[0,4] = 0; //Min DMG
ammunition[0,5] = 0; //Max DMG
ammunition[0,6] = 0; //Speed

ammunition[1,0] = "Arrows"; //Ammo Name
ammunition[1,1] = 5; //Amount what i have
ammunition[1,2] = 50; //Max Amount in EQ
ammunition[1,3] = 20; //Penetration
ammunition[1,4] = 10; //Min DMG
ammunition[1,5] = 25; //Max DMG
ammunition[1,6] = 30; //Speed

ammunition[2,0] = "9mm"; //Ammo Name
ammunition[2,1] = 50; //Amount what i have
ammunition[2,2] = 100; //Max Amount in EQ
ammunition[2,3] = 5; //Penetration
ammunition[2,4] = 5; //Min DMG
ammunition[2,5] = 15; //Max DMG
ammunition[2,6] = 50; //Speed

ammunition[3,0] = "5.56mm"; //Ammo Name
ammunition[3,1] = 50; //Amount what i have
ammunition[3,2] = 100; //Max Amount in EQ
ammunition[3,3] = 10; //Penetration
ammunition[3,4] = 10; //Min DMG
ammunition[3,5] = 20; //Max DMG
ammunition[3,6] = 60; //Speed

ammunition[4,0] = "7.62mm"; //Ammo Name
ammunition[4,1] = 50; //Amount what i have
ammunition[4,2] = 100; //Max Amount in EQ
ammunition[4,3] = 15; //Penetration
ammunition[4,4] = 15; //Min DMG
ammunition[4,5] = 30; //Max DMG
ammunition[4,6] = 70; //Speed

ammunition[5,0] = "Shotgun Shell"; //Ammo Name
ammunition[5,1] = 10; //Amount what i have
ammunition[5,2] = 100; //Max Amount in EQ
ammunition[5,3] = 5; //Penetration
ammunition[5,4] = 5; //Min DMG
ammunition[5,5] = 15; //Max DMG
ammunition[5,6] = 30; //Speed

#endregion

canshot = true; //Can shot
canuneq = true; // Can unequip weapon

Weapon = secweapon;        //Choose array secweapon, primweapon, specweapon
SecSlot = 1;            //Weapon Slot 1 = Secondary
PrimSlot = 1;            //Weapon Slot 2 = Primary
SpecSlot = 0;            //Weapon Slot 3 = Special
ActualSlot = 0;            //Actual slot in use; 0 = Sceondary, 1 = Primary, 2 = Special
WeaponSlot = 0;            //Weapon in slot
WeaponName = "";        //WeaponName
ReloadSpeed = 0;        //Time of reload
ReloadSpeedMax = 0;        //Max Time of reload
ShotSpeed = 0;            //Shot Speed
ActualAmmo = 0;            //Actual ammo type
WeaponSprite = 0;        //Draw Wepon sprite
WeaponIndex = 0;        //Image_Index Weapon Sprite
MaxWeaponAmmo = 0;        //Max ammo in mag (Weapon[1,7] = 10);
WeaponMinArmorPen = 0;    //Min Armor Penetration
WeaponMaxArmorPen = 0;    //Max Armor Penetration
AmmoPenetration = 0;    //Ammo Penteration
MinAmmoDMG = 0;            //Min Ammo DMG
MaxAmmoDMG = 0;            //Max Ammo DMG
MaxEqAmmo = 0;            //Max Ammo in EQ
AmmoName = "";            //Ammo Name
AmmoSpeed = 0;            //Ammo Speed
sspd = 0;                //Shot timer
rspeed = 0;                //Reload Timer
canreload = true;       //can reload
reload = false;            // im reload
reloadend = false;        // end of reload


recoil = 0; // Recoil
moverecoilend = 0; // End recoil
moverecoil = 0; //Recoil when move 0 = Sand, 1 = walk, 2 = run, 3 = Sprint;



dmg = 0;
ap = 0;
alldmg = 0;








STEP:

if global.pausegame == false && myDead == false{

//Choose of weapon slot
if reload == false{
if keyboard_check_pressed(ord("1")){
    ActualSlot = 0;
}
if keyboard_check_pressed(ord("2")){
    ActualSlot = 1;
}
if keyboard_check_pressed(ord("3")){
    ActualSlot = 2;
}
}

//Weapon choose
if (ActualSlot == 0)
{
    Weapon = secweapon;                                //Set an array to secweapon
    WeaponSlot = SecSlot;                            //Set weapon to slot;
    WeaponSprite = 1;                                //Set srpite 1 = s_SceWeaponSprite
} else {
    if (ActualSlot == 1)
    {
        Weapon = primweapon;                    //Set an array to primweapon
        WeaponSlot = PrimSlot;                     
        WeaponSprite = 2;
    } else {
        if (ActualSlot == 2)
        {
            Weapon = specweapon;            //Set an array to specweapon
            WeaponSlot = SpecSlot;                     
            WeaponSprite = 3;
        }
    }
}

/*
secweapon[,0] = "Metal Made Pistol"; //Weapon Name
secweapon[,1] = 0.3; //Shot speed * room_speed // 1 = 1sec;
secweapon[,2] = 1.5; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[,3] = 3; //Min Armor Penetration
secweapon[,4] = 8; //Max Armor Penetration
secweapon[,5] = 2; //Ammo Type ////        9mm
secweapon[,6] = 0; //Amount of ammo in mag
secweapon[,7] = 20; //Max Ammount of ammo in mag

ammunition[,0] = "EMPTY"; //Ammo Name
ammunition[,1] = 0; //Amount what i have
ammunition[,2] = 0; //Max Amount in EQ
ammunition[,3] = 0; //Penetration
ammunition[,4] = 0; //Min DMG
ammunition[,5] = 0; //Max DMG
ammunition[,6] = 0; //Speed
*/

    ActualAmmo = Weapon[WeaponSlot,5];                    //Przypisanie typu ammunicji;
    ReloadSpeed = Weapon[WeaponSlot,2]*room_speed;        //Przypisanie szybkości przeładowania;
    ReloadSpeedMax = Weapon[WeaponSlot,2]*room_speed;    //Przypisanie Maxymalnej szybkości przeładowania;
    ShotSpeed = Weapon[WeaponSlot,1];                    //Przypisanie szybkości strzelania;
    WeaponName = Weapon[WeaponSlot,0];                    //Przypisanie Nazwy Broni
    MaxWeaponAmmo = Weapon[WeaponSlot,7];                //Przypisanie Maksymalnej ilości Ammo w Broni
    WeaponMinArmorPen = Weapon[WeaponSlot,3];            //Przypisanie Minimalnej Penetracji Pocisku Przez Broń
    WeaponMaxArmorPen = Weapon[WeaponSlot,4];            //Przypisanie Maksymalnej Penetracji Pocisku Przez Broń
    WeaponIndex = WeaponSlot;                            //Przypisanie Indexu Sprite Broni

    MinAmmoDMG = ammunition[ActualAmmo,4];                //Przypisanie Minimalnego DMG z Amunicji
    MaxAmmoDMG = ammunition[ActualAmmo,5];                //Przypisanie Maksymalnego DMG z Amunicji
    AmmoPenetration = ammunition[ActualAmmo,3];            //Pryzpisanie Penetracji Pancerza z Amunicji
    MaxEqAmmo = ammunition[ActualAmmo,2];                //Przypisanie Maksymalnej ilości Ammo w EQ
    AmmoName = ammunition[ActualAmmo,0];                //Przypisanie Nazwy Amunicji
    AmmoSpeed = ammunition[ActualAmmo,6];

#region // Choose of hance to shot body part
/////// code deleted
#endregion

recoil = random_range(-5,5);
moverecoilend = (moverecoil * recoil) / global.recoilskill;

dmg = round(irandom_range(MinAmmoDMG,MaxAmmoDMG));
ap = round(irandom_range(WeaponMinArmorPen,WeaponMaxArmorPen));

if global.expmenu == false
{

#region    //SHOT CODE

        if mouse_check_button(mb_left)
        {
            if canshot == true && reload == false
            {
                if global.UnAmmo == false
                {
                    if Weapon[WeaponSlot,6] > 0
                    {
                        canshot = false;
                        alldmg = ((dmg + ap) + AmmoPenetration);
                        if WeaponName = "BOW"{
                            inst = instance_create_layer(x,y,"Instances",o_arrow);
                            inst.speed = AmmoSpeed;
                            inst.spdd = AmmoSpeed;
                            inst.direction = direction;
                            inst.image_angle = direction;
                            inst.ap = ap;
                            inst.dmg = alldmg;
                            inst.bshot = bodyshot;
                            global.lastdmg = alldmg;
                            sspd = ShotSpeed;
                            Weapon[WeaponSlot,6] -= 1;
                        } else {
                            shel = instance_create_layer(x,y,"Instances",o_shell);
                            inst = instance_create_layer(x,y,"Instances",o_bullet);
                            inst.speed = AmmoSpeed;
                            inst.spdd = AmmoSpeed;
                            inst.direction = direction + moverecoilend;
                            inst.image_angle = direction + + moverecoilend;
                            inst.ap = ap;
                            inst.dmg = alldmg;
                            inst.bshot = bodyshot;
                            sspd = ShotSpeed;
                            Weapon[WeaponSlot,6] -= 1;
                        }
                    }
                } else {
                    //if global unammo = true
                    canshot = false;
                        alldmg = ((dmg + ap) + AmmoPenetration);
                        if WeaponName = "BOW"{
                            inst = instance_create_layer(x,y,"Instances",o_arrow);
                            inst.speed = AmmoSpeed;
                            inst.spdd = AmmoSpeed;
                            inst.direction = direction;
                            inst.image_angle = direction;
                            inst.ap = ap;
                            inst.dmg = alldmg;
                            inst.bshot = bodyshot;
                            global.lastdmg = alldmg;
                            sspd = ShotSpeed;
                        } else {
                            shel = instance_create_layer(x,y,"Instances",o_shell);
                            inst = instance_create_layer(x,y,"Instances",o_bullet);
                            inst.speed = AmmoSpeed;
                            inst.spdd = AmmoSpeed;
                            inst.direction = direction + moverecoilend;
                            inst.image_angle = direction + + moverecoilend;
                            inst.ap = ap;
                            inst.dmg = alldmg;
                            inst.bshot = bodyshot;
                            sspd = ShotSpeed;
                        }
                }
            }
        }
if canshot = false && reload = false{
        if sspd > 0{
            sspd -= 1;   
        } else {
            canshot = true;   
        }

#endregion

#region    //RELOAD CODE

/*
secweapon[,0] = "Metal Made Pistol"; //Weapon Name
secweapon[,1] = 0.3; //Shot speed * room_speed // 1 = 1sec;
secweapon[,2] = 1.5; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[,3] = 3; //Min Armor Penetration
secweapon[,4] = 8; //Max Armor Penetration
secweapon[,5] = 2; //Ammo Type ////        9mm
secweapon[,6] = 0; //Amount of ammo in mag
secweapon[,7] = 20; //Max Ammount of ammo in mag

ammunition[,0] = "EMPTY"; //Ammo Name
ammunition[,1] = 0; //Amount what i have
ammunition[,2] = 0; //Max Amount in EQ
ammunition[,3] = 0; //Penetration
ammunition[,4] = 0; //Min DMG
ammunition[,5] = 0; //Max DMG
ammunition[,6] = 0; //Speed
*/


if (WeaponName = "BOW")
{
    if (canreload == true)
    {
        if ((Weapon[WeaponSlot,6] < MaxWeaponAmmo) && (ammunition[ActualAmmo,1] > 0))
        {
            canshot = false;
            canreload = false;
            reload = true;
            rspeed = ReloadSpeed;
        }
    }
} else {
    if keyboard_check_pressed(ord("R"))
    {
        if (canreload == true){
            if (ammunition[ActualAmmo,1] > 0)
            {
                if (Weapon[WeaponSlot,6] < MaxWeaponAmmo)
                {
                    canshot = false;
                    canreload = false;
                    reload = true;
                    rspeed = ReloadSpeed;
                    var mage;
                    mage = instance_create_layer(x,y,"Instances",o_Mag);
                    mage.mag = ActualAmmo;
                }
            }
        }
    }
}

if reload == true
{
    if rspeed > 0{
        rspeed -= 1;
    } else {
        reloadend = true;
    }
}

if reloadend == true
{
    /*
secweapon[,0] = "Metal Made Pistol"; //Weapon Name
secweapon[,1] = 0.3; //Shot speed * room_speed // 1 = 1sec;
secweapon[,2] = 1.5; //Reload Speed * room_Speed // 1 = 1sec;
secweapon[,3] = 3; //Min Armor Penetration
secweapon[,4] = 8; //Max Armor Penetration
secweapon[,5] = 2; //Ammo Type ////        9mm
secweapon[,6] = 0; //Amount of ammo in mag
secweapon[,7] = 20; //Max Ammount of ammo in mag

ammunition[,0] = "EMPTY"; //Ammo Name
ammunition[,1] = 0; //Amount what i have
ammunition[,2] = 0; //Max Amount in EQ
ammunition[,3] = 0; //Penetration
ammunition[,4] = 0; //Min DMG
ammunition[,5] = 0; //Max DMG
ammunition[,6] = 0; //Speed
*/
    var a;
    a = MaxWeaponAmmo - Weapon[WeaponSlot,6]; // a = maxammo (~30) - ammo in mag (~25) == 5 ammo to add;
    if ammunition[ActualAmmo,1] > a // if EQ AMMO(100) > A(5)
    {
        Weapon[WeaponSlot,6] += a;
        ammunition[ActualAmmo,1] -= a;
    } else { //if EQAMMO(3) < A(5)
        Weapon[WeaponSlot,6] += ammunition[ActualAmmo,1]; //(ammo + 3);
        ammunition[ActualAmmo,1] = 0;
    }
  
    reloadend = false;
    reload = false;
    canreload = true;
    canshot = true;
}
#endregion

#endregion
} //global.Expmenu == false;   end
} //global.pausegame = false && mydead == false;  end
 
Last edited:

flyinian

Member
I recommend cleaning the code so, its easier for those trying to help you.

I also recommend adding debug messages to your code and try to narrow down your problem.
 

H2S04

Member
I recommend cleaning the code so, its easier for those trying to help you.

I also recommend adding debug messages to your code and try to narrow down your problem.
Hi, i used debug mesaages but i delete they, The code work, but i See it`s problem to save array, i change Old code to this code, in Old code i have a varibles = arrays and in end of code i Save arrays, but i wanted to get smaller code and write this.
 

Nidoking

Member
You're always resetting the weapon stats to whatever is in the original array, every step. You probably don't want to do that.
 

flyinian

Member
Hi, i used debug mesaages but i delete they, The code work, but i See it`s problem to save array, i change Old code to this code, in Old code i have a varibles = arrays and in end of code i Save arrays, but i wanted to get smaller code and write this.
I just meant comment each section of your code so we know what they do at a glance and delete any commented/unrelated code.
 
Top