Advertisement
Guest User

[TRADUZIDO] Sistema de Casa Dinamica V0.1 [BASICO]

a guest
Jul 10th, 2013
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.76 KB | None | 0 0
  1. // Barbouch's Houses //
  2. // v: 0.1 //
  3. // Features : //
  4. // Buyable/Sellable Houses //
  5. // Dynamic Houses Creating In Game //
  6. //Current Saving System Version: INI//
  7.  
  8. // Next Version v: 0.2 //
  9. // Features: //
  10. // MYSQL VERSION : will come with v0.2 //
  11. // Houses Cars //
  12. // Players will be building there own houses using ressources that they will gather //
  13. // Release Date of the V 0.2 : [Coming Very Soon] //
  14. // Credits: Firecat for his awesome Tutorial//
  15. // Credits: Naruto_Emilio for coding this FilterScript //
  16. // Credits: Traduzido por: Diksplay For PT/BR Board
  17.  
  18. #include <a_samp>
  19. #include <zcmd>
  20. #include <sscanf2>
  21. #include <SII>
  22. #include <streamer>
  23.  
  24.  
  25. #define COL_EASY "{FFF1AF}"
  26. #define COL_WHITE "{FFFFFF}"
  27. #define COL_BLACK "{0E0101}"
  28. #define COL_GREY "{C3C3C3}"
  29. #define COL_GREEN "{6EF83C}"
  30. #define COL_RED "{F81414}"
  31. #define COL_YELLOW "{F3FF02}"
  32. #define COL_ORANGE "{FFAF00}"
  33. #define COL_LIME "{B7FF00}"
  34. #define COL_CYAN "{00FFEE}"
  35. #define COL_LIGHTBLUE "{00C0FF}"
  36. #define COL_BLUE "{0049FF}"
  37. #define COL_MAGENTA "{F300FF}"
  38. #define COL_VIOLET "{B700FF}"
  39. #define COL_PINK "{FF00EA}"
  40. #define COL_MARONE "{A90202}"
  41. #define COL_CMD "{B8FF02}"
  42. #define COL_PARAM "{3FCD02}"
  43. #define COL_SERVER "{AFE7FF}"
  44. #define COL_VALUE "{A3E4FF}"
  45. #define COL_RULE "{F9E8B7}"
  46. #define COL_RULE2 "{FBDF89}"
  47. #define COL_RWHITE "{FFFFFF}"
  48. #define COL_LGREEN "{C9FFAB}"
  49. #define COL_LRED "{FFA1A1}"
  50. #define COL_LRED2 "{C77D87}"
  51.  
  52.  
  53. #pragma tabsize 0
  54.  
  55. #define IAD IsPlayerAdmin
  56. #define MAX_HOUSES_BUILT 1000 // Você Mudar isso, como quiser
  57. #define HELP_DIALOG 2580
  58. #define INVALID_HOUSE_ID -255 // Use sempre um valor negativo
  59.  
  60.  
  61. enum HouseInf
  62. {
  63. Owner[24],
  64. Owned,
  65. Price,
  66. Float:posX,
  67. Float:posY,
  68. Float:posZ,
  69. VW,
  70. Text3D:HouseLabel
  71. }
  72. new HInfo[MAX_HOUSES_BUILT][HouseInf];
  73. new Housesnumbers;
  74. new HousesEntrance[MAX_HOUSES_BUILT];
  75. new HousesExit[MAX_HOUSES_BUILT];
  76. new InsideHouse[MAX_PLAYERS];
  77.  
  78.  
  79. public OnFilterScriptInit()
  80. {
  81. print("\n--------------------------------------");
  82. print(" Barbouch's House System Ligado!");
  83. print("--------------------------------------\n");
  84. LoadHouses();
  85. return 1;
  86. }
  87.  
  88. public OnFilterScriptExit()
  89. {
  90. print("\n--------------------------------------");
  91. print(" Barbouch's House System Desligado!");
  92. print("--------------------------------------\n");
  93. for(new i = 0; i < MAX_PLAYERS; i++)
  94. {
  95. DeletePlayer3DTextLabel(i, PlayerText3D:HouseLabel);
  96. }
  97. return 1;
  98. }
  99.  
  100. public OnPlayerConnect(playerid)
  101. {
  102.  
  103. return 1;
  104. }
  105. public OnPlayerSpawn(playerid)
  106. {
  107.  
  108. return 1;
  109. }
  110.  
  111. CMD:makehouse(playerid, params[])
  112. {
  113. if(!IAD(playerid)) return GameTextForPlayer(playerid, "~r~Acesso Negado", 3000, 5);
  114. new
  115. Float:X,
  116. Float:Y,
  117. Float:Z,
  118. hPrice,
  119. virtualw,
  120. string[60],
  121. HID = Housesnumbers;
  122. if(sscanf(params,"ii", hPrice, virtualw)) return SendClientMessage(playerid,-1,"{ Uso Correto } "#COL_GREEN#" /makehouse "#COL_YELLOW#" (preço) "#COL_VIOLET#" (Virtual World)");
  123.  
  124. if(hPrice < 10000)
  125. {
  126. SendClientMessage(playerid, -1, "O Preço da casa Deve começar em RS 10000");
  127. return 0;
  128. }
  129. if(virtualw <= -1)
  130. {
  131. SendClientMessage(playerid, -1, ""#COL_RED#"Virutal World Não deve ser um "#COL_YELLOW#"minus "#COL_RED#"Número.");
  132. return 0;
  133. }
  134.  
  135. GetPlayerPos(playerid, X, Y, Z);
  136. HInfo[HID][Price] = hPrice;
  137. HInfo[HID][Owned] = 0;
  138. HInfo[HID][posX] = X;
  139. HInfo[HID][posY] = Y;
  140. HInfo[HID][posZ] = Z;
  141. HInfo[HID][VW] = virtualw;
  142. format(HInfo[HID][Owner], 20, "No_Owner");
  143. GameTextForPlayer(playerid, "~g~Casa Criada", 1500, 5);
  144. format(string, sizeof(string), "Preço da Casa: "#COL_GREEN#"%i "#COL_MARONE#"||"#COL_WHITE#" Virtual World: "#COL_GREEN#"%i", HInfo[HID][Price], HInfo[HID][VW]);
  145. SendClientMessage(playerid, -1, string);
  146. HousesEntrance[HID] = CreateDynamicCP(X , Y , Z , 1.0, virtualw);
  147. HousesExit[HID] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5, virtualw);
  148.  
  149. new file[40], labelstring[100];
  150. format(file, sizeof(file), "Houses/%i.ini", HID);
  151. INI_Open(file);
  152. INI_WriteInt("Price", hPrice);
  153. INI_WriteInt("Owned",0);
  154. INI_WriteInt("VirtualWorld", virtualw);
  155. INI_WriteFloat("posX", X);
  156. INI_WriteFloat("posY", Y);
  157. INI_WriteFloat("posZ", Z);
  158. INI_WriteString("Owner","No_Owner");
  159. INI_Save();
  160. INI_Close();
  161. format(labelstring,sizeof(labelstring),""#COL_GREEN#"[ DONO ]: "#COL_WHITE#"Sem Dono \n"#COL_GREEN#"[ Preço ]: "#COL_RED#"%i", hPrice);
  162. HInfo[HID][HouseLabel] = Create3DTextLabel(labelstring, 0xFF0000FF, X, Y, Z, 25.0 , virtualw);
  163. Housesnumbers++;
  164. return 1;
  165. }
  166.  
  167.  
  168.  
  169.  
  170. forward LoadPos(playerid);
  171. public LoadPos(playerid)
  172. {
  173. SetPlayerPos(playerid, GetPVarFloat(playerid,"xpos"), GetPVarFloat(playerid,"ypos"), GetPVarFloat(playerid,"zpos"));
  174. SetPlayerVirtualWorld(playerid, GetPVarInt(playerid, "pvirtual"));
  175. SetPlayerInterior(playerid, 0);
  176. return 1;
  177. }
  178.  
  179. forward SavePos(playerid);
  180. public SavePos(playerid)
  181. {
  182. new Float:x,Float:y,Float:z;
  183. GetPlayerPos(playerid,x,y,z);
  184. SetPVarFloat(playerid,"xpos",x);
  185. SetPVarFloat(playerid,"ypos",y);
  186. SetPVarFloat(playerid,"zpos",z);
  187. SetPVarInt(playerid,"pvirtual", GetPlayerVirtualWorld(playerid));
  188. return 1;
  189. }
  190.  
  191.  
  192. public OnPlayerEnterDynamicCP(playerid,checkpointid)
  193. {
  194. for(new i = 0; i < MAX_HOUSES_BUILT;i++)
  195. {
  196. new pName[24];
  197. GetPlayerName(playerid, pName, sizeof(pName));
  198. if(checkpointid == HousesEntrance[i])
  199. {
  200. if(HInfo[i][Owned] == 1 && strcmp(pName,HInfo[i][Owner]) != 0) return SendClientMessage(playerid,-1,""#COL_RED#"You aren't the "#COL_YELLOW#"owner "#COL_GREEN#"of this house!");
  201. if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner],pName) == 0)
  202. {
  203. ShowPlayerDialog(playerid, 2002, DIALOG_STYLE_LIST, "Opções da Casa", ""#COL_BLUE#"Entrar na Casa\n"#COL_RED#"Vender Casa", "Escolher", "Cancelar");
  204. SavePos(playerid);
  205.  
  206. }
  207. if(HInfo[i][Owned] == 0)
  208. {
  209. ShowPlayerDialog(playerid, 2001, DIALOG_STYLE_MSGBOX, "Opções da Casa", "Você tem certeza, que quer comprar está casa?", "Comprar", "Cancelar");
  210. }
  211.  
  212. }
  213. if(checkpointid == HousesExit[i])
  214. {
  215. ShowPlayerDialog(playerid, 2000, DIALOG_STYLE_MSGBOX, "Opções da Casa", "Você quer deixar está casa?", "Sim", "Não");
  216. }
  217. }
  218. return 1;
  219. }
  220. public OnPlayerLeaveDynamicCP(playerid, checkpointid)
  221. {
  222. return 1;
  223. }
  224.  
  225. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  226. {
  227. if(dialogid == 2000)
  228. {
  229. if(response)
  230. {
  231. for(new i = 0; i < MAX_HOUSES_BUILT;i++)
  232. {
  233. LoadPos(playerid);
  234. }
  235. SendClientMessage(playerid, -1, ""#COL_RED#"Você saiu Da casa de: "#COL_GREEN#"");
  236. }
  237. else
  238. {
  239. SendClientMessage(playerid, -1, ""#COL_RED#"Você cancelou a saida da casa de: "#COL_GREEN#"");
  240.  
  241. }
  242. return 1;
  243. }
  244. if(dialogid == 2001)
  245. {
  246. if(response)
  247. {
  248. for(new i = 0; i < MAX_HOUSES_BUILT;i++)
  249. {
  250. if(!IsPlayerInRangeOfPoint(playerid, 8.0, HInfo[i][posX], HInfo[i][posY], HInfo[i][posZ])) continue;
  251. if(GetPlayerMoney(playerid) < HInfo[i][Price]) return SendClientMessage(playerid, -1, ""#COL_RED#"Você Não tem dinheiro suficiente!");
  252. if(HInfo[i][Owned] == 1) return SendClientMessage(playerid,-1,""#COL_RED#"Está casa já tem "#COL_GREEN#"Dono!");
  253. HInfo[i][Owned] = 1;
  254. new file[60], pName[24], string[100];
  255. GetPlayerName(playerid, pName, sizeof(pName));
  256. format(HInfo[i][Owner], 24, "%s", pName);
  257. format(file,sizeof(file),"Houses/%i.ini", i);
  258. INI_Open(file);
  259. INI_WriteInt("Owned",1);
  260. INI_WriteString("Owner",pName);
  261. INI_Save();
  262. INI_Close();
  263. format(string,sizeof(string),""#COL_GREEN#"Comprada: "#COL_WHITE#"Sim \n"#COL_GREEN#"Preço: "#COL_RED#"%i \n"#COL_GREEN#"Dono: "#COL_WHITE#"%s", HInfo[i][Price], pName);
  264. Update3DTextLabelText(HInfo[i][HouseLabel], 0xFF0000FF, string);
  265. GivePlayerMoney(playerid, -HInfo[i][Price]);
  266. return 1;
  267. }
  268. }
  269. else
  270. {
  271. SendClientMessage(playerid, -1, ""#COL_RED#"Você cancelou a compra desta "#COL_GREEN#"casa");
  272.  
  273. }
  274. return 1;
  275. }
  276. if(dialogid == 2002)
  277. {
  278. if(response)
  279. {
  280. switch(listitem)
  281. {
  282. case 0:
  283. {
  284. for(new i = 0; i < MAX_HOUSES_BUILT;i++)
  285. {
  286. new pName[24];
  287. GetPlayerName(playerid,pName,24);
  288. if(HInfo[i][Owned] == 1 && strcmp(HInfo[i][Owner], pName) == 0)
  289. {
  290. SetPVarInt(playerid,"PlayersInteriorHouse", GetPlayerInterior(playerid));
  291. SetPVarInt(playerid,"PlayerVirtualWorldHouse", GetPlayerVirtualWorld(playerid));
  292. SetPlayerInterior(playerid,12);
  293. SetPlayerPos(playerid,446.7281,507.0475,1001.4195) ;
  294. SetPlayerVirtualWorld(playerid,HInfo[i][VW]);
  295. InsideHouse[playerid] = i;
  296.  
  297. }
  298. else
  299. {
  300. SendClientMessage(playerid, -1, ""#COL_RED#"Você não pode entrar nesta "#COL_GREEN#"pois ela já tem um "#COL_YELLOW#"Dono");
  301. }
  302. }
  303. }
  304. case 1:
  305. {
  306. for(new i = 0; i < MAX_HOUSES_BUILT;i++)//Loop threw all houses.
  307. {
  308. new pName[24];
  309. GetPlayerName(playerid,pName,24);
  310. new file[60],string[100];
  311. format(HInfo[i][Owner], 24, "No_Owner");
  312. format(file,sizeof(file),"Houses/%i.ini",i);
  313. INI_Open(file);
  314. INI_WriteInt("Owned",0);
  315. INI_WriteString("Owner","No_Owner");
  316. INI_Save();
  317. INI_Close();
  318. format(string, sizeof(string), ""#COL_GREEN#"Owned: "#COL_MAGENTA#"No \n"#COL_GREEN#"Price: "#COL_RED#"%i \n"#COL_GREEN#"Owner: "#COL_WHITE#"None", HInfo[i][Price],pName);
  319. Update3DTextLabelText(HInfo[i][HouseLabel], 0xFF0000FF, string);
  320. format(string, 80, "Você vendeu sua casa para:"#COL_GREEN#" %d", HInfo[i][Price]/=2);
  321. GivePlayerMoney(playerid, HInfo[i][Price]/=2);
  322. SendClientMessage(playerid, -1, string);
  323. HInfo[i][Owned] = 0;
  324. return 1;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. return 1;
  331. }
  332.  
  333.  
  334. stock LoadHouses()
  335. {
  336. new file[60],houseowner[24];
  337. for(new i = 0; i < MAX_HOUSES_BUILT;i++)
  338. {
  339. format(file,sizeof(file),"Houses/%i.ini",i);
  340. if(!INI_Exist(file)) continue;
  341. INI_Open(file);
  342. HInfo[i][Price] = INI_ReadInt("Price");
  343. HInfo[i][Owned] = INI_ReadInt("Owned");
  344. HInfo[i][posX] = INI_ReadInt("posX");
  345. HInfo[i][posY] = INI_ReadInt("posY");
  346. HInfo[i][posZ] = INI_ReadInt("posZ");
  347. HInfo[i][VW] = INI_ReadInt("VirtualWorld");
  348. INI_ReadString(houseowner, "Owner");
  349. format(HInfo[i][Owner], 24, "%s", houseowner);
  350. HousesEntrance[i] = CreateDynamicCP(HInfo[i][posX], HInfo[i][posY], HInfo[i][posZ], 1.5, HInfo[i][VW]);
  351. HousesExit[i] = CreateDynamicCP(443.9237, 509.4609, 1001.4195, 1.5, HInfo[i][VW]);
  352. new labelstring[100];
  353. switch(HInfo[i][Owned])
  354. {
  355. case 0:{format(labelstring, sizeof(labelstring), ""#COL_GREEN#"Dono: "#COL_RED#"Não \n"#COL_GREEN#"Preço: "#COL_YELLOW#"%i", HInfo[i][Price]);}
  356. case 1:{format(labelstring, sizeof(labelstring), ""#COL_GREEN#"Dono: "#COL_BLUE#"Sim \n"#COL_GREEN#"Preço: "#COL_YELLOW#"%i \n"#COL_GREEN#"Dono: "#COL_VIOLET#"%s", HInfo[i][Price], HInfo[i][Owner]);}
  357. }
  358. HInfo[i][HouseLabel] = Create3DTextLabel(labelstring, 0xFF0000FF, HInfo[i][posX], HInfo[i][posY], HInfo[i][posZ], 25.0, HInfo[i][VW]);
  359. Housesnumbers++;
  360. INI_Close();
  361. }
  362. return 1;
  363. }
  364.  
  365. stock GetHouseID(playerid)
  366. {
  367. for(new i=0; i<MAX_HOUSES_BUILT; i++)
  368. {
  369. if(IsPlayerInRangeOfPoint(playerid, 1, HInfo[i][posX], HInfo[i][posY], HInfo[i][posZ]))
  370. {
  371. return i;
  372. }
  373. }
  374. return INVALID_HOUSE_ID;
  375. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement