27.11.2014, 21:53
Basically, my system is through MySQL and I literally had a guy help me out with it a while ago, he's out of contact and I had a break from SAMP. Can't seem to remember what does what precisely.
My weapon saves like this:
WeaponSlot is retrieved from WeaponModel.
PlayerWeapons[playerid][w] = SQLID of the weapon in the WeaponSlot i.e MP5 = 4th Slot so W4 = MP5 SQLID.
w = 13 slots (Max weapons.)
This command seems to return correctly for GetWepEX, GetWepIndexFromSQL sometimes displays as -1, although sometimes it's correct.
This is the function I do not understand. The comments are conversations between me and the guy who was helping.
Seriously, any help would be greatly appreciated.
My weapon saves like this:
WeaponSlot is retrieved from WeaponModel.
PlayerWeapons[playerid][w] = SQLID of the weapon in the WeaponSlot i.e MP5 = 4th Slot so W4 = MP5 SQLID.
w = 13 slots (Max weapons.)
This command seems to return correctly for GetWepEX, GetWepIndexFromSQL sometimes displays as -1, although sometimes it's correct.
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;
}
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;
}