23.07.2012, 00:03
Dynamic doors system , failed to load
this is the Mysql code i used in my script
this is my auto saving system
this is my loading doors system
and it's added in the
to start it when the server start
[/pawn]
the problem is that it's not saving and it's not loading
please help
this is the Mysql code i used in my script
PHP код:
DROP TABLE IF EXISTS `ddoors`;
CREATE TABLE `ddoors` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Description` varchar(128) NOT NULL DEFAULT 'None',
`CustomInterior` int(11) NOT NULL DEFAULT '0',
`ExteriorVW` int(11) NOT NULL DEFAULT '0',
`ExteriorInt` int(11) NOT NULL DEFAULT '0',
`InteriorVW` int(11) NOT NULL DEFAULT '0',
`InteriorInt` int(11) NOT NULL DEFAULT '0',
`ExteriorX` float(10,5) NOT NULL DEFAULT '0.00000',
`ExteriorY` float(10,5) NOT NULL DEFAULT '0.00000',
`ExteriorZ` float(10,5) NOT NULL DEFAULT '0.00000',
`ExteriorA` float(10,5) NOT NULL DEFAULT '0.00000',
`InteriorX` float(10,5) NOT NULL DEFAULT '0.00000',
`InteriorY` float(10,5) NOT NULL DEFAULT '0.00000',
`InteriorZ` float(10,5) NOT NULL DEFAULT '0.00000',
`InteriorA` float(10,5) NOT NULL DEFAULT '0.00000',
`CustomExterior` int(11) NOT NULL DEFAULT '0',
`VIP` int(11) NOT NULL DEFAULT '0',
`Family` int(11) NOT NULL DEFAULT '0',
`Faction` int(11) NOT NULL DEFAULT '0',
`Admin` int(11) NOT NULL DEFAULT '0',
`Wanted` int(11) NOT NULL DEFAULT '0',
`VehicleAble` int(11) NOT NULL DEFAULT '0',
`Color` int(11) NOT NULL DEFAULT '0',
`PickupModel` int(11) NOT NULL DEFAULT '0',
`Pass` varchar(24) NOT NULL DEFAULT 'pass',
`Locked` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
pawn Код:
stock SaveDynamicDoor(doorid)
{
new string[1024];
format(string, sizeof(string), "UPDATE `ddoors` SET \
`Description`='%s', \
`CustomInterior`=%d, \
`ExteriorVW`=%d, \
`ExteriorInt`=%d, \
`InteriorVW`=%d, \
`InteriorInt`=%d, \
`ExteriorX`=%f, \
`ExteriorY`=%f, \
`ExteriorZ`=%f, \
`ExteriorA`=%f, \
`InteriorX`=%f, \
`InteriorY`=%f, \
`InteriorZ`=%f, \
`InteriorA`=%f,",
g_mysql_ReturnEscaped(DDoorsInfo[doorid][ddDescription], MainPipeline),
DDoorsInfo[doorid][ddCustomInterior],
DDoorsInfo[doorid][ddExteriorVW],
DDoorsInfo[doorid][ddExteriorInt],
DDoorsInfo[doorid][ddInteriorVW],
DDoorsInfo[doorid][ddInteriorInt],
DDoorsInfo[doorid][ddExteriorX],
DDoorsInfo[doorid][ddExteriorY],
DDoorsInfo[doorid][ddExteriorZ],
DDoorsInfo[doorid][ddExteriorA],
DDoorsInfo[doorid][ddInteriorX],
DDoorsInfo[doorid][ddInteriorY],
DDoorsInfo[doorid][ddInteriorZ],
DDoorsInfo[doorid][ddInteriorA]
);
format(string, sizeof(string), "%s \
`CustomExterior`=%d, \
`VIP`=%d, \
`Family`=%d, \
`Faction`=%d, \
`Admin`=%d, \
`Wanted`=%d, \
`VehicleAble`=%d, \
`Color`=%d, \
`PickupModel`=%d, \
`Pass`='%s', \
`Locked`=%d WHERE `id`=%d",
string,
DDoorsInfo[doorid][ddCustomExterior],
DDoorsInfo[doorid][ddVIP],
DDoorsInfo[doorid][ddFamily],
DDoorsInfo[doorid][ddFaction],
DDoorsInfo[doorid][ddAdmin],
DDoorsInfo[doorid][ddWanted],
DDoorsInfo[doorid][ddVehicleAble],
DDoorsInfo[doorid][ddColor],
DDoorsInfo[doorid][ddPickupModel],
g_mysql_ReturnEscaped(DDoorsInfo[doorid][dPass], MainPipeline),
DDoorsInfo[doorid][dLocked],
doorid+1
); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
}
stock SaveDynamicDoors()
{
for(new i = 0; i < MAX_DDOORS; i++)
{
SaveDynamicDoor(i);
}
return 1;
}
pawn Код:
stock LoadDynamicDoor(doorid)
{
new string[128];
printf("[LoadDynamicDoor] Loading DDoorID %d's data from database...", doorid);
format(string, sizeof(string), "SELECT * FROM `ddoors` WHERE `id`=%d", doorid+1); // Array starts at zero, MySQL starts at 1.
mysql_function_query(MainPipeline, string, true, "OnLoadDynamicDoor", "i", doorid);
}
stock LoadDynamicDoors()
{
printf("[LoadDynamicDoors] Loading data from database...");
mysql_function_query(MainPipeline, "SELECT * FROM `ddoors`", true, "OnLoadDynamicDoors", "");
}
pawn Код:
forward OnLoadDynamicDoor(index);
public OnLoadDynamicDoor(index)
{
new string[512];
new rows, fields;
cache_get_data(rows, fields, MainPipeline);
for(new field;field<fields;field++)
{
cache_get_row(index, field, string, MainPipeline);
switch(field)
{
case 0: DDoorsInfo[index][ddSQLId] = strval(string);
case 1: format(DDoorsInfo[index][ddDescription], 128, "%s", string);
case 2: DDoorsInfo[index][ddCustomInterior] = strval(string);
case 3: DDoorsInfo[index][ddExteriorVW] = strval(string);
case 4: DDoorsInfo[index][ddExteriorInt] = strval(string);
case 5: DDoorsInfo[index][ddInteriorVW] = strval(string);
case 6: DDoorsInfo[index][ddInteriorInt] = strval(string);
case 7: DDoorsInfo[index][ddExteriorX] = floatstr(string);
case 8: DDoorsInfo[index][ddExteriorY] = floatstr(string);
case 9: DDoorsInfo[index][ddExteriorZ] = floatstr(string);
case 10: DDoorsInfo[index][ddExteriorA] = floatstr(string);
case 11: DDoorsInfo[index][ddInteriorX] = floatstr(string);
case 12: DDoorsInfo[index][ddInteriorY] = floatstr(string);
case 13: DDoorsInfo[index][ddInteriorZ] = floatstr(string);
case 14: DDoorsInfo[index][ddInteriorA] = floatstr(string);
case 15: DDoorsInfo[index][ddCustomExterior] = strval(string);
case 16: DDoorsInfo[index][ddVIP] = strval(string);
case 17: DDoorsInfo[index][ddFamily] = strval(string);
case 18: DDoorsInfo[index][ddFaction] = strval(string);
case 19: DDoorsInfo[index][ddAdmin] = strval(string);
case 20: DDoorsInfo[index][ddWanted] = strval(string);
case 21: DDoorsInfo[index][ddVehicleAble] = strval(string);
case 22: DDoorsInfo[index][ddColor] = strval(string);
case 23: DDoorsInfo[index][ddPickupModel] = strval(string);
case 24: format(DDoorsInfo[index][dPass], 24, "%s", string);
case 25: DDoorsInfo[index][dLocked] = strval(string);
}
}
if(!isnull(DDoorsInfo[index][ddDescription])) CreateDynamicDoor(index);
return 1;
}
Код:
OnGameModeInit
[/pawn]
the problem is that it's not saving and it's not loading
please help