Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:createhouse(playerid,params[])
- {
- if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
- // If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
- // returning "SERVER: Unknown command" to the player
- if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
- // Setup local variables
- new HPrice, MaxLevel, HouseID;
- // Check if the player isn't inside a vehicle (the admin-player must be on foot to use this command)
- if (GetPlayerVehicleSeat(playerid) == -1)
- {
- if (sscanf(params, "ii", HPrice, MaxLevel)) return SendClientMessage(playerid, 0xFFFFFFFF, "Koristenje: /createhouse <price> <maxlevel (1-10)"");
- // Check if the player entered a proper maxlevel
- if ((MaxLevel >= 1) && (MaxLevel <= 10))
- {
- // Find the first free HouseID
- for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
- if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID])) // Check if an empty house-index has been found (PickupID is 0)
- break; // Stop searching, the first free HouseID has been found now
- // Check if the house-limit hasn't been reached yet
- // This would seem to double-check the pickup-id, but in case there was no free houseslot found (HouseID points
- // to the last index, the last index would hold a house, so be sure to not overwrite it
- if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
- {
- // Setup some local variables
- new Float:x, Float:y, Float:z, Msg[128];
- // Get the player's position
- GetPlayerPos(playerid, x, y, z);
- // Set some default data
- AHouseData[HouseID][Owned] = false;
- AHouseData[HouseID][Owner] = 0;
- AHouseData[HouseID][HouseX] = x;
- AHouseData[HouseID][HouseY] = y;
- AHouseData[HouseID][HouseZ] = z;
- AHouseData[HouseID][HouseLevel] = 1;
- AHouseData[HouseID][HouseMaxLevel] = MaxLevel;
- AHouseData[HouseID][HousePrice] = HPrice;
- AHouseData[HouseID][HouseOpened] = false;
- AHouseData[HouseID][Insurance] = false;
- AHouseData[HouseID][StaticHouse] = false;
- AHouseData[HouseID][CarSlots] = 1; // This must be equal to the house-level for a normal house
- // Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
- House_UpdateEntrance(HouseID);
- // Save the house
- HouseFile_Save(HouseID);
- // Inform the player that he created a new house
- format(Msg, 128, "{00FF00}You've succesfully created a house with ID: {FFFF00}%i", HouseID);
- SendClientMessage(playerid, 0xFFFFFFFF, Msg);
- }
- else
- SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You have to use a max-level from 1 to 10");
- }
- }
- else
- SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to create a house");
- // Let the server know that this was a valid command
- return 1;
- }
- // Lets the player add new houses (a house that cannot be upgraded, has a fixed interior and a fixed amount of carslots)
- CMD:createstatichouse(playerid,params[])
- {
- // Setup local variables
- new HPrice, Carslots, HouseID, Interior;
- // If a player hasn't logged in properly, he cannot use this command
- if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
- // If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
- // returning "SERVER: Unknown command" to the player
- if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
- // Check if the player isn't inside a vehicle (the admin-player must be on foot to use this command)
- if (GetPlayerVehicleSeat(playerid) == -1)
- {
- if (!sscanf(params, "iii", HPrice, Carslots, Interior))
- {
- // Check if the player entered a proper amount of Carslots
- if ((Carslots >= 1) && (Carslots <= 10))
- {
- // Check if the player entered a valid interior
- if ((Interior >= 1) && (Interior <= 10))
- {
- // Find the first free HouseID
- for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
- if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID])) // Check if an empty house-index has been found (PickupID is 0)
- break; // Stop searching, the first free HouseID has been found now
- // Check if the house-limit hasn't been reached yet
- // This would seem to double-check the pickup-id, but in case there was no free houseslot found (HouseID points
- // to the last index, the last index would hold a house, so be sure to not overwrite it
- if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
- {
- // Setup some local variables
- new Float:x, Float:y, Float:z, Msg[128];
- // Get the player's position
- GetPlayerPos(playerid, x, y, z);
- // Set some default data
- AHouseData[HouseID][Owned] = false;
- AHouseData[HouseID][HouseX] = x;
- AHouseData[HouseID][HouseY] = y;
- AHouseData[HouseID][HouseZ] = z;
- AHouseData[HouseID][HouseLevel] = Interior; // The house-level indicates the static interior
- AHouseData[HouseID][HouseMaxLevel] = Interior;
- AHouseData[HouseID][HousePrice] = HPrice;
- AHouseData[HouseID][HouseOpened] = false;
- AHouseData[HouseID][Insurance] = false;
- AHouseData[HouseID][StaticHouse] = true;
- AHouseData[HouseID][CarSlots] = Carslots;
- // Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
- House_UpdateEntrance(HouseID);
- // Save the house
- HouseFile_Save(HouseID);
- // Inform the player that he created a new house
- format(Msg, 128, "{00FF00}You've succesfully created a static house with ID: {FFFF00}%i", HouseID);
- SendClientMessage(playerid, 0xFFFFFFFF, Msg);
- }
- else
- SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}The maximum amount of houses has been reached");
- }
- else
- SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You have to use an interior-id from 1 to 10");
- }
- else
- SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You have to use a max amount of carslots from 1 to 10");
- }
- }
- else
- SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to create a house");
- // Let the server know that this was a valid command
- return 1;
- }
Add Comment
Please, Sign In to add comment