MySQL Overlapping ID's
#5

Quote:
Originally Posted by TheToretto
View Post
Load Doors when the Gamemode loads, assign the values to the array, then just loop through your array, and check if he's near the coordinates of the door.. No need to send queries every time a player types one of the most used commands in-game...
You mean like so?
pawn Code:
CMD:enter(playerid, params[])
{
    for(new r = 0; r < MAX_DYNAMICDOORS; r++)
    {
        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;
            }
        }
    }
    for(new r = 0; r < MAX_DYNAMICHOUSES; r++)
    {
        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;
            }
        }
    }
    for(new r = 0; r < MAX_FAMILIES; r++)
    {
        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;
            }
        }
    }
    for(new r = 0; r < MAX_FACTIONS; r++)
    {
        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[])
{
    for(new r = 0; r < MAX_DYNAMICDOORS; r++)
    {
        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;
            }
        }
    }
    for(new r = 0; r < MAX_DYNAMICHOUSES; r++)
    {
        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;
            }
        }
    }
    for(new r = 0; r < MAX_FAMILIES; r++)
    {
        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;
            }
        }
    }
    for(new r = 0; r < MAX_FACTIONS; r++)
    {
        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;
}
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)