Repair System, Not Loading. -
DerickClark - 14.02.2017
My repair position saves in MySQL. But it's not loading from database
OnGameModeInit:
Код:
mysql_tquery(mysql, "SELECT * FROM repair_system", "OnLoadRepairPickups");
Код:
enum aInfo
{
PickupID,
Float: pux,
Float: puy,
Float: puz,
Text3D: TextLabel
};
new ARepairPickups[MAX_REPAIR_PICKUPS][aInfo];
Код:
AddARepairPickups(Float:x, Float:y, Float:z)
{
for (new i; i < sizeof(ARepairPickups); i++)
{
if (ARepairPickups[i][PickupID] == 0)
{
ARepairPickups[i][PickupID] = CreatePickup(3096, 1, x, y, z, 0);
ARepairPickups[i][pux] = x;
ARepairPickups[i][puy] = y;
ARepairPickups[i][puz] = z;
Create3DTextLabel("{FFFF00}Type {00FF00}/repair {FFFF00}to repair your vehicle!", -1, x, y, z +0.5, 50.0, 0);
CreateDynamicMapIcon(x, y, z, 63, 0, 0, 0, -1, 300.0);
break;
}
}
}
Код:
forward OnLoadRepairPickups();
public OnLoadRepairPickups()
{
new count;
cache_get_row_count(count);
for(new i; i < count; i++)
{
i = cache_get_value_name_int(i, "PickupID", ARepairPickups[i][PickupID]);
cache_get_value_name_float(i, "pux", ARepairPickups[i][pux]);
cache_get_value_name_float(i, "puy", ARepairPickups[i][puy]);
cache_get_value_name_float(i, "puz", ARepairPickups[i][puz]);
}
return 1;
}
Код:
CMD:createrepair(playerid, params[])
{
new Float:x, Float:y, Float:z, query[128];
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
GetPlayerPos(playerid, x, y, z);
mysql_format(mysql, query, 128, "INSERT INTO `repair_system` (`pux`,`puy`,`puz`) VALUES (%f, %f, %f)", x, y, z);
mysql_tquery(mysql, query, "AddARepairPickups", "fff", x, y, z);
AddARepairPickups(x, y, z);
return 1;
}
Re: Repair System, Not Loading. -
DerickClark - 15.02.2017
bump
Re: Repair System, Not Loading. -
haikalbintang - 15.02.2017
Have you check your MySQL_Log?
Re: Repair System, Not Loading. -
DerickClark - 15.02.2017
Quote:
Originally Posted by haikalbintang
Have you check your MySQL_Log?
|
Yes no errors.
Re: Repair System, Not Loading. -
DerickClark - 18.02.2017
Bump, It's not loading or calling it
Re: Repair System, Not Loading. -
w1z4rd - 18.02.2017
Have you tried other methods? It depends on what mysql version you're using
Try something like this
Код:
public OnLoadRepairPickups()
{
new rows, fields, temp[128], Float:tempfloat;
cache_get_data(rows, fields);
if(rows)
{
for(new i; i < rows; i++)
{
cache_get_row(i, 0, temp);
ARepairPickups[i][PickupID]=strval(temp);
cache_get_row(i, 1, temp);
sscanf(temp, "f", tempfloat);
ARepairPickups[i][pux]=tempfloat;
cache_get_row(i, 2, temp);
sscanf(temp, "f", tempfloat);
ARepairPickups[i][puy]=tempfloat;
cache_get_row(i, 3, temp);
sscanf(temp, "f", tempfloat);
ARepairPickups[i][puz]=tempfloat;
}
}
return 1;
}
It's bit more code but I hope it work's. It worked for me
Re: Repair System, Not Loading. -
Vince - 18.02.2017
You're creating an infinite loop. Specifically this line:
PHP код:
i = cache_get_value_name_int(i, "PickupID", ARepairPickups[i][PickupID]);
in R40+ the return value (i.e. the value that gets stored in the variable
i) is either 1 or 0 to indicate success or failure. The variable
i will forever be smaller than the variable
count and thus the loop will run forever.
Re: Repair System, Not Loading. -
DerickClark - 18.02.2017
@Wizrd i used R41-2
@Vince this still a loop?
Код:
forward OnLoadRepairPickups();
public OnLoadRepairPickups()
{
new count, RepairID;
cache_get_row_count(count);
for(new i; i < count; i++)
{
count = cache_get_value_name_int(i, "PickupID", ARepairPickups[i][PickupID]);
cache_get_value_name_float(i, "pux", ARepairPickups[RepairID][pux]);
cache_get_value_name_float(i, "puy", ARepairPickups[RepairID][puy]);
cache_get_value_name_float(i, "puz", ARepairPickups[RepairID][puz]);
printf("Loaded %d Repair Spot", ARepairPickups[RepairID][PickupID]);
}
return 1;
}
i removed
I don't know why it's not calling
OnLoadRepairPickups
Re: Repair System, Not Loading. -
DerickClark - 19.02.2017
It's not callling or printing
Respuesta: Repair System, Not Loading. -
Eloy - 19.02.2017
PHP код:
forward OnLoadRepairPickups();
public (OnLoadRepairPickups)
{
new count, totalpickups;
/* Compruebas que existen datos en el resultado. */
if(cache_get_row_count(count))
{
/* Recorres cada fila cargando sus propios datos. */
for(new x = 0; x < count; x++)
{
i = cache_get_value_name_int(i, "PickupID", ARepairPickups[i][PickupID]);
cache_get_value_name_float(x, "pux", ARepairPickups[i][pux]);
cache_get_value_name_float(x, "puy", ARepairPickups[i][puy]);
cache_get_value_name_float(x, "puz", ARepairPickups[i][puz]);
totalpickups++;
// Create pickups here
}
printf("Loaded: %d", totalpickups);
}
return 1;
}