all rows
#1

I don't see why this isn't loading all the rows I've got in my table? everything after the 6th row isn't being loaded...

PHP Code:
forward LoadServerVehicles();
public 
LoadServerVehicles()
{
    if(
cache_get_row_count() < 1) return 1;
    new 
rows cache_get_row_count(), row 0;
    while(
row rows)
    {
        new 
vid cache_get_field_content_int(row"ID");
        
ServerVeh[vid][svModel] = cache_get_field_content_int(row"Model");
        
ServerVeh[vid][svX] = cache_get_field_content_float(row"X");
        
ServerVeh[vid][svY] = cache_get_field_content_float(row"Y");
        
ServerVeh[vid][svZ] = cache_get_field_content_float(row"Z");
        
ServerVeh[vid][svA] = cache_get_field_content_float(row"A");
        
ServerVeh[vid][svC1] = cache_get_field_content_int(row"C1");
        
ServerVeh[vid][svC2] = cache_get_field_content_int(row"C2");
        
CreateVehicle(ServerVeh[vid][svModel], ServerVeh[vid][svX], ServerVeh[vid][svY], ServerVeh[vid][svZ], ServerVeh[vid][svA], ServerVeh[vid][svC1], ServerVeh[vid][svC2], -1);
        
row++;
    }
    return 
1;

Reply
#2

Try to debug it, print the row count, look what it is and check your query.
Reply
#3

Unfortunately print(); isn't going to work for me because I can't view samp.server because of my host.

Edit: Mysql query in OnGameModeInIt
PHP Code:
mysql_tquery(mysql"SELECT * FROM `ServerVehs`""LoadServerVehicles"); 
Reply
#4

Can't even access the logs? You could also use SendclientMessageToAll.

Also, you said everything after the 6th row isn't being loaded, how many rows are there?
Reply
#5

Currently 19, but even if I had 7 it wouldn't load the seventh row.
SCMToall isn't sending anything either.
Reply
#6

Why is SCMToAll not working? I meant that you should just print the row count, like this(I edited the code a little, i like itbetter that way):

PHP Code:
forward LoadServerVehicles(); 
public 
LoadServerVehicles() 

    new 
rowCount cache_get_row_count();
    new 
debugMessage[20];
    
format(debugMessagesizeof(debugMessage), "Row count is: %d"rowCount);
    
SendClientMessageToAll(-1debugMessage);
    for(new 
row 0row rowCountrow++)
    { 
        new 
vid cache_get_field_content_int(row"ID"); 
        
ServerVeh[vid][svModel] = cache_get_field_content_int(row"Model"); 
        
ServerVeh[vid][svX] = cache_get_field_content_float(row"X"); 
        
ServerVeh[vid][svY] = cache_get_field_content_float(row"Y"); 
        
ServerVeh[vid][svZ] = cache_get_field_content_float(row"Z"); 
        
ServerVeh[vid][svA] = cache_get_field_content_float(row"A"); 
        
ServerVeh[vid][svC1] = cache_get_field_content_int(row"C1"); 
        
ServerVeh[vid][svC2] = cache_get_field_content_int(row"C2"); 
        
CreateVehicle(ServerVeh[vid][svModel], ServerVeh[vid][svX], ServerVeh[vid][svY], ServerVeh[vid][svZ], ServerVeh[vid][svA], ServerVeh[vid][svC1], ServerVeh[vid][svC2], -1); 
    } 
    return 
1

have u considered updating your MySQL, seems like you are using an older version. You'd have to rework a lot tho(Depending on how much old MySQL code u got).
Reply
#7

You're retrieving ID from your tables and using it as an index of your array. If the retrieved ID is not within the array bounds, it could be why your operation breaks there. Use this code and debug to confirm:
pawn Code:
//Make sure you're connecting while this runs.
forward LoadServerVehicles();
public LoadServerVehicles()
{
    //if(cache_get_row_count() < 1) return 1;
    //new rows = cache_get_row_count(), row = 0; //Why use the function twice?
    new
        rows = cache_get_row_count(),
        row = 0,
        debug_String[64]
    ;
    if(rows < 1)
        return 1;

    while(row < rows)
    {
        new vid = cache_get_field_content_int(row, "ID");
        format(debug_String, sizeof(debug_String), "row : %d | vid : %d | rows : %d", row, vid, rows);
        SendClientMessageToAll(-1, debug_String);
        print(debug_String); //You can get it from server_log.txt if you're not connected.
        ServerVeh[vid][svModel] = cache_get_field_content_int(row, "Model");
        ServerVeh[vid][svX] = cache_get_field_content_float(row, "X");
        ServerVeh[vid][svY] = cache_get_field_content_float(row, "Y");
        ServerVeh[vid][svZ] = cache_get_field_content_float(row, "Z");
        ServerVeh[vid][svA] = cache_get_field_content_float(row, "A");
        ServerVeh[vid][svC1] = cache_get_field_content_int(row, "C1");
        ServerVeh[vid][svC2] = cache_get_field_content_int(row, "C2");
        CreateVehicle(ServerVeh[vid][svModel], ServerVeh[vid][svX], ServerVeh[vid][svY], ServerVeh[vid][svZ], ServerVeh[vid][svA], ServerVeh[vid][svC1], ServerVeh[vid][svC2], -1);
        row++;
    }
    return 1;
}
If possible, show us your table structure and data.
Reply
#8

Quote:
Originally Posted by Lordzy
View Post
You're retrieving ID from your tables and using it as an index of your array. If the retrieved ID is not within the array bounds, it could be why your operation breaks there. Use this code and debug to confirm:
pawn Code:
//Make sure you're connecting while this runs.
forward LoadServerVehicles();
public LoadServerVehicles()
{
    //if(cache_get_row_count() < 1) return 1;
    //new rows = cache_get_row_count(), row = 0; //Why use the function twice?
    new
        rows = cache_get_row_count(),
        row = 0,
        debug_String[64]
    ;
    if(rows < 1)
        return 1;

    while(row < rows)
    {
        new vid = cache_get_field_content_int(row, "ID");
        format(debug_String, sizeof(debug_String), "row : %d | vid : %d | rows : %d", row, vid, rows);
        SendClientMessageToAll(-1, debug_String);
        print(debug_String); //You can get it from server_log.txt if you're not connected.
        ServerVeh[vid][svModel] = cache_get_field_content_int(row, "Model");
        ServerVeh[vid][svX] = cache_get_field_content_float(row, "X");
        ServerVeh[vid][svY] = cache_get_field_content_float(row, "Y");
        ServerVeh[vid][svZ] = cache_get_field_content_float(row, "Z");
        ServerVeh[vid][svA] = cache_get_field_content_float(row, "A");
        ServerVeh[vid][svC1] = cache_get_field_content_int(row, "C1");
        ServerVeh[vid][svC2] = cache_get_field_content_int(row, "C2");
        CreateVehicle(ServerVeh[vid][svModel], ServerVeh[vid][svX], ServerVeh[vid][svY], ServerVeh[vid][svZ], ServerVeh[vid][svA], ServerVeh[vid][svC1], ServerVeh[vid][svC2], -1);
        row++;
    }
    return 1;
}
If possible, show us your table structure and data.
He is using the cache index and not the actual database row, which is totally fine. Correct me if i am wrong, but explain please
Reply
#9

Debug, it stops at the 6th row, with your code, Lordzy.
Reply
#10

Show array ServerVeh
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)