03.08.2013, 23:11
(
Последний раз редактировалось Nero_x$; 04.04.2014 в 23:40.
)
edith:
if (newkeys == KEY_SECONDARY_ATTACK)
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_SECONDARY_ATTACK)
{
// Setup local variables
new HouseID, IntID;
// If a player hasn't logged in properly, he cannot use this command
if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
// Check if the player isn't inside a vehicle (the player must be on foot to use this command)
if (GetPlayerVehicleSeat(playerid) == -1)
{
// Loop through all houses
for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
{
// Check if the house exists
if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
{
// Check if the player is in range of the house-pickup
if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
{
// Check if the house is closed to the public
if (AHouseData[HouseID][HouseOpened] == false)
{
// The house isn't open to the public, so keep anyone out who isn't the owner of the house
if (House_PlayerIsOwner(playerid, HouseID) == 0)
{
// Let the player know that this house isn't open to the public and he can't enter it
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Esta casa no estб abierta al pъblico, no se puede entrar en йl");
return 1;
}
}
// The house is open to the public, or the player trying to enter is the owner, so let the player inside the house
// Get the interior to put the player in
IntID = AHouseData[HouseID][HouseLevel]; // Get the level of the house
// Set the worldid so other players cannot see him anymore (but allow all players in the same house to see eachother)
SetPlayerVirtualWorld(playerid, 5000 + HouseID);
// Set the player inside the interior of the house
SetPlayerInterior(playerid, AHouseInteriors[IntID][InteriorID]);
// Set the position of the player at the spawn-location of the house's interior
SetPlayerPos(playerid, AHouseInteriors[IntID][IntX], AHouseInteriors[IntID][IntY], AHouseInteriors[IntID][IntZ]);
// Also set a tracking-variable to enable /housemenu to track in which house the player is
APlayerData[playerid][CurrentHouse] = HouseID;
// Also let the player know he can use /housemenu to upgrade/exit his house
SendClientMessage(playerid, 0xFFFFFFFF, "{3399FF}Use {FF0000}/hmenu{3399FF} para cambiar las opciones de su casa");
// Exit the function
return 1;
}
}
}
}
}
House_Exit(playerid, HouseID)
{
// Set the player in the normal world again
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
// Set the position of the player at the entrance of his house
SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
// Also clear the tracking-variable to track in which house the player is
APlayerData[playerid][CurrentHouse] = 0;
// Check if there is a timer-value set for exiting the house (this timer freezes the player while the environment is being loaded)
if (ExitHouseTimer > 0)
{
// Don't allow the player to fall
TogglePlayerControllable(playerid, 0);
// Let the player know he's frozen for 5 seconds
GameTextForPlayer(playerid, "", ExitHouseTimer, 4);
// Start a timer that will allow the player to fall again when the environment has loaded
SetTimerEx("House_ExitTimer", ExitHouseTimer, false, "ii", playerid, HouseID);
SetPlayerVirtualWorld(playerid,0);
}
return 0;
}
return 1;
}