Advertisement
Guest User

Untitled

a guest
Jan 24th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.98 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3. #include <zcmd>
  4. #include <sscanf2>
  5. #include <streamer>
  6.  
  7. #define GREY 0xAFAFAFAA
  8. #define BLUE2 0x4682B4FF
  9. #define RED 0xFF0000AA
  10. #define YELLOW 0xE9E312FF
  11. #define ORANGE 0xFF9900AA
  12. #define WHITE 0xFFFEFFFF
  13. #define GREEN 0x33AA33AA
  14. #define BLUE 0x0000FFFF
  15. #define LIGHTGREEN 0x90EE90FF
  16. #define OLIVE 0x808000FF
  17. #define SALAMON 0xFA8072FF
  18. #define BLACK 0x000000FF
  19.  
  20. #define C_GREY "{AFAFAF}"
  21. #define C_BLUE2 "{4682B4}"
  22. #define C_RED "{FF0000}"
  23. #define C_YELLOW "{E9E312}"
  24. #define C_ORANGE "{FF9900}"
  25. #define C_WHITE "{FFFEFF}"
  26. #define C_GREEN "{33AA33}"
  27. #define C_BLUE "{0000FF}"
  28. #define C_LIGHTGREEN "{90EE90}"
  29. #define C_OLIVE "{808000}"
  30. #define C_SALAMON "{FA8072}"
  31. #define C_BLACK "{000000}"
  32.  
  33. #define MAX_HOUSE 100
  34. #define HousePATH "House/%d.ini"
  35.  
  36. enum hInfo
  37. {
  38. hOwner[24],
  39. Text3D:hLabel,
  40. hPickup,
  41. Float:hEnterX,
  42. Float:hEnterY,
  43. Float:hEnterZ,
  44. Float:hExitX,
  45. Float:hExitY,
  46. Float:hExitZ,
  47. hInterior,
  48. hCost,
  49. hSell
  50. };
  51.  
  52. new HouseInfo[MAX_PLAYERS][hInfo];
  53. new MaDom[MAX_PLAYERS];
  54. new Float:X, Float:Y, Float:Z;
  55. new houseid;
  56. new HouseCount;
  57.  
  58. forward LoadHouse_data(playerid, name[], value[]);
  59.  
  60. public OnPlayerConnect(playerid)
  61. {
  62. HouseInfo[playerid][hOwner] = 0;
  63. HouseInfo[playerid][hEnterX] = 0;
  64. HouseInfo[playerid][hEnterY] = 0;
  65. HouseInfo[playerid][hEnterZ] = 0;
  66. HouseInfo[playerid][hExitX] = 0;
  67. HouseInfo[playerid][hExitY] = 0;
  68. HouseInfo[playerid][hExitZ] = 0;
  69. HouseInfo[playerid][hInterior] = 0;
  70. HouseInfo[playerid][hCost] = 0;
  71. HouseInfo[playerid][hSell] = 0;
  72. MaDom[playerid] = 0;
  73. return 1;
  74. }
  75.  
  76. public OnPlayerDisconnect(playerid, reason)
  77. {
  78. if(MaDom[playerid] == 1)
  79. {
  80. for(new h = 0; h < sizeof(HouseInfo); h++)
  81. {
  82. new INI:File = INI_Open(HousePath());
  83. INI_WriteString(File, "Owner", HouseInfo[playerid][hOwner]);
  84. INI_WriteFloat(File, "EntryX", HouseInfo[playerid][hEnterX]);
  85. INI_WriteFloat(File, "EntryY", HouseInfo[playerid][hEnterY]);
  86. INI_WriteFloat(File, "EntryZ", HouseInfo[playerid][hEnterZ]);
  87. INI_WriteFloat(File, "OutputX", HouseInfo[playerid][hExitX]);
  88. INI_WriteFloat(File, "OutputY", HouseInfo[playerid][hExitY]);
  89. INI_WriteFloat(File, "OutputZ", HouseInfo[playerid][hExitZ]);
  90. INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]);
  91. INI_WriteInt(File, "Cost", HouseInfo[playerid][hCost]);
  92. INI_WriteInt(File, "Sell", HouseInfo[playerid][hSell]);
  93. }
  94. }
  95. return 1;
  96. }
  97.  
  98. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  99. {
  100. for(new h = 0; h < MAX_HOUSE; h++)
  101. {
  102. if(checkpointid == HouseInfo[playerid][hPickup])
  103. {
  104. if(fexist(HousePath()))
  105. {
  106. INI_ParseFile(HousePath(), "LoadHouse_%d", .bExtra = true, .extra = playerid);
  107. ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_MSGBOX, "Dom", "?æä äáéú ùìê, äàí áøöåðê ìäéëðñ àìéå ", "Yes", "No");
  108. }
  109. else
  110. {
  111. ShowPlayerDialog(playerid, 5001, DIALOG_STYLE_MSGBOX, "Dom", "?äáéú äæä äåà ìîëéøä, äàí áøöåðê ì÷ðåú àåúå", "Yes", "No");
  112. }
  113. }
  114. }
  115. return 1;
  116. }
  117.  
  118. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  119. {
  120. if(dialogid == 5001)
  121. {
  122. if(response)
  123. {
  124. if(GetPlayerMoney(playerid) > HouseInfo[playerid][hCost])
  125. {
  126. MaDom[playerid] = 1;
  127. SendClientMessage(playerid, GREEN, "House. ");
  128.  
  129. new string[128];
  130. format(string, sizeof string, ""C_BLUE2"Owner : "C_BLUE2"%s ", PlayerName(playerid));
  131. Update3DTextLabelText(HouseInfo[playerid][hLabel], RED, string);
  132.  
  133. new INI:File = INI_Open(HousePath());
  134. INI_WriteString(File, "Owner", PlayerName(playerid));
  135. INI_WriteFloat(File, "EntryX", HouseInfo[playerid][hEnterX]);
  136. INI_WriteFloat(File, "EntryY", HouseInfo[playerid][hEnterY]);
  137. INI_WriteFloat(File, "EntryZ", HouseInfo[playerid][hEnterZ]);
  138. INI_WriteFloat(File, "OutputX", HouseInfo[playerid][hExitX]);
  139. INI_WriteFloat(File, "OutputY", HouseInfo[playerid][hExitY]);
  140. INI_WriteFloat(File, "OutputZ", HouseInfo[playerid][hExitZ]);
  141. INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]);
  142. INI_WriteInt(File, "Cost", HouseInfo[playerid][hCost]);
  143. INI_WriteInt(File, "Sell", HouseInfo[playerid][hSell]);
  144. INI_Close(File);
  145. }
  146. else SendClientMessage(playerid, LIGHTGREEN, "You can not afford this house! ");
  147. }
  148. }
  149. return 1;
  150. }
  151.  
  152. CMD:createhouse(playerid, params[])
  153. {
  154. new cost, Sell, interior;
  155.  
  156. if(sscanf(params, "ddd", cost, Sell, interior))
  157. return SendClientMessage(playerid, SALAMON, "USAGE: /createhouse [cost] [sell] [interior]");
  158.  
  159. CreateHouse(playerid, cost, Sell, interior);
  160. return 1;
  161. }
  162.  
  163. forward CreateHouse(playerid, cost, Sell, interior);
  164. public CreateHouse(playerid, cost, Sell, interior)
  165. {
  166.  
  167. GetPlayerPos(playerid, X, Y, Z);
  168. new INI:File = INI_Open(HousePath());
  169.  
  170. HouseCount++;
  171. HouseInfo[playerid][hEnterX] = X;
  172. HouseInfo[playerid][hEnterY] = Y;
  173. HouseInfo[playerid][hEnterZ] = Z;
  174. HouseInfo[playerid][hInterior] = interior;
  175. HouseInfo[playerid][hCost] = cost;
  176. HouseInfo[playerid][hSell] = Sell;
  177.  
  178. INI_WriteFloat(File, "EntryX", HouseInfo[playerid][hEnterX]);
  179. INI_WriteFloat(File, "EntryY", HouseInfo[playerid][hEnterY]);
  180. INI_WriteFloat(File, "EntryZ", HouseInfo[playerid][hEnterZ]);
  181. INI_WriteFloat(File, "OutputX", 0);
  182. INI_WriteFloat(File, "OutputY", 0);
  183. INI_WriteFloat(File, "OutputZ", 0);
  184. INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]);
  185. INI_WriteInt(File, "Cost", HouseInfo[playerid][hCost]);
  186. INI_WriteInt(File, "Sell", HouseInfo[playerid][hSell]);
  187. INI_Close(File);
  188.  
  189. new string[128];
  190. format(string, sizeof string, ""C_BLUE2"Owner : "C_YELLOW"lack \n"C_BLUE2"cost : "C_YELLOW"%d\n", cost);
  191. HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, X, Y, Z, 7.0, 0);
  192.  
  193. HouseInfo[houseid][hPickup] = CreateDynamicCP(X, Y, Z, 2, 0, 0, 0, 20);
  194. return 1;
  195. }
  196.  
  197. public LoadHouse_data(playerid, name[], value[])
  198. {
  199. new Name[24], string[128];
  200. GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
  201. INI_String("Owner", Name, 48);
  202. INI_Float("EntryX", HouseInfo[playerid][hEnterX]);
  203. INI_Float("EntryY", HouseInfo[playerid][hEnterY]);
  204. INI_Float("EntryZ", HouseInfo[playerid][hEnterZ]);
  205. INI_Float("OutputX", HouseInfo[playerid][hExitX]);
  206. INI_Float("OutputY", HouseInfo[playerid][hExitY]);
  207. INI_Float("OutputZ", HouseInfo[playerid][hExitZ]);
  208. INI_Int("Interior", HouseInfo[playerid][hInterior]);
  209. INI_Int("Cost", HouseInfo[playerid][hCost]);
  210. INI_Int("Sell", HouseInfo[playerid][hSell]);
  211.  
  212. if(HouseInfo[playerid][hOwner] == 1)
  213. {
  214. format(string, sizeof string, ""C_BLUE2"Owner : "C_YELLOW"%s \n", Name);
  215. HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterZ], HouseInfo[playerid][hEnterZ], 7.0, 0);
  216. HouseInfo[houseid][hPickup] = CreateDynamicCP(HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterY], HouseInfo[playerid][hEnterZ], 2, 0, 0, 0, 20);
  217. }
  218. else
  219. {
  220. format(string, sizeof string, ""C_BLUE2"Owner : "C_YELLOW"brak \n"C_BLUE2"cost : "C_YELLOW"%d\n", HouseInfo[playerid][hCost]);
  221. HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterZ], HouseInfo[playerid][hEnterZ], 7.0, 0);
  222. HouseInfo[houseid][hPickup] = CreateDynamicCP(HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterY], HouseInfo[playerid][hEnterZ], 2, 0, 0, 0, 20);
  223. }
  224. return 1;
  225. }
  226.  
  227. stock HousePath()
  228. {
  229. new string[256];
  230. format(string, sizeof string, HousePATH, HouseCount);
  231. return string;
  232. }
  233.  
  234. stock PlayerName(playerid)
  235. {
  236. new name[24];
  237. GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  238. return name;
  239. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement