09.08.2016, 08:28
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:
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_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);
if(mysql_errno() != 0)
{
printf("[MySQL] The connection has failed.");
}
else
{
printf("[MySQL] The connection was successful.");
}
new Query[128];
mysql_format(mysql, Query, sizeof(Query), "SELECT * FROM actors");
mysql_tquery(mysql, Query, "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(rows, fields, mysql);
if(rows)
{
new createdonstr[100], createdbystr[MAX_PLAYER_NAME];
for(new i = 0; i < max_actors; i++)
{
aInfo[i][aID] = -1;
}
for(new i = 0; i < rows; i++)
{
cache_get_row(i, 8, createdonstr);
cache_get_row(i, 7, createdbystr);
aInfo[i][aID] = cache_get_row_int(i, 0);
aInfo[i][aModel] = cache_get_row_int(i, 9);
aInfo[i][aWorld] = cache_get_row_int(i, 5);
aInfo[i][aInvulnerable] = cache_get_row_int(i, 6);
aInfo[i][aX] = cache_get_row_float(i, 1);
aInfo[i][aY] = cache_get_row_float(i, 2);
aInfo[i][aZ] = cache_get_row_float(i, 3);
aInfo[i][aCreatedBy] = createdbystr;
aInfo[i][aCreatedOn] = createdonstr;
aInfo[i][aAngel] = cache_get_row_float(i, 4);
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(playerid, msg[])
{
new string[128];
format(string, sizeof(string), ""WORD_ACTOR"%s", msg);
SCM(playerid, -1, string);
return 1;
}