DDoors error
#1

Dynamic doors system , failed to load
this is the Mysql code i used in my script
PHP код:
DROP TABLE IF EXISTS `ddoors`;
CREATE TABLE `ddoors` (
  `
idint(11NOT NULL AUTO_INCREMENT,
  `
Descriptionvarchar(128NOT NULL DEFAULT 'None',
  `
CustomInteriorint(11NOT NULL DEFAULT '0',
  `
ExteriorVWint(11NOT NULL DEFAULT '0',
  `
ExteriorIntint(11NOT NULL DEFAULT '0',
  `
InteriorVWint(11NOT NULL DEFAULT '0',
  `
InteriorIntint(11NOT NULL DEFAULT '0',
  `
ExteriorXfloat(10,5NOT NULL DEFAULT '0.00000',
  `
ExteriorYfloat(10,5NOT NULL DEFAULT '0.00000',
  `
ExteriorZfloat(10,5NOT NULL DEFAULT '0.00000',
  `
ExteriorAfloat(10,5NOT NULL DEFAULT '0.00000',
  `
InteriorXfloat(10,5NOT NULL DEFAULT '0.00000',
  `
InteriorYfloat(10,5NOT NULL DEFAULT '0.00000',
  `
InteriorZfloat(10,5NOT NULL DEFAULT '0.00000',
  `
InteriorAfloat(10,5NOT NULL DEFAULT '0.00000',
  `
CustomExteriorint(11NOT NULL DEFAULT '0',
  `
VIPint(11NOT NULL DEFAULT '0',
  `
Familyint(11NOT NULL DEFAULT '0',
  `
Factionint(11NOT NULL DEFAULT '0',
  `
Adminint(11NOT NULL DEFAULT '0',
  `
Wantedint(11NOT NULL DEFAULT '0',
  `
VehicleAbleint(11NOT NULL DEFAULT '0',
  `
Colorint(11NOT NULL DEFAULT '0',
  `
PickupModelint(11NOT NULL DEFAULT '0',
  `
Passvarchar(24NOT NULL DEFAULT 'pass',
  `
Lockedint(11NOT NULL DEFAULT '0',
  
PRIMARY KEY (`id`)
ENGINE=InnoDB DEFAULT CHARSET=latin1
this is my auto saving system
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;
}
this is my loading doors system
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;
}
and it's added in the
Код:
OnGameModeInit
to start it when the server start
[/pawn]
the problem is that it's not saving and it's not loading
please help
Reply
#2

OFF TOPIC: why use a ngrp script?

ON TOPIC: its a problem with your database, do a sql dump and send me it and il fix it
Reply
#3

OFF TOPIC : i'm not using it in public and i will not ,and i will not share it with other, i'm learning scripting , it's the best way when you learn from masters.
ON TOPIC : How to do this SQL DUMP ??
Reply
#4

oh sorry basically open up your mysql database with a program like phpmyadmin or navicat and right click and select dump sql and save to to somewhere, and i must agree it is a good way of learning to script
Reply
#5

You expect to use an advanced script and be able to have a cake-walk through setting it up?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)