autoremovehouses
#1

Hello, i am using this code to remove houses whom owners havent connected from past 7 days, but its not working but freezes / crashes the server instead, its SQLITE

PHP код:
COMMAND:autoremovehouses(playeridparams[])
{
    new 
query[200], pname[24], sweep[4], resultcounter;
    for(new 
0MAX_SCRIPT_HOUSESi++)
    {
        
mysql_format(1querysizeof(query), "SELECT `sweepCompleted` FROM `playerdata` WHERE `playerName` = '%s'"houseStuff[i][house_owner]);
        
mysql_query(1query);
        
//mysql_store_result();
        //new rows = mysql_num_rows();
        
if (cache_num_rows() > 0)
        {
            
cache_get_field_content(0"playerName"pname1129);
            
cache_get_field_content(0"sweepCompleted"sweep1129);
             new    
houseid,
            
houseQuery[200],
            
deleteQuery[200];
            new 
DBResult:qresultcount 0;
            
qresult db_query(DBHOUSEDBhouseQuery);
            
count db_num_rows(qresult);
            new 
sweepValue strval(sweep);
              if ((
getdate() - sweepValue) > 7)
            {
            
// Find the unique ID for house info
                
new dbIDvalue[48];
                
db_get_field_assoc(qresult"house_id"value48); // House UID
                
dbID strval(value);
                if(
houseStuff[i][house_id] == dbID)
                {
                    
format(deleteQuerysizeof(deleteQuery), "UPDATE `house_data` SET `house_bought` = '0', `house_owner` = 'None' WHERE `house_id` = '%i'"dbID);
                    
db_query(DBHOUSEDBdeleteQuery);
                    
resultcounter++;
                    
reloadHouses();
                    break;
                }
            }
        }
    }
    new 
str[144];
    
format(strsizeof(str), "Cleaning completed %d houses cleared"resultcounter);
    
SendClientMessage(playerid0x00FFFFFFstr);
    return 
1;

Reply
#2

  1. You cannot get a field "playerName" if you don't select that field.
  2. Why are you even using MySQL functions when it's SQLite?
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Why are you even using MySQL functions when it's SQLite?
It seems that he's using a MySQL database and an SQLite one at the same time.
Why he's doing that instead of using one of those two is beyond me.
Reply
#4

I am getting playername & his last connect time from mysql, and then trying to remove his house from houses.db SQLITE
Reply
#5

I tried to wait and the result of this cmd came after like 15mins of freezing server : 'cleaning completed 0 houses cleared'.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)