Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- COMMAND:buildhouse(playerid, params[])
- {
- if(pData[playerdid][Buildstage] == NO_BUILD_STAGE)
- {
- if(GetPVarInt(playerid, "AdminLevel") >= 5)
- {
- new slot;
- slot = FindEmptySlot[builders];
- if(slot != 1)
- {
- builders[slot][E_BUILDER_ID] = playerid;
- pData[playerid][Buildstage] = STAGE_BUILD_START;
- pData[playerid][Buildslot] = slot;
- SendClientMessage(playerid, white, "You are now creating a house. Type /buildhouse at the OUTSIDE position to save the outside position.");
- return 1;
- }
- return SendClientMessage(playerid, white, "All building slots are taken! Please wait until one is free.");
- }
- return 0;
- }
- switch(pData[playerid][Buildstage])
- {
- case STAGE_BUILD_START:
- {
- GetPlayerPos(playerid, builder[pData[playerid][Buildslot]][][x], builder[pData[playerid][Buildslot]][][y], builder[pData[playerid][Buildslot]][][z]);
- GetPlayerFacingAngle(playerid, builder[pData[playerid][Buildslot]][][rotation]);
- pData[playerid][Buildstage] = STAGE_BUILD_TYPE;
- SendClientMessage(playerid, white, "Outside position saved. Type /buildhouse <type> (TYPES - 1: SMALL, 2: MEDIUM, 3: LARGE)");
- return 1;
- }
- case STAGE_BUILD_TYPE
- {
- new hType = strval(params), cArray[MAX_HOUSE_TYPES] = {-1,...}, Counter = 0, result;
- if(!isnull(params))
- {
- for(new a = 0; a < sizeof(cData); a++)
- {
- if(cData[a][Type] == hType)
- {
- Counter++;
- cArray[Counter] = a;
- }
- result = random(Counter);
- builder[pData[playerid][Buildslot]][x2] = cData[cArray[result]][ix];
- builder[pData[playerid][Buildslot]][y2] = cData[cArray[result]][iy];
- builder[pData[playerid][Buildslot]][z2] = cData[result][iz];
- builder[pData[playerid][Buildslot]][rotation2] = cData[cArray[result]][iz];
- builder[pData[playerid][Buildslot]][interior] = cData[cArray[result]][iinterior];
- pData[playerid][Buildstage] = STAGE_BUILD_PRICE;
- SendClientMessage(playerid, white, "Use /buildhouse <price> to set the price.");
- }
- }
- return SendClientMessage(playerid, white, "Usage: /buildhouse <type> (TYPES: 1: SMALL, 2: MEDIUM, 3: LARGE)");
- }
- case STAGE_BUILD_PRICE:
- {
- builder[pData[playerid][Buildslot]][price] = strval(params);
- if(!isnull(params))
- {
- new HouseID = HouseCount+1;
- builder[pData[playerid][Buildslot]][x] = hData[HouseID][x];
- builder[pData[playerid][Buildslot]][y] = hData[HouseID][y];
- builder[pData[playerid][Buildslot]][z] = hData[HouseID][z];
- builder[pData[playerid][Buildslot]][rotation] = hData[HouseID][rotation];
- builder[pData[playerid][Buildslot]][x2] = hData[HouseID][x2];
- builder[pData[playerid][Buildslot]][y2] = hData[HouseID][y2];
- builder[pData[playerid][Buildslot]][z2] = hData[HouseID][z2];
- builder[pData[playerid][Buildslot]][rotation2] = hData[HouseID][rotation2];
- builder[pData[playerid][Buildslot]][interior] = hData[HouseID][interior];
- builder[pData[playerid][Buildslot]][price] = hData[HouseID][price];
- format(bigstr, sizeof(bigstr), "INSERT INTO `houses` (`owner`, `x`, `y`, `z`, `rotation`, `x2`, `y2`, `z2`, `rotation2`, `interior`, `price`, `HouseID`) VALUES ('none', %f, %f, %f, %f, %f, %f, %f, %f, %d, %d, %d)", hData[HouseID][x], hData[HouseID][y], hData[HouseID][z], hData[HouseID][rotation], hData[HouseID][x2], hData[HouseID][y2], hData[HouseID][z2], hData[HouseID][rotation2], hData[HouseID][interior], hData[HouseID][price], HouseID);
- mysql_query(bigstr);
- mysql_free_result();
- DestroyDynamicPickup(HousePickup[HouseID]);
- HousePickup[HouseID] = CreateDynamicPickup(HOUSE_AVAILABLE_PICKUP, 23, hData[HouseID][x], hData[HouseID][y], hData[HouseID][z], -1, 0, -1, HOUSE_PICKUP_DISTANCE);
- DestroyDynamicMapIcon(HouseMap[HouseID]);
- HouseMap[HouseID] = CreateDynamicMapIcon(hData[HouseID][x], hData[HouseID][y], hData[HouseID][z], HOUSE_AVAILABLE_MAP, 0, 0, 0, -1, HOUSE_MAP_DISTANCE);
- HouseCount = HouseID;
- pData[playerid][Buildslot] = -1;
- pData[playerid][Buildstage] = NO_BUILD_STAGE;
- }
- return SendClientMessage(playerid, white, "Usage: /createhouse <price>");
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement