Issues with weapon saving system when dropping weapons. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Issues with weapon saving system when dropping weapons. (
/showthread.php?tid=548278)
Issues with weapon saving system when dropping weapons. -
Dokins - 28.11.2014
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]
Re: Issues with weapon saving system when dropping weapons. -
Dokins - 29.11.2014
Bump.