Struggling to update code to support MYSQL R40+ -
NinjaChicken - 15.07.2018
Hmm, im really trying to understand this mysql business, todays project is my safe system,
this is what i've changed the load code to
Код:
public onloadSafes() {
new
iRows,
iFields,
szResult[64];
cache_get_data(iRows, iFields, MainPipeline);
if(!iRows)
return printf("[LoadSafes] Failed to load any Safes.");
for(new iRow; iRow < iRows; iRow++) {
cache_get_value_name_int(iRow, "safeDBID", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iDBID] = strval(szResult);
cache_get_value_name_int(iRow, "safeType", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iType] = strval(szResult);
cache_get_value_name_int(iRow, "safeTypeID", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iTypeID] = strval(szResult);
cache_get_field_name_int(iRow, "safeVW", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iVW] = strval(szResult);
cache_get_field_name_int(iRow, "safeInt", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iVW] = strval(szResult);
cache_get_field_name_int(iRow, "safeModel", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iModelID] = strval(szResult);
cache_get_field_name_float(iRow, "safePosX", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][0] = floatstr(szResult);
cache_get_field_name_float(iRow, "safePosY", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][1] = floatstr(szResult);
cache_get_field_name_float(iRow, "safePosZ", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][2] = floatstr(szResult);
cache_get_field_name_float(iRow, "safeRotX", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][3] = floatstr(szResult);
cache_get_field_name_float(iRow, "safeRotY", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][4] = floatstr(szResult);
cache_get_field_name_float(iRow, "safeRotZ", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][5] = floatstr(szResult);
cache_get_field_name_int(iRow, "safeMoney", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iMoney] = strval(szResult);
cache_get_field_name_int(iRow, "safePin", SafeData[iRow][g_iPin], MainPipeline, 5);
cache_get_field_name_int(iRow, "safeRobbed", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iRobbed] = strval(szResult);
cache_get_field_name_int(iRow, "safeRobbedTime", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_tRobbedTime] = strval(szResult);
processSafe(iRow);
}
return printf("[MySQL] Loaded %i Safes from database.", iRows);
}
And im getting ALOT of errors so obviously i don't quite understand what im doing
this is what the code used to be
Код:
forward onloadSafes();
public onloadSafes() {
new
iRows,
iFields,
szResult[64];
cache_get_data(iRows, iFields, MainPipeline);
if(!iRows)
return printf("[LoadSafes] Failed to load any Safes.");
for(new iRow; iRow < iRows; iRow++) {
cache_get_field_content(iRow, "safeDBID", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iDBID] = strval(szResult);
cache_get_field_content(iRow, "safeType", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iType] = strval(szResult);
cache_get_field_content(iRow, "safeTypeID", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iTypeID] = strval(szResult);
cache_get_field_content(iRow, "safeVW", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iVW] = strval(szResult);
cache_get_field_content(iRow, "safeInt", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iVW] = strval(szResult);
cache_get_field_content(iRow, "safeModel", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iModelID] = strval(szResult);
cache_get_field_content(iRow, "safePosX", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][0] = floatstr(szResult);
cache_get_field_content(iRow, "safePosY", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][1] = floatstr(szResult);
cache_get_field_content(iRow, "safePosZ", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][2] = floatstr(szResult);
cache_get_field_content(iRow, "safeRotX", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][3] = floatstr(szResult);
cache_get_field_content(iRow, "safeRotY", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][4] = floatstr(szResult);
cache_get_field_content(iRow, "safeRotZ", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_fPos][5] = floatstr(szResult);
cache_get_field_content(iRow, "safeMoney", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iMoney] = strval(szResult);
cache_get_field_content(iRow, "safePin", SafeData[iRow][g_iPin], MainPipeline, 5);
cache_get_field_content(iRow, "safeRobbed", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_iRobbed] = strval(szResult);
cache_get_field_content(iRow, "safeRobbedTime", szResult, MainPipeline, sizeof szResult); SafeData[iRow][g_tRobbedTime] = strval(szResult);
processSafe(iRow);
}
return printf("[MySQL] Loaded %i Safes from database.", iRows);
}
What have i done wrong? and is someone able to show me what i need todo to fix it
Re: Struggling to update code to support MYSQL R40+ -
IdonTmiss - 15.07.2018
Maybe try this?
-
https://sampforum.blast.hk/showthread.php?tid=337810
Re: Struggling to update code to support MYSQL R40+ -
NinjaChicken - 15.07.2018
il read through it but this shit is doing my head in,
Код:
./includes/group/gangrobbery.pwn(681) : warning 215: expression has no effect
./includes/group/gangrobbery.pwn(687) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(687) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(688) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(688) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(689) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(689) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(690) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(690) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(691) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(691) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(692) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(692) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(693) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(693) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(694) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(694) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(695) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(695) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(696) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(696) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(697) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(697) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(698) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(698) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(699) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(699) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(700) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(700) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(701) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(701) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(702) : warning 213: tag mismatch
./includes/group/gangrobbery.pwn(702) : warning 202: number of arguments does not match definition
./includes/group/gangrobbery.pwn(677) : symbol is never used: "iFields"
Re: Struggling to update code to support MYSQL R40+ -
Rolux - 15.07.2018
Код:
public onloadSafes() {
new iRows;
cache_get_row_count(iRows);
if(!iRows) return printf("[LoadSafes] Failed to load any Safes.");
for(new iRow; iRow < iRows; iRow++) {
cache_get_value_name_int(iRow, "safeDBID", SafeData[iRow][g_iDBID]);
cache_get_value_name_int(iRow, "safeType", SafeData[iRow][g_iType]);
cache_get_value_name_int(iRow, "safeTypeID",SafeData[iRow][g_iTypeID]);
cache_get_field_name_int(iRow, "safeVW", SafeData[iRow][g_iVW]);
cache_get_field_name_int(iRow, "safeInt", SafeData[iRow][g_iInt]);
cache_get_field_name_int(iRow, "safeModel", SafeData[iRow][g_iModelID]);
cache_get_field_name_float(iRow, "safePosX", SafeData[iRow][g_fPos][0]);
cache_get_field_name_float(iRow, "safePosY", SafeData[iRow][g_fPos][1]);
cache_get_field_name_float(iRow, "safePosZ", SafeData[iRow][g_fPos][2]);
cache_get_field_name_float(iRow, "safeRotX", SafeData[iRow][g_fPos][3]);
cache_get_field_name_float(iRow, "safeRotY", SafeData[iRow][g_fPos][4]);
cache_get_field_name_float(iRow, "safeRotZ", SafeData[iRow][g_fPos][5]);
cache_get_field_name_int(iRow, "safeMoney", SafeData[iRow][g_iMoney]);
cache_get_field_name_int(iRow, "safePin", SafeData[iRow][g_iPin]);
cache_get_field_name_int(iRow, "safeRobbed", SafeData[iRow][g_iRobbed]);
cache_get_field_name_int(iRow, "safeRobbedTime", SafeData[iRow][g_tRobbedTime]);
processSafe(iRow);
}
return printf("[MySQL] Loaded %i Safes from database.", iRows);
}
Re: Struggling to update code to support MYSQL R40+ -
NinjaChicken - 15.07.2018
Код:
./includes/group/gangrobbery.pwn(523) : error 035: argument type mismatch (argument 3)
./includes/group/gangrobbery.pwn(665) : error 035: argument type mismatch (argument 3)
./includes/group/gangrobbery.pwn(684) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(685) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(686) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(687) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(688) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(689) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(690) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(691) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(692) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(693) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(694) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(695) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(696) : error 017: undefined symbol "cache_get_field_name_int"
Just tried your above code and got all that :/
Re: Struggling to update code to support MYSQL R40+ -
Rolux - 15.07.2018
Download the newest MySQL plugin then.
https://github.com/pBlueG/SA-MP-MySQ...41-4-win32.zip
Re: Struggling to update code to support MYSQL R40+ -
NinjaChicken - 15.07.2018
* MySQL plugin R41-4
At the very top of the a_mysql.inc in the includes folder
Re: Struggling to update code to support MYSQL R40+ -
NinjaChicken - 15.07.2018
Il try and elaborate further on this
Код:
./includes/group/gangrobbery.pwn(523) : error 035: argument type mismatch (argument 3)
./includes/group/gangrobbery.pwn(665) : error 035: argument type mismatch (argument 3)
./includes/group/gangrobbery.pwn(684) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(685) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(686) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(687) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(688) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(689) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(690) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(691) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(692) : error 017: undefined symbol "cache_get_field_name_float"
./includes/group/gangrobbery.pwn(693) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(694) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(695) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(696) : error 017: undefined symbol "cache_get_field_name_int"
./includes/group/gangrobbery.pwn(841) : error 035: argument type mismatch (argument 3)
This is line 841
Код:
return mysql_tquery(MainPipeline, szQuery, true, "onCreateSafe", "ii", playerid, i);
this is line 523
Код:
mysql_tquery(MainPipeline, str, false, "OnQueryFinish", "i", NO_THREAD);
Re: Struggling to update code to support MYSQL R40+ -
Rolux - 15.07.2018
Sorry, I made a mistake.
Код:
public onloadSafes() {
new iRows;
cache_get_row_count(iRows);
if(!iRows) return printf("[LoadSafes] Failed to load any Safes.");
for(new iRow; iRow < iRows; iRow++) {
cache_get_value_name_int(iRow, "safeDBID", SafeData[iRow][g_iDBID]);
cache_get_value_name_int(iRow, "safeType", SafeData[iRow][g_iType]);
cache_get_value_name_int(iRow, "safeTypeID",SafeData[iRow][g_iTypeID]);
cache_get_value_name_int(iRow, "safeVW", SafeData[iRow][g_iVW]);
cache_get_value_name_int(iRow, "safeInt", SafeData[iRow][g_iInt]);
cache_get_value_name_int(iRow, "safeModel", SafeData[iRow][g_iModelID]);
cache_get_value_name_float(iRow, "safePosX", SafeData[iRow][g_fPos][0]);
cache_get_value_name_float(iRow, "safePosY", SafeData[iRow][g_fPos][1]);
cache_get_value_name_float(iRow, "safePosZ", SafeData[iRow][g_fPos][2]);
cache_get_value_name_float(iRow, "safeRotX", SafeData[iRow][g_fPos][3]);
cache_get_value_name_float(iRow, "safeRotY", SafeData[iRow][g_fPos][4]);
cache_get_value_name_float(iRow, "safeRotZ", SafeData[iRow][g_fPos][5]);
cache_get_value_name_int(iRow, "safeMoney", SafeData[iRow][g_iMoney]);
cache_get_value_name_int(iRow, "safePin", SafeData[iRow][g_iPin]);
cache_get_value_name_int(iRow, "safeRobbed", SafeData[iRow][g_iRobbed]);
cache_get_value_name_int(iRow, "safeRobbedTime", SafeData[iRow][g_tRobbedTime]);
processSafe(iRow);
}
return printf("[MySQL] Loaded %i Safes from database.", iRows);
}
Line 523:
Код:
mysql_tquery(MainPipeline, str, "OnQueryFinish", "i", NO_THREAD);
Line 841:
Код:
return mysql_tquery(MainPipeline, szQuery, "onCreateSafe", "ii", playerid, i);
Re: Struggling to update code to support MYSQL R40+ -
NinjaChicken - 15.07.2018
You are a fkn legend! thank you so much! i'm have another little issue and i was wondering if you can also help me fix it,
Код:
GangTag_Load()
{
mysql_tquery(MainPipeline, "SELECT *FROM `gangtags` where 1", "GangTag_OnLoad", "");
}
forward GangTag_OnLoad();
public GangTag_OnLoad()
{
new iRows;
cache_get_row_count(iRows);
if(!iRows) return print("[Gang Tags] There are no gang tags in the database.");
new idx,
szResult[MAX_GANGTAGS_LEN],
value,
Float:fValue;
while(idx < iRows)
{
cache_get_value_name(idx, "text", szResult);
GangTag_AdmProcess(idx, cache_get_value_name_float(idx, "x", fValue),
cache_get_value_name_float(idx, "y", fValue),
cache_get_value_name_float(idx, "z", fValue),
cache_get_value_name_float(idx, "rx", fValue),
cache_get_value_name_float(idx, "ry", fValue),
cache_get_value_name_float(idx, "rz", fValue),
szResult,
cache_get_value_name_int(idx, "fontid", value),
cache_get_value_name_int(idx, "color", value));
idx++;
}
printf("[Gang Tags] Loaded %d gang tags.", idx);
return 1;
}
Код:
GangTag_AdmSave(iPlayerID, i)
{
new Float:gt_finPos[6];
GetDynamicObjectPos(arrGangTags[i][gt_iObjectID], gt_finPos[0], gt_finPos[1], gt_finPos[2]);
GetDynamicObjectRot(arrGangTags[i][gt_iObjectID], gt_finPos[3], gt_finPos[4], gt_finPos[5]);
if(IsValidDynamic3DTextLabel(arrGangTags[i][gt_iTextID])) DestroyDynamic3DTextLabel(arrGangTags[i][gt_iTextID]);
format(szMiscArray, sizeof(szMiscArray), "Gang Tag Point (ID %d)", i);
arrGangTags[i][gt_iTextID] = CreateDynamic3DTextLabel(szMiscArray, COLOR_YELLOW, gt_finPos[0], gt_finPos[1], gt_finPos[2]+2.75, 4.0);
mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT * FROM `gangtags` WHERE `id` = '%d'", i);
mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnSetText", "i", i);
mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `gangtags` SET `x` = '%f', `y` = '%f', `z` = '%f', `rx` = '%f', `ry` = '%f', `rz` = '%f' WHERE `id` = '%d'",
gt_finPos[0], gt_finPos[1], gt_finPos[2], gt_finPos[3], gt_finPos[4], gt_finPos[5], i);
mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnAdmSave", "ii", iPlayerID, i);
}
forward GangTag_OnSetText(i);
public GangTag_OnSetText(i)
{
new iRows,
szResult[MAX_GANGTAGS_LEN],
iCount,
color,
fontid;
cache_get_row_count(iRows);
while(iCount < iRows)
{
cache_get_value_name(iCount, "text", szResult);
cache_get_value_name_int(iCount, "color", color);
cache_get_value_name_int(iCount, "fontid", fontid);
SetDynamicObjectMaterialText(arrGangTags[i][gt_iObjectID], 0, szResult, OBJECT_MATERIAL_SIZE_512x512, szFonts[fontid], 1000 / strlen(szResult), 1, GangTag_IntColor(color), 0, 1);
++iCount;
}
return 1;
}
forward GangTag_OnAdmSave(iPlayerID, i);
public GangTag_OnAdmSave(iPlayerID, i)
{
if(mysql_errno()) return SendClientMessage(iPlayerID, COLOR_GRAD1, "Something went wrong. Try again later.");
format(szMiscArray, sizeof(szMiscArray), "You have successfully edited gang tag ID %d", i);
SendClientMessage(iPlayerID, COLOR_YELLOW, szMiscArray);
return 1;
}
GangTag_AdmProcess(i, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ, text[], fontid, color)
{
Iter_Add(GangTags, i);
if(IsValidDynamicObject(arrGangTags[i][gt_iObjectID])) DestroyDynamicObject(arrGangTags[i][gt_iObjectID]);
arrGangTags[i][gt_iObjectID] = CreateDynamicObject(GANGTAGS_OBJECTID, X, Y, Z, RX, RY, RZ);
if(IsValidDynamic3DTextLabel(arrGangTags[i][gt_iTextID])) DestroyDynamic3DTextLabel(arrGangTags[i][gt_iTextID]);
format(szMiscArray, sizeof(szMiscArray), "Gang Tag Point (ID %d)", i);
arrGangTags[i][gt_iTextID] = CreateDynamic3DTextLabel(szMiscArray, COLOR_YELLOW, X, Y, Z+2.75, 4.0);
SetDynamicObjectMaterialText(arrGangTags[i][gt_iObjectID], 0, text, OBJECT_MATERIAL_SIZE_512x512, szFonts[fontid], 1000 / strlen(text), 1, GangTag_IntColor(color), 0, 1);
}
GangTag_Delete(iPlayerID, i)
{
if(!IsValidDynamicObject(arrGangTags[i][gt_iObjectID])) return SendClientMessage(iPlayerID, COLOR_GRAD1, "You specified an invalid gang tag ID.");
mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "DELETE FROM `gangtags` WHERE `id` = '%d'", i);
mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnDelete", "ii", iPlayerID, i);
return 1;
}
Can you see anything wrong with that code? when i create one in game, it spams the chat 4 times saying the same thing, and on server restart they don't load in