[Help] Mysql Dynamic System.
#1

Hey guys,


I just decided to create a Dynamic System, where you can create a garage and store your vehicles inside it.

Anyways when I create a Garage the system doesnt save the house.


If anyone have any clue what so ever please help me out.

Command
pawn Code:
if(strcmp(cmd, "/creategarage", true) == 0)
{
        if(IsPlayerConnected(playerid))
    {
            if(PlayerInfo[playerid][pAdmin] != 1338)
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command(Developers only)!");
                return 1;
            }
            new strGatePosition[256];
            strGatePosition = strtok(cmdtext, idx);
            if(!strlen(strGatePosition))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /creategarage [small(Size 2)/large(Size 4)]");
                return 1;
            }
            if(strcmp(strGatePosition,"small",true) == 0)
            {
                    new Query[128];
                    new Float:X,Float:Y,Float:Z,Float:Angle;
                format(Query, sizeof(Query), "SELECT * FROM `Garage`");
                mysql_query(Query); mysql_store_result();
                new rows = mysql_num_rows();
                rows++;
               
                GetPlayerFacingAngle(playerid, Angle);
                    GetPlayerPos(playerid,X,Y,Z);
                GarageInfo[rows][gExtX] = X;
                GarageInfo[rows][gExtY] = Y;
                GarageInfo[rows][gExtZ] = Z;
                GarageInfo[rows][gIntX] = 217.0053;
                GarageInfo[rows][gIntY] = -1882.2456;
                GarageInfo[rows][gIntZ] = 2004.6872;
                GarageInfo[rows][gRot] = Angle;
                GarageInfo[rows][gLocked] = 0;
                GarageInfo[rows][gWorld] = rows;
               
                CreateDynamicPickup(1318, 1, GarageInfo[rows][gExtX], GarageInfo[rows][gExtY], GarageInfo[rows][gExtZ]);
                format(Query, sizeof(Query), "INSERT INTO `Garage` (`gExtX`,`gExtY`,`gExtZ`,`gIntX`,`gIntY`,`gIntZ`,`gRot`,`gLocked`,`gWorld`) \
                VALUES (%f,%f,%f,%f,%f,%f,%f,%d,%d)"
,
                GarageInfo[rows][gExtX],
                GarageInfo[rows][gExtY],
                GarageInfo[rows][gExtZ],
                GarageInfo[rows][gIntX],
                GarageInfo[rows][gIntY],
                GarageInfo[rows][gIntZ],
                GarageInfo[rows][gRot],
                GarageInfo[rows][gLocked],
                GarageInfo[rows][gWorld]);
                mysql_query(Query);
                mysql_store_result();
                return 1;
            }
            else if(strcmp(strGatePosition,"large",true) == 0)
            {
                new Query[128];
                    new Float:X,Float:Y,Float:Z,Float:Angle;
                format(Query, sizeof(Query), "SELECT * FROM `Garage`");
                mysql_query(Query); mysql_store_result();
                new rows = mysql_num_rows();
                rows++;

                GetPlayerFacingAngle(playerid, Angle);
                    GetPlayerPos(playerid,X,Y,Z);
                GarageInfo[rows][gExtX] = X;
                GarageInfo[rows][gExtY] = Y;
                GarageInfo[rows][gExtZ] = Z;
                GarageInfo[rows][gIntX] = 217.0053;
                GarageInfo[rows][gIntY] = -1882.2456;
                GarageInfo[rows][gIntZ] = 2004.6872;
                GarageInfo[rows][gRot] = Angle;
                GarageInfo[rows][gLocked] = 0;
                GarageInfo[rows][gWorld] = rows;

                CreateDynamicPickup(1318, 1, GarageInfo[rows][gExtX], GarageInfo[rows][gExtY], GarageInfo[rows][gExtZ]);
                format(Query, sizeof(Query), "INSERT INTO `Garage` (`gExtX`,`gExtY`,`gExtZ`,`gIntX`,`gIntY`,`gIntZ`,`gRot`,`gLocked`,`gWorld`) \
                VALUES (%f,%f,%f,%f,%f,%f,%f,%d,%d)"
,
                GarageInfo[rows][gExtX],
                GarageInfo[rows][gExtY],
                GarageInfo[rows][gExtZ],
                GarageInfo[rows][gIntX],
                GarageInfo[rows][gIntY],
                GarageInfo[rows][gIntZ],
                GarageInfo[rows][gRot],
                GarageInfo[rows][gLocked],
                GarageInfo[rows][gWorld]);
                mysql_query(Query);
                mysql_store_result();
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "Unknown command!");
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /creategarage [small(Size 2)/large(Size 4)]");
                return 1;
            }
        }
    }
Save callback
pawn Code:
public SaveGarage()
{
    new Count;
    new Query[900];
        for(new i=0; i<MAX_GARAGES; i++)
    {
        format(Query, sizeof(Query), "UPDATE `Garage` SET \
            gExtX = %f, \
            gExtY = %f, \
            gExtZ = %f, \
            gIntX = %f, \
            gIntY = %f, \
            gIntZ = %f, \
            gRot = %f, \
            gLocked = %d, \
            gWorld = %d \
            WHERE ID = %d"
,
            GarageInfo[i][gExtX],
            GarageInfo[i][gExtY],
            GarageInfo[i][gExtZ],
            GarageInfo[i][gIntX],
            GarageInfo[i][gIntY],
            GarageInfo[i][gIntZ],
            GarageInfo[i][gRot],
            GarageInfo[i][gLocked],
            GarageInfo[i][gWorld],
            Count);
       
            Count++;
            mysql_query(Query);
    }
    printf("%d Dynamic Garages saved.", Count);
    return 1;
}


Regards,
Tony
Reply


Messages In This Thread
[Help] Mysql Dynamic System. - by tony_fitto - 04.07.2012, 19:49
Re: [Help] Mysql Dynamic System. - by ReneG - 04.07.2012, 20:13
Respuesta: Re: [Help] Mysql Dynamic System. - by tony_fitto - 04.07.2012, 20:54
Re: [Help] Mysql Dynamic System. - by Tee - 04.07.2012, 22:13
Respuesta: Re: [Help] Mysql Dynamic System. - by tony_fitto - 07.07.2012, 03:10

Forum Jump:


Users browsing this thread: 1 Guest(s)