Repair System, Not Loading.
#1

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;
}
Reply
#2

bump
Reply
#3

Have you check your MySQL_Log?
Reply
#4

Quote:
Originally Posted by haikalbintang
Посмотреть сообщение
Have you check your MySQL_Log?
Yes no errors.
Reply
#5

Bump, It's not loading or calling it
Reply
#6

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
Reply
#7

You're creating an infinite loop. Specifically this line:
PHP код:
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.
Reply
#8

@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
Код:
count =
I don't know why it's not calling
OnLoadRepairPickups
Reply
#9

It's not callling or printing
Reply
#10

PHP код:
forward OnLoadRepairPickups();
public  (
OnLoadRepairPickups)
{
    new 
counttotalpickups;
    
    
/* Compruebas que existen datos en el resultado. */
    
if(cache_get_row_count(count))
    {
        
/* Recorres cada fila cargando sus propios datos. */
        
for(new 0countx++)
        {
            
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;

Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)