MySQL Overlapping ID's
#1

Not too sure how to go about this, but I use a couple different databases with door entrance ID's that are overlapping,
my current /enter command is working, BUT my exit CMD is not, I am wondering if there is a much simpler way than this, less stress for the server....

pawn Code:
CMD:enter(playerid, params[])
{
    new rows;
    mysql_query(g_SQL, "SELECT * FROM `dynamicdoors` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_DYNAMICDOORS; r++)
        {
            cache_get_value_name_int(r, "locked", DynamicDoors[r][Locked]);
            cache_get_value_name_float(r, "pos_x", DynamicDoors[r][PosX]);
            cache_get_value_name_float(r, "pos_y", DynamicDoors[r][PosY]);
            cache_get_value_name_float(r, "pos_z", DynamicDoors[r][PosZ]);

            cache_get_value_name_float(r, "int_x", DynamicDoors[r][IntX]);
            cache_get_value_name_float(r, "int_y", DynamicDoors[r][IntY]);
            cache_get_value_name_float(r, "int_z", DynamicDoors[r][IntZ]);
            cache_get_value_name_float(r, "int_a", DynamicDoors[r][IntA]);

            cache_get_value_name_int(r, "insideinteriorid", DynamicDoors[r][InsideInteriorID]);
            cache_get_value_name_int(r, "insidevwid", DynamicDoors[r][InsideVWID]);
            cache_get_value_name_int(r, "outsideinteriorid", DynamicDoors[r][OutsideInteriorID]);
            cache_get_value_name_int(r, "outsidevwid", DynamicDoors[r][OutsideVWID]);
            if(IsPlayerInRangeOfPoint(playerid, 1.0, DynamicDoors[r][PosX],DynamicDoors[r][PosY],DynamicDoors[r][PosZ]))
            {
                if(DynamicDoors[r][Locked])
                {
                    GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
                    return 1;
                }
                else
                {
                    SetPlayerPos(playerid, DynamicDoors[r][IntX], DynamicDoors[r][IntY], DynamicDoors[r][IntZ]);
                    SetPlayerFacingAngle(playerid, DynamicDoors[r][IntA]);
                    SetPlayerInterior(playerid, DynamicDoors[r][InsideInteriorID]);
                    SetPlayerVirtualWorld(playerid, DynamicDoors[r][InsideVWID]);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    mysql_query(g_SQL, "SELECT * FROM `dynamichouses` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_DYNAMICHOUSES; r++)
        {
            cache_get_value_name_int(r, "locked", DynamicHouses[r][Locked]);
            cache_get_value_name_float(r, "pos_x", DynamicHouses[r][PosX]);
            cache_get_value_name_float(r, "pos_y", DynamicHouses[r][PosY]);
            cache_get_value_name_float(r, "pos_z", DynamicHouses[r][PosZ]);

            cache_get_value_name_float(r, "int_x", DynamicHouses[r][IntX]);
            cache_get_value_name_float(r, "int_y", DynamicHouses[r][IntY]);
            cache_get_value_name_float(r, "int_z", DynamicHouses[r][IntZ]);
            cache_get_value_name_float(r, "int_a", DynamicHouses[r][IntA]);

            cache_get_value_name_int(r, "insideinteriorid", DynamicHouses[r][InsideInteriorID]);
            cache_get_value_name_int(r, "insidevwid", DynamicHouses[r][InsideVWID]);
            cache_get_value_name_int(r, "outsideinteriorid", DynamicHouses[r][OutsideInteriorID]);
            cache_get_value_name_int(r, "outsidevwid", DynamicHouses[r][OutsideVWID]);
            if(IsPlayerInRangeOfPoint(playerid, 1.0, DynamicHouses[r][PosX], DynamicHouses[r][PosY], DynamicHouses[r][PosZ]))
            {
                if(DynamicHouses[r][Locked])
                {
                    GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
                    return 1;
                }
                else
                {
                    SetPlayerPos(playerid, DynamicHouses[r][IntX], DynamicHouses[r][IntY], DynamicHouses[r][IntZ]);
                    SetPlayerFacingAngle(playerid, DynamicHouses[r][IntA]);
                    SetPlayerInterior(playerid, DynamicHouses[r][InsideInteriorID]);
                    SetPlayerVirtualWorld(playerid, DynamicHouses[r][InsideVWID]);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    mysql_query(g_SQL, "SELECT * FROM `families` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_FAMILIES; r++)
        {
            cache_get_value_name_int(r, "familyexists", Families[r][Exists]);
            cache_get_value_name_int(r, "id", Families[r][ID]);
            cache_get_value_name(r, "familyname", Families[r][FamilyName],72);

            cache_get_value_name_float(r, "hqx", Families[r][FamHQX]);
            cache_get_value_name_float(r, "hqy", Families[r][FamHQY]);
            cache_get_value_name_float(r, "hqz", Families[r][FamHQZ]);
            cache_get_value_name_float(r, "hqintx", Families[r][FamHQIntX]);
            cache_get_value_name_float(r, "hqinty", Families[r][FamHQIntY]);
            cache_get_value_name_float(r, "hqintz", Families[r][FamHQIntZ]);
            cache_get_value_name_float(r, "hqinta", Families[r][FamHQIntA]);
            cache_get_value_name_int(r, "hqvw", Families[r][FamHQVW]);
            cache_get_value_name_int(r, "hqintid", Families[r][FamHQIntID]);
            cache_get_value_name_int(r, "hqintvw", Families[r][FamHQIntVW]);
            cache_get_value_name_int(r, "hqintintid", Families[r][FamHQIntIntID]);
            if(IsPlayerInRangeOfPoint(playerid, 1.0, Families[r][FamHQX], Families[r][FamHQY], Families[r][FamHQZ]))
            {
                if(Player[playerid][FamilyID] != Families[r][ID])
                {
                    GameTextForPlayer(playerid, "~r~Restricted Access", 5000, 1);
                    return 1;
                }
                else if(Families[r][FamHQIntIntID] == 999)
                {
                    SendClientMessage(playerid, -1, "SERVER: This HQ is not setup correctly.");
                    return 1;
                }
                else
                {
                    SetPlayerPos(playerid, Families[r][FamHQIntX], Families[r][FamHQIntY], Families[r][FamHQIntZ]);
                    SetPlayerFacingAngle(playerid, Families[r][FamHQIntA]);
                    SetPlayerInterior(playerid, Families[r][FamHQIntIntID]);
                    SetPlayerVirtualWorld(playerid, Families[r][FamHQIntVW]);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    mysql_query(g_SQL, "SELECT * FROM `factions` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_FACTIONS; r++)//Finish this as Factions not Families
        {
            cache_get_value_name_int(r, "factionexists", Factions[r][Exists]);
            cache_get_value_name_int(r, "id", Factions[r][ID]);
            cache_get_value_name(r, "factionname", Factions[r][FactionName],72);

            cache_get_value_name_float(r, "hqx", Factions[r][FacHQX]);
            cache_get_value_name_float(r, "hqy", Factions[r][FacHQY]);
            cache_get_value_name_float(r, "hqz", Factions[r][FacHQZ]);
            cache_get_value_name_float(r, "hqintx", Factions[r][FacHQIntX]);
            cache_get_value_name_float(r, "hqinty", Factions[r][FacHQIntY]);
            cache_get_value_name_float(r, "hqintz", Factions[r][FacHQIntZ]);
            cache_get_value_name_float(r, "hqinta", Factions[r][FacHQIntA]);
            cache_get_value_name_int(r, "hqvw", Factions[r][FacHQVW]);
            cache_get_value_name_int(r, "hqintid", Factions[r][FacHQIntID]);
            cache_get_value_name_int(r, "hqintvw", Factions[r][FacHQIntVW]);
            cache_get_value_name_int(r, "hqintintid", Factions[r][FacHQIntIntID]);
            if(IsPlayerInRangeOfPoint(playerid, 1.0, Factions[r][FacHQX], Factions[r][FacHQY], Factions[r][FacHQZ]))
            {
                if(Player[playerid][FactionID] != Factions[r][ID])
                {
                    GameTextForPlayer(playerid, "~r~Restricted Access", 5000, 1);
                    return 1;
                }
                else if(Factions[r][FacHQIntIntID] == 999)
                {
                    SendClientMessage(playerid, -1, "SERVER: This HQ is not setup correctly.");
                    return 1;
                }
                else
                {
                    SetPlayerPos(playerid, Factions[r][FacHQIntX], Factions[r][FacHQIntY], Factions[r][FacHQIntZ]);
                    SetPlayerFacingAngle(playerid, Factions[r][FacHQIntA]);
                    SetPlayerInterior(playerid, Factions[r][FacHQIntIntID]);
                    SetPlayerVirtualWorld(playerid, Factions[r][FacHQIntVW]);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    #if DEBUG_COMMANDS == true
        print("DEBUG: CMD:enter Called");
    #endif
    return 1;
}

CMD:exit(playerid, params[])
{
    new rows;
    mysql_query(g_SQL, "SELECT * FROM `dynamicdoors` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_DYNAMICDOORS; r++)
        {
            cache_get_value_name_int(r, "locked", DynamicDoors[r][Locked]);
            cache_get_value_name_float(r, "pos_x", DynamicDoors[r][PosX]);
            cache_get_value_name_float(r, "pos_y", DynamicDoors[r][PosY]);
            cache_get_value_name_float(r, "pos_z", DynamicDoors[r][PosZ]);

            cache_get_value_name_float(r, "int_x", DynamicDoors[r][IntX]);
            cache_get_value_name_float(r, "int_y", DynamicDoors[r][IntY]);
            cache_get_value_name_float(r, "int_z", DynamicDoors[r][IntZ]);
            cache_get_value_name_float(r, "int_a", DynamicDoors[r][IntA]);

            cache_get_value_name_int(r, "insideinteriorid", DynamicDoors[r][InsideInteriorID]);
            cache_get_value_name_int(r, "insidevwid", DynamicDoors[r][InsideVWID]);
            cache_get_value_name_int(r, "outsideinteriorid", DynamicDoors[r][OutsideInteriorID]);
            cache_get_value_name_int(r, "outsidevwid", DynamicDoors[r][OutsideVWID]);
            if(IsPlayerInRangeOfPoint(playerid, 1.0, DynamicDoors[r][PosX],DynamicDoors[r][PosY],DynamicDoors[r][PosZ]))
            {
                if(DynamicDoors[r][Locked])
                {
                    GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
                    return 1;
                }
                else
                {
                    SetPlayerPos(playerid, DynamicDoors[r][PosX], DynamicDoors[r][PosY], DynamicDoors[r][PosZ]);
                    SetPlayerFacingAngle(playerid, DynamicDoors[r][PosA]);
                    SetPlayerInterior(playerid, DynamicDoors[r][OutsideInteriorID]);
                    SetPlayerVirtualWorld(playerid, DynamicDoors[r][OutsideVWID]);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    mysql_query(g_SQL, "SELECT * FROM `dynamichouses` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_DYNAMICHOUSES; r++)
        {
            cache_get_value_name_int(r, "locked", DynamicHouses[r][Locked]);
            cache_get_value_name_float(r, "pos_x", DynamicHouses[r][PosX]);
            cache_get_value_name_float(r, "pos_y", DynamicHouses[r][PosY]);
            cache_get_value_name_float(r, "pos_z", DynamicHouses[r][PosZ]);

            cache_get_value_name_float(r, "int_x", DynamicHouses[r][IntX]);
            cache_get_value_name_float(r, "int_y", DynamicHouses[r][IntY]);
            cache_get_value_name_float(r, "int_z", DynamicHouses[r][IntZ]);
            cache_get_value_name_float(r, "int_a", DynamicHouses[r][IntA]);

            cache_get_value_name_int(r, "insideinteriorid", DynamicHouses[r][InsideInteriorID]);
            cache_get_value_name_int(r, "insidevwid", DynamicHouses[r][InsideVWID]);
            cache_get_value_name_int(r, "outsideinteriorid", DynamicHouses[r][OutsideInteriorID]);
            cache_get_value_name_int(r, "outsidevwid", DynamicHouses[r][OutsideVWID]);
            if(IsPlayerInRangeOfPoint(playerid, 1.0, DynamicHouses[r][PosX], DynamicHouses[r][PosY], DynamicHouses[r][PosZ]))
            {
                if(DynamicHouses[r][Locked])
                {
                    GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
                    return 1;
                }
                else
                {
                    SetPlayerPos(playerid, DynamicHouses[r][PosX], DynamicHouses[r][PosY], DynamicHouses[r][PosZ]);
                    SetPlayerFacingAngle(playerid, DynamicHouses[r][PosA]);
                    SetPlayerInterior(playerid, DynamicHouses[r][OutsideInteriorID]);
                    SetPlayerVirtualWorld(playerid, DynamicHouses[r][OutsideVWID]);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    mysql_query(g_SQL, "SELECT * FROM `families` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_FAMILIES; r++)
        {
            cache_get_value_name_int(r, "familyexists", Families[r][Exists]);
            cache_get_value_name_int(r, "id", Families[r][ID]);
            cache_get_value_name(r, "familyname", Families[r][FamilyName],72);

            cache_get_value_name_float(r, "hqx", Families[r][FamHQX]);
            cache_get_value_name_float(r, "hqy", Families[r][FamHQY]);
            cache_get_value_name_float(r, "hqz", Families[r][FamHQZ]);
            cache_get_value_name_float(r, "hqintx", Families[r][FamHQIntX]);
            cache_get_value_name_float(r, "hqinty", Families[r][FamHQIntY]);
            cache_get_value_name_float(r, "hqintz", Families[r][FamHQIntZ]);
            cache_get_value_name_float(r, "hqinta", Families[r][FamHQIntA]);
            cache_get_value_name_int(r, "hqvw", Families[r][FamHQVW]);
            cache_get_value_name_int(r, "hqintid", Families[r][FamHQIntID]);
            cache_get_value_name_int(r, "hqintvw", Families[r][FamHQIntVW]);
            cache_get_value_name_int(r, "hqintintid", Families[r][FamHQIntIntID]);
            if(IsPlayerInRangeOfPoint(playerid, 1.0, Families[r][FamHQX], Families[r][FamHQY], Families[r][FamHQZ]))
            {
                if(Player[playerid][FamilyID] != Families[r][ID])
                {
                    GameTextForPlayer(playerid, "~r~Restricted Access", 5000, 1);
                    return 1;
                }
                else if(Families[r][FamHQIntIntID] == 999)
                {
                    SendClientMessage(playerid, -1, "SERVER: This HQ is not setup correctly.");
                    return 1;
                }
                else
                {
                    SetPlayerPos(playerid, Families[r][FamHQX], Families[r][FamHQY], Families[r][FamHQZ]);
                    SetPlayerFacingAngle(playerid, Families[r][FamHQA]);
                    SetPlayerInterior(playerid, Families[r][FamHQIntID]);
                    SetPlayerVirtualWorld(playerid, Families[r][FamHQIntVW]);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    mysql_query(g_SQL, "SELECT * FROM `factions` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_FACTIONS; r++)//Finish this as Factions not Families
        {
            cache_get_value_name_int(r, "factionexists", Factions[r][Exists]);
            cache_get_value_name_int(r, "id", Factions[r][ID]);
            cache_get_value_name(r, "factionname", Factions[r][FactionName],72);

            cache_get_value_name_float(r, "hqx", Factions[r][FacHQX]);
            cache_get_value_name_float(r, "hqy", Factions[r][FacHQY]);
            cache_get_value_name_float(r, "hqz", Factions[r][FacHQZ]);
            cache_get_value_name_float(r, "hqintx", Factions[r][FacHQIntX]);
            cache_get_value_name_float(r, "hqinty", Factions[r][FacHQIntY]);
            cache_get_value_name_float(r, "hqintz", Factions[r][FacHQIntZ]);
            cache_get_value_name_float(r, "hqinta", Factions[r][FacHQIntA]);
            cache_get_value_name_int(r, "hqvw", Factions[r][FacHQVW]);
            cache_get_value_name_int(r, "hqintid", Factions[r][FacHQIntID]);
            cache_get_value_name_int(r, "hqintvw", Factions[r][FacHQIntVW]);
            cache_get_value_name_int(r, "hqintintid", Factions[r][FacHQIntIntID]);
            if(IsPlayerInRangeOfPoint(playerid, 1.0, Factions[r][FacHQX], Factions[r][FacHQY], Factions[r][FacHQZ]))
            {
                if(Player[playerid][FactionID] != Factions[r][ID])
                {
                    GameTextForPlayer(playerid, "~r~Restricted Access", 5000, 1);
                    return 1;
                }
                else if(Factions[r][FacHQIntIntID] == 999)
                {
                    SendClientMessage(playerid, -1, "SERVER: This HQ is not setup correctly.");
                    return 1;
                }
                else
                {
                    SetPlayerPos(playerid, Factions[r][FacHQX], Factions[r][FacHQY], Factions[r][FacHQZ]);
                    SetPlayerFacingAngle(playerid, Factions[r][FacHQA]);
                    SetPlayerInterior(playerid, Factions[r][FacHQIntID]);
                    SetPlayerVirtualWorld(playerid, Factions[r][FacHQIntVW]);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    #if DEBUG_COMMANDS == true
        print("DEBUG: CMD:exit Called");
    #endif
    return 1;
}
It's actually doing my head in just seeing this mess lol
Reply


Messages In This Thread
MySQL Overlapping ID's - by SkyFlare - 12.02.2019, 07:24
Re: MySQL Overlapping ID's - by Kane - 12.02.2019, 07:55
Re: MySQL Overlapping ID's - by TheToretto - 12.02.2019, 08:15
Re: MySQL Overlapping ID's - by SkyFlare - 12.02.2019, 08:18
Re: MySQL Overlapping ID's - by SkyFlare - 12.02.2019, 08:35
Re: MySQL Overlapping ID's - by TheToretto - 12.02.2019, 09:49
Re: MySQL Overlapping ID's - by Autorojo - 12.02.2019, 11:46
Re: MySQL Overlapping ID's - by SkyFlare - 12.02.2019, 16:01

Forum Jump:


Users browsing this thread: 1 Guest(s)