Guest User

Sisteminha de Casa

a guest
Aug 7th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. // GM TOPO
  2.  
  3. new Casas;
  4.  
  5. new CasaPickup[MAX_CASAS];
  6. new Text3D:CasaTextLabel[MAX_CASAS];
  7.  
  8. // COMANDO
  9.  
  10. CMD:criarcasa(playerid, params[])
  11. {
  12. new File[32], Float:Pos[3];
  13.  
  14. if(!IsPlayerAdmin(playerid))
  15. return SendClientMessage(playerid, -1, "| ERRO | Você não tem permissão!");
  16.  
  17. if(sscanf(params, "dd", Preco, Interior)
  18. return SendClientMessage(playerid, -1, "| ERRO | Use: /CriarCasa [Preço] [Interior]");
  19.  
  20. format(File, sizeof(File), "Casas/Casa%d.ini", Casas);
  21. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  22.  
  23. if(!DOF2::FileExists(File))
  24. {
  25. DOF2::CreateFile(File);
  26. DOF2::SetString(File, "Dono", "Ninguem");
  27. DOF2::SetString(File, "Mensagem", "Nada");
  28. DOF2::SetInt(File, "TDono", 0);
  29. DOF2::SetInt(File, "Preco", Preco);
  30. DOF2::SetInt(File, "Interior", Interior);
  31. DOF2::SetFloat(File, "X", Pos[0]);
  32. DOF2::SetFloat(File, "Y", Pos[1]);
  33. DOF2::SetFloat(File, "Z", Pos[2]);
  34. DOF2::SaveFile();
  35. }
  36. CasaPickup[Casas] = CreateDynamicPickup(1273, 1, Pos[0], Pos[1], Pos[2], -1, -1, -1, 100.0);
  37.  
  38. format(string, sizeof(string), "Casa id: %d", Casas);
  39. CasaTextLabel[Casas] = CreateDynamic3DTextLabel(string, -1, Pos[0], Pos[1], Pos[2], 30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100.0);
  40.  
  41. SendClientMessage(playerid, -1, "| INFO | Casa criada com sucesso!");
  42.  
  43. Casas++;
  44. return 1;
  45. }
  46. CMD:comprarcasa(playerid)
  47. {
  48. new File[32];
  49.  
  50. for(new House = 0; House < MAX_CASAS; ++House)
  51. {
  52. format(File, sizeof(File), "Casas/Casa%d.ini", House);
  53.  
  54. if(PlayerToPoint(playerid, 1.0, DOF2::GetFloat(File, "X"), DOF2::GetFloat(File, "Y"), DOF2::GetFloat(File, "Z"))
  55. return SendClientMessage(playerid, -1, "| ERRO | Você não está em uma Casa!");
  56.  
  57. if(GetPlayerMoney(playerid) < DOF2::GetInt(File, "Preco"))
  58. return SendClientMessage(playerid, -1, "| ERRO | Você não tem dinheiro suficiente!");
  59.  
  60. if(DOF2::GetInt(File, "TDono") == 1)
  61. return SendClientMessage(playerid, -1, "| ERRO | Esta casa já possui um dono(a)!");
  62.  
  63. DOF2::SetString(File, "Dono", pNome);
  64. DOF2::SetInt(File, "TDono", 1);
  65.  
  66. // PLAYER
  67.  
  68. format(File, sizeof(File, "Contas/%s.ini", pNome);
  69. DOF2::SetInt(Conta, "CasaID", House);
  70.  
  71. DOF2::SaveFile();
  72.  
  73. DestroyDynamicPickup(CasaPickup[House]);
  74. CasaPickup[House] = CreateDynamicPickup(19522, 1, INI_ReadFloat(File, "X"), INI_ReadFloat(File, "Y"), INI_ReadFloat(File, "Z"), -1, -1, -1, 100.0);
  75.  
  76. format(string, sizeof(string), "Casa id: %d", House);
  77. UpdateDynamic3DTextLabelText(CasaTextLabel[House], -1, string);
  78. return 1;
  79. }
  80. return 1;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment