12.02.2019, 08:35
Quote:
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...
|
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;
}