Issues with weapon system, storing weapons.
#1

Hi there

I have a fairly complicated MySQL weapon
System, every weapon has an ID, model etc is stored on MySQL.

Basically I cannot store an MP5 which is ID 1 in MySQL and therefore ID 0 on server index.

Every other weapon works fine, however if I store a weapon it also removes the MP5 (Id 0)

Here are all the parts. Please let me know if you wish to see anything else.

I've been working tirelessly and endlessly.
Any assistance would be crazy.
pawn Код:
// ALL THE CODE YOU NEED I HOPE.


//GIVEWEAPONEX (GIVES ALL WEAPONS ON THE SQLID)
stock GivePlayerWeaponEx(playerid)
{
    for(new w = 0; w < 13; w++)
    {
        new id = GetWepIndexFromSQL(PlayerWeapons[playerid][w]);
       
        if(id < 0)
            continue;
            printf("CONTINUE ID in GIVEPLAYERWEAPON: %d", id);
        if(WepAmmo[id] > 0)
        {
            printf("AMMO ID in GIVEPLAYERWEAPON: %d", id);
            GivePlayerWeapon(playerid,WepModel[id],WepAmmo[id]);

        }

    }
    printf("Weapon ID in GIVEPLAYERWEAPON: %d", id);
    printf("Weapon MODEL %d Weapon AMMO %d in GIVEPLAYERWEAPON: %d", WepModel[id],WepAmmo[id], id);
    return 1;
}



//REMOVEPLAYERWEAPON (THE THING I FEEL IS CAUSING THE ISSUE).
RemovePlayerWeapon(playerid, weaponid)
{
    printf("Weapon id %d , Playerid%d", playerid, weaponid);
    //new weaponid = GetPlayerWeaponEx(playerid); - Weapon SQLID
    new wepidx = GetWepIndexFromSQL(weaponid);
    printf("Get weapon index from SQL %d", wepidx);
    new slot = GetWeaponSlot(WepModel[wepidx]);
    printf("wepidx %d, slot %d", wepidx, slot);
    PlayerWeapons[playerid][slot] = 0;
    printf("player weapons slot %d", PlayerWeapons[playerid][slot]);
    printf("wepidx %d", wepidx);
    ResetPlayerWeapons(playerid);
    printf("Reset Weapons");
    GivePlayerWeaponEx(playerid);
    printf("Reset Weapons");
   
    return 1;
}

//THE STORING AREA, IT DELETES THE INDEX ID 0
            if(!(strcmp(item, "weapon", true)))
            {
                if(VehicleSQLID[vehicleid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You cannot store a weapon in this vehicle");
                if(VehWep1[vehicleid] > 0 && VehWep2[vehicleid] > 0)return SendClientMessage(playerid, COLOUR_GREY, "You do not have any free weapon slots.");
                if(GetPlayerWeapon(playerid) < 1) return SendClientMessage(playerid, COLOUR_GREY, "You do not have a weapon to store.");

                new model = GetPlayerWeapon(playerid);
                printf("model %d", model);

                new wslot = GetWeaponSlot(model);
                printf("wslot %d", wslot);

                if(VehWep1[vehicleid] == 0)
                {
                    if(VehicleSQLID[vehicleid] > 0)
                    {
                        VehWep1[vehicleid] = PlayerWeapons[playerid][wslot];
                        printf("SAVED VEH WEP 1 =: %d", PlayerWeapons[playerid][wslot]);
                        printf("VEH WEP 1 %d", VehWep1[vehicleid]);
                        new wepid  = PlayerWeapons[playerid][wslot];
                        MySQL_SetInteger(VehicleSQLID[vehicleid], "VehWep1", PlayerWeapons[playerid][wslot], "vehicles");
                        printf("SAVED to mysql =: %d", PlayerWeapons[playerid][wslot]);
                        new fieldname[12];
                        format(fieldname, sizeof(fieldname), "Weapon%d", wslot);
                        printf("Weapon SLOT %d", wslot);
                       
                        MySQL_SetInteger(PlayerSQLID[playerid], fieldname, 0, "accounts");//this is the line that sadly is correct BUT someone something else is done...
                        RemovePlayerWeapon(playerid, wepid);
                        format(string, sizeof(string), "You have stored a %s in the vehicle's trunk.", WeaponNames[model]);
                        SendClientMessage(playerid, COLOUR_BLUE, string);
                        format(string, sizeof(string), "* %s has stored a weapon in the vehicle's trunk.", GetNameEx(playerid));
                        ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
                    }

                }
Reply
#2

Bump.
Reply
#3

Still unresolved
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)