[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
#2

Print the queries, and see what they output, I can already assume one is not big enough.
Reply
#3

Quote:
Originally Posted by VincentDunn
View Post
Print the queries, and see what they output, I can already assume one is not big enough.
Lol, thanks mate I found the problem now.

When I did the print thing, I noticed that the Query\'s where in same name when there where two of them. Now it works when I changed it.


Just got one other problem, some how when I exit the damn garage my car disapares. But it works to enter it but I doesn\'t see the garage until I exit the car.


This is what I got under /enter
pawn Code:
for(new i = 0; i < sizeof(GarageInfo); i++)
            {
                new getcarid = GetPlayerVehicleID(playerid);
                if (PlayerToPoint(7, playerid, GarageInfo[i][gExtX], GarageInfo[i][gExtY], GarageInfo[i][gExtZ]))
                {
                    if(IsPlayerInAnyVehicle(playerid))
                    {
                        new tmpcar = GetPlayerVehicleID(playerid);
                        SetVehiclePos(tmpcar, GarageInfo[i][gIntX], GarageInfo[i][gIntY], GarageInfo[i][gIntZ]);
                        SetVehicleVirtualWorld(tmpcar, GarageInfo[i][gWorld]);
                        SetPlayerVirtualWorld(playerid, GarageInfo[i][gWorld]);
                        SetVehicleZAngle(tmpcar, 180.0000);
                        PutPlayerInVehicle(playerid, getcarid, 0);
                    }
                    else
                    {
                        SetPlayerVirtualWorld(playerid, GarageInfo[i][gWorld]);
                        SetPlayerFacingAngle(playerid, 180.0000);
                        SetPlayerPos(playerid, GarageInfo[i][gIntX], GarageInfo[i][gIntY], GarageInfo[i][gIntZ]-0.0888);
                    }
                }
                else if (PlayerToPoint(7, playerid, GarageInfo[i][gIntX], GarageInfo[i][gIntY], GarageInfo[i][gIntZ]))
                {
                    if(IsPlayerInAnyVehicle(playerid))
                    {
                        new tmpcar = GetPlayerVehicleID(playerid);
                        SetVehiclePos(tmpcar, GarageInfo[i][gExtX], GarageInfo[i][gExtY], GarageInfo[i][gExtZ]+0.0888);
                        SetVehicleVirtualWorld(tmpcar, 0);
                        SetVehicleZAngle(tmpcar, GarageInfo[i][gRot]);
                        PutPlayerInVehicle(playerid, getcarid, 0);
                    }
                    else
                    {
                        SetPlayerVirtualWorld(playerid, 0);
                        SetPlayerFacingAngle(playerid, GarageInfo[i][gRot]);
                        SetPlayerPos(playerid, GarageInfo[i][gExtX], GarageInfo[i][gExtY], GarageInfo[i][gExtZ]);
                    }
                }
            }
Reply
#4

Added SetPlayerVirtualWorld(playerid, 0); to
pawn Code:
else if (PlayerToPoint(7, playerid, GarageInfo[i][gIntX], GarageInfo[i][gIntY], GarageInfo[i][gIntZ]))
{
    if(IsPlayerInAnyVehicle(playerid))
    {
Reply
#5

Quote:
Originally Posted by Tee
View Post
Added SetPlayerVirtualWorld(playerid, 0); to
pawn Code:
else if (PlayerToPoint(7, playerid, GarageInfo[i][gIntX], GarageInfo[i][gIntY], GarageInfo[i][gIntZ]))
{
    if(IsPlayerInAnyVehicle(playerid))
    {
Works perfect, just one other major problem. When I add more then one garages and exit anyone of them they bug. You spawn at different garages and such...
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)