They won't create -
Micko123 - 12.11.2016
this is under OnGameModeInit
PHP код:
mysql_tquery(g_SQL, "SELECT * FROM `drugs`", "DrugsLoad");
This is func
PHP код:
forward DrugsLoad();
public DrugsLoad()
{
for(new i = 0; i < MAX_DRUGS_PLACE; i++)
{
DrugsInfo[i][ID] = cache_get_value_int(i, "ID", DrugsInfo[i][ID]);
DrugsInfo[i][dPosX] = cache_get_value_float(i, "X", DrugsInfo[i][dPosX]);
DrugsInfo[i][dPosY] = cache_get_value_float(i, "Y", DrugsInfo[i][dPosY]);
DrugsInfo[i][dPosZ] = cache_get_value_float(i, "Z", DrugsInfo[i][dPosZ]);
Iter_Add(i_Drugs, i);
DrugsPickup[i] = CreateDynamicPickup(1279, 1, DrugsInfo[i][dPosX], DrugsInfo[i][dPosY], DrugsInfo[i][dPosZ]);
DrugsLabel[i] = CreateDynamic3DTextLabel(""SERVERBLUE"[ DRUGS ]\n"WHITE"To buy drugs type /buydrugs", 0x1D9F00AA, DrugsInfo[i][dPosX], DrugsInfo[i][dPosY], DrugsInfo[i][dPosZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
}
return 1;
}
It saves nice but when I join they are not created.. What could be the problem??
Re: They won't create -
oMa37 - 12.11.2016
You have to check if the rows exists and loop through the
ROWS not through the max value you got.
Код:
cache_get_value_int(rows, ...);
PHP код:
public DrugsLoad()
{
new rows = cache_num_rows();
if(rows)
{
for(new i; i < rows; i++)
{
cache_get_value_int(i, "ID", DrugsInfo[i][ID]);
cache_get_value_float(i, "X", DrugsInfo[i][dPosX]);
cache_get_value_float(i, "Y", DrugsInfo[i][dPosY]);
cache_get_value_float(i, "Z", DrugsInfo[i][dPosZ]);
Iter_Add(i_Drugs, i);
DrugsPickup[i] = CreateDynamicPickup(1279, 1, DrugsInfo[i][dPosX], DrugsInfo[i][dPosY], DrugsInfo[i][dPosZ]);
DrugsLabel[i] = CreateDynamic3DTextLabel(""SERVERBLUE"[ DRUGS ]\n"WHITE"To buy drugs type /buydrugs", 0x1D9F00AA, DrugsInfo[i][dPosX], DrugsInfo[i][dPosY], DrugsInfo[i][dPosZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
}
}
return 1;
}
Re: They won't create -
Micko123 - 13.11.2016
I did this
PHP код:
forward DrugsLoad();
public DrugsLoad()
{
new rows = cache_num_rows();
if(rows)
{
for(new i; i < rows; i++)
{
cache_get_value_int(i, "ID", DrugsInfo[i][ID]);
cache_get_value_float(i, "X", DrugsInfo[i][dPosX]);
cache_get_value_float(i, "Y", DrugsInfo[i][dPosY]);
cache_get_value_float(i, "Z", DrugsInfo[i][dPosZ]);
Iter_Add(i_Drugs, i);
DrugsPickup[i] = CreateDynamicPickup(1279, 1, DrugsInfo[i][dPosX], DrugsInfo[i][dPosY], DrugsInfo[i][dPosZ]);
DrugsLabel[i] = CreateDynamic3DTextLabel(""SERVERBLUE"[ DRUGS ]\n"WHITE"To buy drugs type /buydrugs", 0x1D9F00AA, DrugsInfo[i][dPosX], DrugsInfo[i][dPosY], DrugsInfo[i][dPosZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
}
}
return 1;
}
And added this OnGameModeInit
PHP код:
mysql_tquery(g_SQL, "SELECT * FROM `drugs`", "DrugsLoad");
But still nothing.. They are written in table with unique ID and pos but just won't create when I rejoin server..
Re: They won't create -
Micko123 - 13.11.2016
Okay so I added this
Код:
forward DrugsLoad();
public DrugsLoad()
{
new rows = cache_num_rows();
if(rows)
{
for(new i; i < rows; i++)
{
cache_get_value_int(i, "ID", DrugsInfo[i][ID]);
cache_get_value_float(i, "X", DrugsInfo[i][dPosX]);
cache_get_value_float(i, "Y", DrugsInfo[i][dPosY]);
cache_get_value_float(i, "Z", DrugsInfo[i][dPosZ]);
Iter_Add(i_Drugs, i);
DrugsPickup[i] = CreateDynamicPickup(1279, 1, DrugsInfo[i][dPosX], DrugsInfo[i][dPosY], DrugsInfo[i][dPosZ]);
DrugsLabel[i] = CreateDynamic3DTextLabel(""SERVERBLUE"[ DRUGS ]\n"WHITE"To buy drugs type /buydrugs", 0x1D9F00AA, DrugsInfo[i][dPosX], DrugsInfo[i][dPosY], DrugsInfo[i][dPosZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
printf("Function 'DrugsLoad' Loaded");
}
}
return 1;
}
But when I start server.exe It is not shown. Here is the log
Код:
SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team
[09:54:15] filterscripts = "" (string)
[09:54:15]
[09:54:15] Server Plugins
[09:54:15] --------------
[09:54:15] Loading plugin: sscanf
[09:54:15]
[09:54:15] ===============================
[09:54:15] sscanf plugin loaded.
[09:54:15] Version: 2.8.2
[09:54:15] © 2012 Alex "******" Cole
[09:54:15] ===============================
[09:54:15] Loaded.
[09:54:15] Loading plugin: streamer
[09:54:15]
*** Streamer Plugin v2.8.2 by Incognito loaded ***
[09:54:15] Loaded.
[09:54:15] Loading plugin: pawncmd
[09:54:15] Pawn.CMD plugin v3.1.2 by urShadow loaded
[09:54:15] Loaded.
[09:54:15] Loading plugin: mysql
[09:54:15] >> plugin.mysql: R41 successfully loaded.
[09:54:15] Loaded.
[09:54:15] Loaded 4 plugins.
[09:54:15]
[09:54:15] Filterscripts
[09:54:15] ---------------
[09:54:15] Loaded 0 filterscripts.
[09:54:15] MySQL connection is successful to `server`.
[09:54:15]
--------------------------------
[09:54:15] Database: 'server'
[09:54:15] Password: ''
[09:54:15] Host: 'localhost'
[09:54:15] User: 'root'
[09:54:15] ----------------------------------
[09:54:15] Number of vehicle models: 5
So it looks like that function is not called at all by mysql_tquery..
Re: They won't create - justice96 - 13.11.2016
You didn't even use y_iterate include
Re: They won't create -
Micko123 - 13.11.2016
Any other way to do this or y_iterate is only?
Re: They won't create -
oMa37 - 13.11.2016
foreach is faster than y_iterate.
Re: They won't create -
Micko123 - 13.11.2016
But how to fix this guys

? Any ideas?
Re: They won't create -
oMa37 - 13.11.2016
Try this;
PHP код:
public DrugsLoad()
{
new rows = cache_num_rows();
if(rows)
{
for(new i; i < rows; i++)
{
new id = Iter_Free(i_Drugs);
cache_get_value_int(i, "ID", DrugsInfo[id][ID]);
cache_get_value_float(i, "X", DrugsInfo[id][dPosX]);
cache_get_value_float(i, "Y", DrugsInfo[id][dPosY]);
cache_get_value_float(i, "Z", DrugsInfo[id][dPosZ]);
DrugsPickup[id] = CreateDynamicPickup(1279, 1, DrugsInfo[id][dPosX], DrugsInfo[id][dPosY], DrugsInfo[id][dPosZ]);
DrugsLabel[id] = CreateDynamic3DTextLabel(""SERVERBLUE"[ DRUGS ]\n"WHITE"To buy drugs type /buydrugs", 0x1D9F00AA, DrugsInfo[id][dPosX], DrugsInfo[id][dPosY], DrugsInfo[id][dPosZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
Iter_Add(i_Drugs, id);
}
printf("Drugs Loaded - %i", rows);
}
return 1;
}
Re: They won't create -
Micko123 - 13.11.2016
Here is log
Код:
SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team
[10:20:43] filterscripts = "" (string)
[10:20:43]
[10:20:43] Server Plugins
[10:20:43] --------------
[10:20:43] Loading plugin: sscanf
[10:20:43]
[10:20:43] ===============================
[10:20:43] sscanf plugin loaded.
[10:20:43] Version: 2.8.2
[10:20:43] © 2012 Alex "******" Cole
[10:20:43] ===============================
[10:20:43] Loaded.
[10:20:43] Loading plugin: streamer
[10:20:43]
*** Streamer Plugin v2.8.2 by Incognito loaded ***
[10:20:43] Loaded.
[10:20:43] Loading plugin: pawncmd
[10:20:43] Pawn.CMD plugin v3.1.2 by urShadow loaded
[10:20:43] Loaded.
[10:20:43] Loading plugin: mysql
[10:20:43] >> plugin.mysql: R41 successfully loaded.
[10:20:43] Loaded.
[10:20:43] Loaded 4 plugins.
[10:20:43]
[10:20:43] Filterscripts
[10:20:43] ---------------
[10:20:43] Loaded 0 filterscripts.
[10:20:43] MySQL connection is successful to `server`.
[10:20:43]
--------------------------------
[10:20:43] Database: 'server'
[10:20:43] Password: ''
[10:20:43] Host: 'localhost'
[10:20:43] User: 'root'
[10:20:43] ----------------------------------
[10:20:43] Number of vehicle models: 5
Function is not even called. I don't get it...