Issues with weapon saving system when dropping weapons.
#1

Apparently GetWepIndexFromSQL brings it from the MySQL to the serverside index but I don't understand that.

pawn Код:
stock GetWepIndexFromSQL(weapid)//returns the INDEX of the serverside database (PlayerWeapons[playerid][w] by giving the SQLID as parameter
{//needed when using WepVARIABLES
    new rst = -1;
    new string[40];
    format(string, sizeof(string), "SELECT `id` FROM `weapons`");
    mysql_query(string);
    mysql_store_result();
    new maxr = mysql_num_rows();
    mysql_free_result();
    for(new n=0; n<maxr; n++)
    {
        if(weapid == WepSQLID[n])   //at this point ==> weapid is the SQLID we have from PlayerWeapons
        {//and WepSQLID[n] is the SQL ID that is stored in the serverside table... n is the specific index (the number
            rst = n;//that we need)... Ahh. But if PlayerWeapons stores the SQLID? PlayerWeapons stores the SQLID, I don't
            break;// get your question:D
        }
    }
    return rst;
}
This function wasn't created by me and I cannot remember it's exact function.

When I drop a weapon this returns something like this:

Код:
GetWepEX: 26, GetWepIndexFromSQL: -1.
GetWepEx seems to be returning the model and not the MySQLID.

pawn Код:
CMD:wepcheck(playerid, params[])
{
    new string[50];
    new wep = GetPlayerWeaponEx(playerid);
    format(string, sizeof(string),"GetWepEX: %d, GetWepIndexFromSQL: %d",wep, GetWepIndexFromSQL(wep));
    SendClientMessage(playerid, COLOUR_WHITE, string);
    return 1;
}
This is how the weapons ID is figured out:
pawn Код:
GetPlayerWeaponEx(playerid)//Gets the Weapon id, sqlside, checks what slot it's saved in.
{
    new weaponmodel = GetPlayerWeapon(playerid);
    new slot = GetWeaponSlot(weaponmodel); //here you get the slot the player has the weapon in
    new pslot = PlayerWeapons[playerid][slot]; //PlayerWeapons[playerid][slot] saves the SQLID so pslot = the SQLID of the weapon he uses
    return pslot;   //no the SQLID - Returns SQLID. Check SQLID for WeaponModel
}
pawn Код:
w = 13; //This is an example. This saves the weapon ID (Not the model, mysqlid).
PlayerWeapons [playerid] [w]
Reply
#2

Bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)