Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. CMD:buyhouse(playerid, params[])
  2. {
  3. new pName[MAX_PLAYER_NAME];
  4. GetPlayerName(playerid, pName, sizeof(pName));
  5. for(new h = 0; h < sizeof(HouseInfo); h++)
  6. {
  7. if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ]) && HouseInfo[h][hOwned] == 0)
  8. {
  9. if(GetLevel(playerid) < HouseInfo[h][hLevelbuy])
  10. {
  11. format(msg, sizeof(msg), "You must be level %d to purchase this house", HouseInfo[h][hLevelbuy]);
  12. HouseMSG(playerid, msg);
  13. return 1;
  14. }
  15. if(PlayerInfo[playerid][pHouseKey] != -1 && strcmp(pName, HouseInfo[PlayerInfo[playerid][pHouseKey]][hOwner], true) == 0) return HouseMSG(playerid, "You already own a house, type /sellhouse if you want to buy this one.");
  16. if(GetCash(playerid) < HouseInfo[h][hPrice]) return HouseMSG(playerid, "You don't have the cash for that !");
  17. PlayerInfo[playerid][pHouseKey] = h;
  18. PlayerInfo[playerid][pSpawnType] = 1;
  19. HouseInfo[h][hOwned] = 1;
  20. HouseInfo[h][hLocked] = 1;
  21. HouseInfo[h][hRentable] = 0;
  22. HouseInfo[h][hRentprice] = 0;
  23. HouseInfo[h][hCash] = 0;
  24. strmid(HouseInfo[h][hOwner], GetName(playerid), 0, strlen(GetName(playerid)), 255);
  25. GiveCash(playerid, -HouseInfo[h][hPrice]);
  26. HouseMSG(playerid, "Congratulations, on your new Purchase !");
  27. HouseMSG(playerid, "Type /househelp to review the new property help section !");
  28. UpdateHouseText(h);
  29. UpdateHouseInfo(h);
  30. format(query, sizeof(query), "UPDATE `users` SET `housekey` = %d WHERE `housekey` = %d", -1, h);
  31. SavePlayerStats(playerid);
  32. return 1;
  33. }
  34. }
  35. return 1;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement