Advertisement
Guest User

createhouse

a guest
Mar 16th, 2018
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. CMD:createhouse(playerid, params[])
  2. {
  3. if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
  4. if(IsPlayerConnected(playerid))
  5. {
  6. if(PlayerInfo[playerid][pAdmin] >= 6)
  7. {
  8. new house[64],Float:pX,Float:pY,Float:pZ,string[128],PropertyString[256],query[500];
  9. if(sscanf(params, "s[64]", house)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFFFF}Syntax: {FFFFFF}/createhouse <exterior/interior/complete>");
  10. if(strcmp(house,"exterior",true) == 0)
  11. {
  12. GetPlayerPos(playerid, pX, pY, pZ);
  13. SetPVarFloat(playerid, "pHeX", pX);
  14. SetPVarFloat(playerid, "pHeY", pY);
  15. SetPVarFloat(playerid, "pHeZ", pZ);
  16. SetPVarInt(playerid, "hExt", 1);
  17. SendClientMessage(playerid, COLOR_YELLOW, "House exterior position configured.");
  18. }
  19. if(strcmp(house,"interior",true) == 0)
  20. {
  21. GetPlayerPos(playerid, pX, pY, pZ);
  22. SetPVarFloat(playerid, "pHiX", pX);
  23. SetPVarFloat(playerid, "pHiY", pY);
  24. SetPVarFloat(playerid, "pHiZ", pZ);
  25. SetPVarInt(playerid, "pHiID", GetPlayerInterior(playerid));
  26. SetPVarInt(playerid, "pHiVW", GetPlayerVirtualWorld(playerid));
  27. SetPVarInt(playerid, "hInt", 1);
  28. SendClientMessage(playerid, COLOR_YELLOW, "House interior position configured.");
  29. }
  30. if(strcmp(house,"complete",true) == 0)
  31. {
  32. if(GetPVarInt(playerid, "hExt") != 1 || GetPVarInt(playerid, "hInt") != 1)
  33. return SendClientMessage(playerid, COLOR_RED, "You haven't configured either the house exterior or interior. Creation attempt failed.");
  34.  
  35. new i = housess+1;
  36. mysql_format(SQL, query, sizeof(query), "INSERT INTO houses (Owner, Lockk, Hel, Arm, Level, Rentabil, Rent, Owned, Discription, Value, Takings) VALUES('AdmBot', '0', '0', '0', '10', '1', '500', '0', 'House', '10000000', '0')");
  37. mysql_tquery(SQL, query, "", "");
  38.  
  39. HouseInfo[i][hID] = i;
  40. HouseInfo[i][hEntrancex] = GetPVarFloat(playerid, "pHeX");
  41. HouseInfo[i][hEntrancey] = GetPVarFloat(playerid, "pHeY");
  42. HouseInfo[i][hEntrancez] = GetPVarFloat(playerid, "pHeZ");
  43. HouseInfo[i][hExitx] = GetPVarFloat(playerid, "pHiX");
  44. HouseInfo[i][hExity] = GetPVarFloat(playerid, "pHiY");
  45. HouseInfo[i][hExitz] = GetPVarFloat(playerid, "pHiZ");
  46. format(HouseInfo[i][hOwner], 64, "The State");
  47. format(HouseInfo[i][hDiscription], 64, "House");
  48. HouseInfo[i][hValue] = 10000000;
  49. HouseInfo[i][hHel] = 0;
  50. HouseInfo[i][hArm] = 0;
  51. HouseInfo[i][hInterior] = GetPVarInt(playerid, "pHiID");
  52. HouseInfo[i][hLock] = 0;
  53. HouseInfo[i][hOwned] = 0;
  54. HouseInfo[i][hRent] = 500;
  55. HouseInfo[i][hRentabil] = 1;
  56. HouseInfo[i][hTakings] = 0;
  57. HouseInfo[i][hLevel] = 10;
  58. HouseInfo[i][hVirtual] = GetPVarInt(playerid, "pHiVW");
  59.  
  60. mysql_format(SQL, query, sizeof(query), "UPDATE `houses` SET `Entrancex`='%f',`Entrancey`='%f',`Entrancez`='%f',`Exitx`='%f',`Exity`='%f',`Exitz`='%f',`Interior`='%d',`Virtual`='%d' WHERE `ID`='%d'",HouseInfo[i][hEntrancex],HouseInfo[i][hEntrancey],HouseInfo[i][hEntrancez],HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz],HouseInfo[i][hInterior],HouseInfo[i][hVirtual],i);
  61. mysql_tquery(SQL,query,"","");
  62.  
  63. DeletePVar(playerid, "pHeX");
  64. DeletePVar(playerid, "pHeY");
  65. DeletePVar(playerid, "pHeZ");
  66. DeletePVar(playerid, "pHiX");
  67. DeletePVar(playerid, "pHeY");
  68. DeletePVar(playerid, "pHeZ");
  69. DeletePVar(playerid, "pHiID");
  70. DeletePVar(playerid, "pHiVW");
  71. DeletePVar(playerid, "pExt");
  72. DeletePVar(playerid, "pInt");
  73.  
  74. DestroyDynamic3DTextLabel(HouseLabel[i]);
  75. format(PropertyString, sizeof(PropertyString),"{FFFFFF}House {FF0000}%d \n{FF0000}This house is for sale(/buyhouse) ! \n{FFFFFF}Description: {FF0000}%s \n{FFFFFF}Price: {FF0000}$%s \n{FFFFFF}Level: {FF0000}%d",i,HouseInfo[i][hDiscription],FormatNumber(HouseInfo[i][hValue]),HouseInfo[i][hLevel]);
  76. HouseLabel[i] = CreateDynamic3DTextLabel(PropertyString ,0x09FF00CC,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez],25, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100.0);
  77. DestroyDynamicPickup(HousePickup[i]);
  78. HousePickup[i] = CreateDynamicPickup(1273, 23, HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]);
  79.  
  80. SetPlayerInterior(playerid, 0);
  81. SetPlayerVirtualWorld(playerid, 0);
  82. SetPlayerPos(playerid, HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]);
  83. housess++;
  84. format(string,sizeof(string),"House %d created!",i);
  85. SendClientMessage(playerid, COLOR_YELLOW, string);
  86. }
  87. }
  88. else return SendClientMessage(playerid, COLOR_ERROR, AdminOnly);
  89. }
  90. return 1;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement