Loading actors
#1

Hello guys, I've made a table on my MySQL database. Now, I want to load actors from the database. When the FILTERSCRIPT starts, OnFilterScriptInit, it calls the function "LoadActors", but it's like the function wasn't called, it doesn't printf anything. It is supposed to printf: "No actors to load", or "Loaded %d actors".

Can someone tell wats the problem?

[NOTE] I'm using Frag host.

This is my filterscript file:
PHP код:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#include <a_mysql>
#define    MYSQL_HOST        "localhost"
#define    MYSQL_USER        "f3413_ahcnr"
#define    MYSQL_DATABASE    "f3413_ahcnr"
#define    MYSQL_PASSWORD    "x"
#define SCM         SendClientMessage
#define SCMToAll    SendClientMessageToAll
////////////// COLOR DEFINES //////////////
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED   0xFF0000FF
#define COLOR_GREEN 0x00FF00FF
#define COLOR_ACTOR 0xFA5B25FF
//////////////// COL DEFINES ///////////////
#define COL_WHITE     "{FFFFFF}"
#define COL_GRAY    "{C0C0C0}"
#define COL_RED     "{FF0000}"
#define COL_GREEN   "{00FF00}"
#define COL_ACTOR   "{FA5B25}"
/////////////////// WORDS ///////////////////
#define WORD_ACTOR  ""COL_ACTOR"[ACTOR] "COL_WHITE""
//////////////////////////////////////////
#define max_actors 100
//////////////////////////////////////////
new mysql;
new 
LoadedActors 0;
public 
OnFilterScriptInit()
{
    print(
"\n------------------------------------------------");
    print(
"     A21_Actors System by Ahmed21");
    print(
"-------------------------------------------------\n");
    
mysql_log(LOG_ALL);
    
mysql mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DATABASEMYSQL_PASSWORD);
    if(
mysql_errno() != 0)
    {
        
printf("[MySQL] The connection has failed.");
    }
    else
    {
        
printf("[MySQL] The connection was successful.");
    }
    new 
Query[128];
    
mysql_format(mysqlQuerysizeof(Query), "SELECT * FROM actors");
    
mysql_tquery(mysqlQuery"LoadActors""");
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;
}
/////////////   ENUMS    /////////////////
enum actors
{
    
aID,
    
aModel,
    
aActorID,
    
Float:aX,
    
Float:aY,
    
Float:aZ,
    
Float:aAngel,
    
aWorld,
    
aCreatedBy[MAX_PLAYER_NAME],
    
aCreatedOn[100],
    
aInvulnerable
}
new 
aInfo[max_actors][actors];
////////////    FUNCIONS     ////////////////////
forward LoadActors();
public 
LoadActors()
{
    new
        
rows,
        
fields;
    
cache_get_data(rowsfieldsmysql);
    if(
rows)
    {
        new 
createdonstr[100], createdbystr[MAX_PLAYER_NAME];
        for(new 
0max_actorsi++)
        {
            
aInfo[i][aID] = -1;
        }
        for(new 
0rowsi++)
        {
            
cache_get_row(i8createdonstr);
            
cache_get_row(i7createdbystr);
            
aInfo[i][aID] = cache_get_row_int(i0);
            
aInfo[i][aModel] = cache_get_row_int(i9);
            
aInfo[i][aWorld] = cache_get_row_int(i5);
            
aInfo[i][aInvulnerable] = cache_get_row_int(i6);
            
aInfo[i][aX] = cache_get_row_float(i1);
            
aInfo[i][aY] = cache_get_row_float(i2);
            
aInfo[i][aZ] = cache_get_row_float(i3);
            
aInfo[i][aCreatedBy] = createdbystr;
            
aInfo[i][aCreatedOn] = createdonstr;
            
aInfo[i][aAngel] = cache_get_row_float(i4);
            
            
aInfo[i][aActorID] = CreateActor(aInfo[i][aModel], aInfo[i][aX], aInfo[i][aY], aInfo[i][aZ], aInfo[i][aAngel]);
            
SetActorInvulnerable(aInfo[i][aActorID], aInfo[i][aInvulnerable]);
            
SetActorVirtualWorld(aInfo[i][aActorID], aInfo[i][aWorld]);
            
LoadedActors++;
        }
        
printf("Loaded %d actors"LoadedActors);
    }
    else
    {
        
printf("There are no actors to load.");
    }
    return 
1;
}
stock SendActorMSG(playeridmsg[])
{
    new 
string[128];
    
format(stringsizeof(string), ""WORD_ACTOR"%s"msg);
    
SCM(playerid, -1string);
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)