Advertisement
Guest User

Untitled

a guest
Nov 11th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.84 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. #define FILTERSCRIPT
  4.  
  5. // Incudes
  6. #include <a_samp>
  7. #include <YSI\y_ini>
  8. #include <YSI\y_commands>
  9. #include <streamer>
  10. #include <sscanf2>
  11. #include <zcmd(3)>
  12.  
  13. #if defined FILTERSCRIPT
  14.  
  15. // Dialogs
  16. #define DIALOG_REGISTER 1
  17. #define DIALOG_LOGIN 2
  18. #define DIALOG_SUCCESS_1 3
  19. #define DIALOG_SUCCESS_2 4
  20.  
  21. // Path
  22. #define PATH "/Users/%s.ini"
  23.  
  24. // Colors
  25. #define COL_WHITE "{FFFFFF}"
  26. #define COL_RED "{F81414}"
  27. #define COL_GREEN "{00FF22}"
  28. #define COL_LIGHTBLUE "{00CED1}"
  29.  
  30. #define SCM SendClientMessage //Saves time
  31. #define BPATH "/Business/%i.ini" //Defines the path y_ini will use to find the .ini file we need.
  32. //The below colors do not have to be used, but you will need to edit the script if you choose not to use them.
  33. #define NEWBIE_COLOR 0x7DAEFFFF
  34. #define TCOLOR_WHITE 0xFFFFFF00
  35. #define COLOR_GRAD1 0xB4B5B7FF
  36. #define COLOR_GRAD2 0xBFC0C2FF
  37. #define COLOR_GRAD3 0xCBCCCEFF
  38. #define COLOR_GRAD4 0xD8D8D8FF
  39. #define COLOR_GRAD5 0xE3E3E3FF
  40. #define COLOR_GRAD6 0xF0F0F0FF
  41. #define COLOR_FADE1 0xE6E6E6E6
  42. #define COLOR_FADE2 0xC8C8C8C8
  43. #define COLOR_FADE3 0xAAAAAAAA
  44. #define COLOR_FADE4 0x8C8C8C8C
  45. #define COLOR_FADE5 0x6E6E6E6E
  46. #define COLOR_PURPLE 0xC2A2DAAA
  47. #define COLOR_RED 0xAA3333AA
  48. #define COLOR_GREY 0xAFAFAFAA
  49. #define COLOR_GREEN 0x33AA33AA
  50. #define COLOR_BLACK 0x000001FF
  51. #define COLOR_BLUE 0x007BD0FF
  52. #define COLOR_LIGHTORANGE 0xFFA100FF
  53. #define COLOR_FLASH 0xFF000080
  54. #define COLOR_LIGHTRED 0xFF6347AA
  55. #define COLOR_LIGHTBLUE 0x01FCFFC8
  56. #define COLOR_LIGHTGREEN 0x9ACD32AA
  57. #define COLOR_YELLOW 0xFFFF00AA
  58. #define COLOR_LIGHTYELLOW 0xFFFF91FF
  59. #define COLOR_YELLOW2 0xF5DEB3AA
  60. #define COLOR_WHITE 0xFFFFFFAA
  61.  
  62. new InsideBiz[MAX_PLAYERS];//This define will be used later to find out what business we are in.
  63.  
  64. enum bInfo {
  65. bOwned,
  66. bPrice,
  67. bOwner[MAX_PLAYER_NAME],
  68. bType,
  69. bLocked,
  70. bMoney,
  71. Float:bEntranceX,
  72. Float:bEntranceY,
  73. Float:bEntranceZ,
  74. Float:bEntranceA,
  75. Float:bExitX,
  76. Float:bExitY,
  77. Float:bExitZ,
  78. Float:bExitA,
  79. bInt,
  80. bWorld,
  81. bInsideInt,
  82. bInsideWorld,
  83. bInsideIcon,
  84. bOutsideIcon,
  85. bName[128]
  86. }
  87. new BusinessInfo[200][bInfo];//We are creating a define to use for our Enum.
  88.  
  89. // enum
  90. enum pInfo
  91. {
  92. pPass,
  93. pAdmin,
  94. pKills,
  95. pDeaths,
  96. BizID,
  97. Money,
  98. Skin
  99. }
  100. new PlayerInfo[MAX_PLAYERS][pInfo];
  101.  
  102. public OnFilterScriptInit()
  103. {
  104. new str[40];
  105. for(new idx = 1; idx < sizeof(BusinessInfo); idx++)//Creates a loop, that goes through all of the businesses.
  106. {
  107. format(str, sizeof(str), BPATH, idx);//formats the file path, with the biz ID
  108. INI_ParseFile(str, "loadbiz_%s", .bExtra = true, .extra = idx );//This is very hard to explain, but it basically loads the info from the file(More in Y_Less y_ini tutorial.)
  109. BusinessInfo[idx][bOutsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[idx][bEntranceX], BusinessInfo[idx][bEntranceY], BusinessInfo[idx][bEntranceZ], BusinessInfo[idx][bWorld]); //Creates a pickup at the business entrance.
  110. BusinessInfo[idx][bInsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[idx][bExitX], BusinessInfo[idx][bExitY], BusinessInfo[idx][bExitZ], BusinessInfo[idx][bInsideWorld]); //Creates a pickup at the exit(Inside the interior)
  111. }
  112. print("\n--------------------------------------");
  113. print(" Register System");
  114. print("--------------------------------------\n");
  115. return 1;
  116. }
  117.  
  118. public OnFilterScriptExit()
  119. {
  120. for(new id = 1; id < sizeof(BusinessInfo); id++)//Loops through the businesses.
  121. {
  122. if(BusinessInfo[id][bPrice] == 0) break;//Breaks the loop if the price is 0(Meaning it doesn't exist)
  123. SaveBusiness(id);//Calls the SaveBusiness function.
  124. }
  125. print("\n--------------------------------------");
  126. print(" Register System shuting down");
  127. print("--------------------------------------\n");
  128. return 1;
  129. }
  130.  
  131. #else
  132.  
  133. main()
  134. {
  135. print("\n----------------------------------");
  136. print(" REG SYS");
  137. print("----------------------------------\n");
  138. }
  139.  
  140. #endif
  141.  
  142. forward SaveBusiness(id);
  143. public SaveBusiness(id)
  144. {
  145. new file4[40];
  146. format(file4, sizeof(file4), BPATH, id);
  147. new INI:File = INI_Open(file4);
  148. INI_SetTag(File,"data");
  149. INI_WriteInt(File,"bOwned", BusinessInfo[id][bOwned]);
  150. INI_WriteInt(File,"bPrice", BusinessInfo[id][bPrice]);
  151. INI_WriteString(File,"bOwner", BusinessInfo[id][bOwner]);
  152. INI_WriteInt(File,"bType", BusinessInfo[id][bType]);
  153. INI_WriteInt(File,"bLocked", BusinessInfo[id][bLocked]);
  154. INI_WriteInt(File,"bMoney", BusinessInfo[id][bMoney]);
  155. INI_WriteFloat(File,"bEntranceX", BusinessInfo[id][bEntranceX]);
  156. INI_WriteFloat(File,"bEntranceY", BusinessInfo[id][bEntranceY]);
  157. INI_WriteFloat(File,"bEntranceZ", BusinessInfo[id][bEntranceZ]);
  158. INI_WriteFloat(File,"bEntranceA", BusinessInfo[id][bEntranceA]);
  159. INI_WriteFloat(File,"bExitX", BusinessInfo[id][bExitX]);
  160. INI_WriteFloat(File,"bExitY", BusinessInfo[id][bExitY]);
  161. INI_WriteFloat(File,"bExitZ", BusinessInfo[id][bExitZ]);
  162. INI_WriteFloat(File,"bExitA", BusinessInfo[id][bExitA]);
  163. INI_WriteInt(File,"bInt", BusinessInfo[id][bInt]);
  164. INI_WriteInt(File,"bWorld", BusinessInfo[id][bWorld]);
  165. INI_WriteInt(File,"bInsideInt", BusinessInfo[id][bInsideInt]);
  166. INI_WriteInt(File,"bInsideWorld", BusinessInfo[id][bInsideWorld]);
  167. INI_WriteString(File,"bName", BusinessInfo[id][bName]);
  168. INI_Close(File);
  169. return 1;
  170. }
  171.  
  172. forward loadbiz_data(idx, name[], value[]);
  173. public loadbiz_data(idx, name[], value[])
  174. {
  175. INI_Int("bOwned", BusinessInfo[idx][bOwned]);
  176. INI_Int("bPrice", BusinessInfo[idx][bPrice]);
  177. INI_String("bOwner", BusinessInfo[idx][bOwner], 24);
  178. INI_Int("bType", BusinessInfo[idx][bType]);
  179. INI_Int("bLocked", BusinessInfo[idx][bLocked]);
  180. INI_Int("bMoney", BusinessInfo[idx][bMoney]);
  181. INI_Float("bEntranceX", BusinessInfo[idx][bEntranceX]);
  182. INI_Float("bEntranceY", BusinessInfo[idx][bEntranceY]);
  183. INI_Float("bEntranceZ", BusinessInfo[idx][bEntranceZ]);
  184. INI_Float("bEntranceA", BusinessInfo[idx][bEntranceA]);
  185. INI_Float("bExitX", BusinessInfo[idx][bExitX]);
  186. INI_Float("bExitY", BusinessInfo[idx][bExitY]);
  187. INI_Float("bExitZ", BusinessInfo[idx][bExitZ]);
  188. INI_Float("bExitA", BusinessInfo[idx][bExitA]);
  189. INI_Int("bInt", BusinessInfo[idx][bInt]);
  190. INI_Int("bWorld", BusinessInfo[idx][bWorld]);
  191. INI_Int("bInsideInt", BusinessInfo[idx][bInsideInt]);
  192. INI_Int("bInsideWorld", BusinessInfo[idx][bInsideWorld]);
  193. INI_String("bName", BusinessInfo[idx][bName], 128);
  194. return 1;
  195. }
  196.  
  197. CMD:createbiz(playerid, params[])
  198. {
  199. if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_GREY, "You aren't authorized to use this command!");//Checks if player is a RCON admin..Change this with your admin system.
  200.  
  201. new price, level, id, int, world, string[128], Float:Xi, Float:Yi, Float:Zi, inti;//All the new defines we will need.
  202. if(sscanf(params, "dddfff", price, level, inti, Xi, Yi, Zi)) return SendClientMessage(playerid, COLOR_GREY, "YCMD: /createbiz [price] [type] [interior] [X] [Y] [Z]");//d stands for integer, f stands for float.
  203.  
  204. if(level < 0 || level > 4) return SendClientMessage(playerid, COLOR_GREY, "YCMD: Type cannot go below 0, or above 10.");//
  205.  
  206. if(price < 10000) return SendClientMessage(playerid, COLOR_GREY, "YCMD: Price cannot go below $10,000.");// Check if the price is below 1000, if it is it will return a message saying it.
  207.  
  208. for(new h = 1;h < sizeof(BusinessInfo);h++)//Loops through all the businesses
  209. {
  210. if(BusinessInfo[h][bPrice] == 0)//Checks if the price of a business is 0.
  211. {
  212. id = h;
  213. break;//It stops looping if it is.
  214. }
  215. }
  216. new Float:X,Float:Y,Float:Z,Float:A;//More new defines.
  217. GetPlayerPos(playerid, X, Y, Z);//Gets your player position, and saves it into floats.
  218. GetPlayerFacingAngle(playerid, A);//Gets your facing angle, and saves it into a float.
  219. int = GetPlayerInterior(playerid);//Gets your interior, and saves it into a integer.
  220. world = GetPlayerVirtualWorld(playerid);//Gets your Virtual World, and saves it into a integer
  221. BusinessInfo[id][bInsideInt] = inti;
  222. BusinessInfo[id][bExitX] = Xi;
  223. BusinessInfo[id][bExitY] = Yi;
  224. BusinessInfo[id][bExitZ] = Zi;
  225.  
  226. BusinessInfo[id][bOwned] = 0;
  227. BusinessInfo[id][bPrice] = price;
  228. BusinessInfo[id][bType] = level;
  229. BusinessInfo[id][bEntranceX] = X;
  230. BusinessInfo[id][bEntranceY] = Y;
  231. BusinessInfo[id][bEntranceZ] = Z;
  232. BusinessInfo[id][bEntranceA] = A;
  233. BusinessInfo[id][bLocked] = 1;
  234.  
  235. BusinessInfo[id][bInt] =int;
  236. BusinessInfo[id][bWorld] =world;
  237. BusinessInfo[id][bInsideWorld] =id;
  238.  
  239. format(string, sizeof(string), "None");
  240. strmid(BusinessInfo[id][bName], string, 0, strlen(string), 255);
  241.  
  242. if(BusinessInfo[id][bOutsideIcon]) DestroyDynamicPickup(BusinessInfo[id][bOutsideIcon]);
  243. if(BusinessInfo[id][bInsideIcon]) DestroyDynamicPickup(BusinessInfo[id][bInsideIcon]);
  244. BusinessInfo[id][bOutsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[id][bEntranceX], BusinessInfo[id][bEntranceY], BusinessInfo[id][bEntranceZ], BusinessInfo[id][bWorld]);//Creates a pickup at your location
  245. BusinessInfo[id][bInsideIcon] = CreateDynamicPickup(1272, 1, BusinessInfo[id][bExitX], BusinessInfo[id][bExitY], BusinessInfo[id][bExitZ], BusinessInfo[id][bInsideWorld]);//Creates a pickup at your location
  246. new file4[40];
  247. format(file4, sizeof(file4), BPATH, id);
  248. new INI:File = INI_Open(file4);
  249. INI_SetTag(File,"data");
  250. INI_WriteInt(File,"bOwned", BusinessInfo[id][bOwned]);
  251. INI_WriteInt(File,"bPrice", BusinessInfo[id][bPrice]);
  252. INI_WriteString(File,"bOwner", BusinessInfo[id][bOwner]);
  253. INI_WriteInt(File,"bType", BusinessInfo[id][bType]);
  254. INI_WriteInt(File,"bLocked", BusinessInfo[id][bLocked]);
  255. INI_WriteInt(File,"bMoney", BusinessInfo[id][bMoney]);
  256. INI_WriteFloat(File,"bEntranceX", BusinessInfo[id][bEntranceX]);
  257. INI_WriteFloat(File,"bEntranceY", BusinessInfo[id][bEntranceY]);
  258. INI_WriteFloat(File,"bEntranceZ", BusinessInfo[id][bEntranceZ]);
  259. INI_WriteFloat(File,"bEntranceA", BusinessInfo[id][bEntranceA]);
  260. INI_WriteFloat(File,"bExitX", BusinessInfo[id][bExitX]);
  261. INI_WriteFloat(File,"bExitY", BusinessInfo[id][bExitY]);
  262. INI_WriteFloat(File,"bExitZ", BusinessInfo[id][bExitZ]);
  263. INI_WriteFloat(File,"bExitA", BusinessInfo[id][bExitA]);
  264. INI_WriteInt(File,"bInt", BusinessInfo[id][bInt]);
  265. INI_WriteInt(File,"bWorld", BusinessInfo[id][bWorld]);
  266. INI_WriteInt(File,"bInsideInt", BusinessInfo[id][bInsideInt]);
  267. INI_WriteInt(File,"bInsideWorld", BusinessInfo[id][bInsideWorld]);
  268. INI_WriteString(File,"bName", BusinessInfo[id][bName]);
  269. INI_Close(File);
  270. return 1;
  271. }
  272.  
  273. CMD:deletebiz(playerid, params[])
  274. {
  275. if(!IsPlayerAdmin(playerid)) return 1; // Checks if a player is a RCON admin, again change this to your admin system.
  276.  
  277. new id;
  278.  
  279. if(sscanf(params, "d", id)) return SendClientMessage(playerid, COLOR_GREY, "YCMD: /deletebiz [id]");
  280. if(BusinessInfo[id][bOwned] == 1) return SCM(playerid, COLOR_GREY, "This biz is owned.");//Checks if the biz is owned, if it is it won't allow it to be deleted.
  281. //Below it resets all the biz enum info.
  282. BusinessInfo[id][bOwned] = 0;
  283. BusinessInfo[id][bPrice] = 0;
  284. BusinessInfo[id][bOwner] = 0;
  285. BusinessInfo[id][bType] = 0;
  286. BusinessInfo[id][bLocked] = 0;
  287. BusinessInfo[id][bName] = 0;
  288. BusinessInfo[id][bMoney] = 0;
  289. BusinessInfo[id][bEntranceX] = 0;
  290. BusinessInfo[id][bEntranceY] = 0;
  291. BusinessInfo[id][bEntranceZ] = 0;
  292. BusinessInfo[id][bEntranceA] = 0;
  293. BusinessInfo[id][bExitX] = 0;
  294. BusinessInfo[id][bExitY] = 0;
  295. BusinessInfo[id][bExitZ] = 0;
  296. BusinessInfo[id][bExitA] = 0;
  297. BusinessInfo[id][bInt] = 0;
  298. BusinessInfo[id][bWorld] = 0;
  299.  
  300. if(BusinessInfo[id][bOutsideIcon]) DestroyDynamicPickup(BusinessInfo[id][bOutsideIcon]);//Destroys the pickup.
  301.  
  302. new string[128];
  303.  
  304. format(string, sizeof(string), BPATH, id);
  305. fremove(string);
  306. return 1;
  307. }
  308.  
  309. public OnPlayerPickUpDynamicPickup(playerid, pickupid)
  310. {
  311. new string[256];
  312. for(new b = 1;b < sizeof(BusinessInfo);b++)// Loopd through all the businesses again.
  313. {
  314. if(pickupid == BusinessInfo[b][bOutsideIcon])//Checks if it's a biz pickup.
  315. {
  316. if(BusinessInfo[b][bOwned] == 0)//Checks if it is owned.
  317. {
  318. format(string, sizeof(string), "~g~Name:~w~%s~n~~w~This business is ~g~for sale!~n~~r~Price:~g~%i~n~BizType:~w~%s~n~~g~BizID:~w~%i", BusinessInfo[b][bName], BusinessInfo[b][bPrice], BusinessType(b), b);//Formats a string with all the info.
  319. GameTextForPlayer(playerid, string, 3000, 3);
  320. }
  321. if(BusinessInfo[b][bOwned] == 1)//Checks if it owned.
  322. {
  323. format(string, sizeof(string), "~g~Name:~w~%s~n~~g~Owner:~w~%s~n~~g~BizType:~w~%s ~n~~g~BizID:~w~%i", BusinessInfo[b][bName], BusinessInfo[b][bOwner], BusinessType(b), b);//Formats a string with all the info.
  324. GameTextForPlayer(playerid, string, 3000, 3);
  325. }
  326. }
  327. }
  328. return 1;
  329. }
  330.  
  331. stock BusinessType(b)// creates a stock.
  332. {
  333. new string[30];
  334. switch(BusinessInfo[b][bType])//You should know what switch is.
  335. {
  336. case 4: string = "24/7";
  337. case 3: string = "Club";
  338. case 2: string = "Bar";
  339. case 1: string = "Clothes Shop";
  340. }
  341. return string;
  342. }
  343.  
  344. IsPlayerNearBizEnt(playerid)
  345. {
  346. for(new b = 1; b < sizeof(BusinessInfo); b++)
  347. {
  348. if(IsPlayerInRangeOfPoint(playerid, 2.0, BusinessInfo[b][bEntranceX], BusinessInfo[b][bEntranceY], BusinessInfo[b][bEntranceZ])) return b;
  349. }
  350. return -1;
  351. }
  352.  
  353. CMD:lockbiz(playerid, params[])
  354. {
  355. new id = IsPlayerNearBizEnt(playerid);//Uses the function to find if player is near a biz!
  356. if(id != PlayerInfo[playerid][BizID]) return SCM(playerid, COLOR_GREY, "This isn't your biz!");
  357. if(BusinessInfo[id][bLocked] == 1)
  358. {
  359. BusinessInfo[id][bLocked] = 0;
  360. GameTextForPlayer(playerid, "Biz ~g~unlocked!", 3000, 3);
  361. }
  362. else
  363. {
  364. BusinessInfo[id][bLocked] = 1;
  365. GameTextForPlayer(playerid, "Biz ~r~locked!", 3000, 3);
  366. }
  367. return 1;
  368. }
  369.  
  370. CMD:enter(playerid, params[])
  371. {
  372. for(new b = 1; b < sizeof(BusinessInfo); b++)//Loops through all the businesses.
  373. {
  374. if(IsPlayerInRangeOfPoint(playerid, 1.0, BusinessInfo[b][bEntranceX], BusinessInfo[b][bEntranceY], BusinessInfo[b][bEntranceZ]))//Checks if player is near the entrance.
  375. {
  376. if(BusinessInfo[b][bLocked] == 1) return SendClientMessage(playerid, COLOR_GREY, "This Business is locked!");//Checks it it is locked/
  377. SetPlayerPos(playerid, BusinessInfo[b][bExitX], BusinessInfo[b][bExitY], BusinessInfo[b][bExitZ]);
  378. SetPlayerFacingAngle(playerid, BusinessInfo[b][bExitA]);
  379. SetPlayerInterior(playerid, BusinessInfo[b][bInsideInt]);
  380. SetPlayerVirtualWorld(playerid, BusinessInfo[b][bInsideWorld]);
  381. InsideBiz[playerid] = b;
  382. return 1;
  383. }
  384. if(IsPlayerInRangeOfPoint(playerid, 2.0, BusinessInfo[b][bExitX], BusinessInfo[b][bExitY], BusinessInfo[b][bExitZ]) && GetPlayerVirtualWorld(playerid) == BusinessInfo[b][bInsideWorld])//Checks if player is in near the exit.
  385. {
  386. SetPlayerPos(playerid, BusinessInfo[b][bEntranceX], BusinessInfo[b][bEntranceY], BusinessInfo[b][bEntranceZ]);
  387. SetPlayerFacingAngle(playerid, BusinessInfo[b][bEntranceA]);
  388. SetPlayerInterior(playerid, BusinessInfo[b][bInt]);
  389. SetPlayerVirtualWorld(playerid, BusinessInfo[b][bWorld]);
  390. InsideBiz[playerid] = 0;
  391. return 1;
  392. }
  393. }
  394. return 1;
  395. }
  396.  
  397. CMD:buybiz(playerid, params[])
  398. {
  399.  
  400. new id = IsPlayerNearBizEnt(playerid);
  401.  
  402. if(id == -1 || id == 0) return SendClientMessage(playerid, COLOR_GREY, "You are not near a biz");
  403.  
  404. if(BusinessInfo[id][bOwned] != 0 || BusinessInfo[id][bPrice] == 0) return SendClientMessage(playerid, COLOR_GREY, "This biz is not for sale.");
  405.  
  406. if(PlayerInfo[playerid][BizID] != 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You already own a biz.");
  407.  
  408. if(PlayerInfo[playerid][Money] < BusinessInfo[id][bPrice]) return SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, you can not afford this biz.");
  409.  
  410. PlayerInfo[playerid][BizID] = id;
  411. PlayerInfo[playerid][Money] -= BusinessInfo[id][bPrice];
  412. GivePlayerMoney(playerid, -BusinessInfo[id][bPrice]);
  413.  
  414. BusinessInfo[id][bLocked] = 0;
  415. BusinessInfo[id][bOwned] = 1;
  416. //BusinessInfo[id][bOwner] = RemoveUnderScore(playerid);
  417.  
  418. SendClientMessage(playerid, COLOR_YELLOW, "Congratulations on your new biz! Use /bizhelp to get help, or /ask!");
  419. return 1;
  420. }
  421.  
  422. CMD:sellbiz(playerid, params[])
  423. {
  424. new id = PlayerInfo[playerid][BizID];
  425. if(PlayerInfo[playerid][BizID] == 0) return SCM(playerid, COLOR_GREY, "You don't own a biz!");
  426. BusinessInfo[id][bOwned] = 0;
  427. BusinessInfo[id][bOwner] = 0;
  428. BusinessInfo[id][bLocked] = 1;
  429. PlayerInfo[playerid][Money] = BusinessInfo[id][bPrice];
  430. PlayerInfo[playerid][BizID] = 0;
  431. SCM(playerid, COLOR_YELLOW, "Business sold!");
  432. return 1;
  433. }
  434.  
  435. CMD:bizsetname(playerid, params[])
  436. {
  437. new name[128];
  438. if(sscanf(params, "s[128]", name)) return SCM(playerid, COLOR_GREY, "/bizsetname [name]");
  439. if(PlayerInfo[playerid][BizID] == 0) return SCM(playerid, COLOR_GREY, "You don't own a biz!");
  440. BusinessInfo[PlayerInfo[playerid][BizID]][bName] = name;
  441. SCM(playerid, COLOR_YELLOW, "Business name changed!");
  442. return 1;
  443. }
  444.  
  445. CMD:clothes(playerid, params[])
  446. {
  447. new skin;
  448. if(sscanf(params, "i", skin)) return SCM(playerid, COLOR_GREY, "YCMD:/skin [skinid]");
  449. if(PlayerInfo[playerid][Money] < 100) return SCM(playerid, COLOR_GREY, "You need atleast 100%!");
  450. if(BusinessInfo[InsideBiz[playerid]][bType] != 1) return SCM(playerid, COLOR_GREY, "You need to be in clothes shop!");
  451. if(1 > skin || 299 < skin || skin == 288 || skin == 287 || skin == 286 || skin == 285 || skin == 284 || skin == 283 || skin == 282 || skin == 281 || skin == 280 || skin == 279 || skin == 278 || skin == 277 || skin == 276 || skin == 275 || skin == 274) return SCM(playerid, COLOR_GREY, "Invalid skin ID!");
  452. SetPlayerSkin(playerid, skin);
  453. PlayerInfo[playerid][Skin] = skin;
  454. GivePlayerMoney(playerid, -100);
  455. BusinessInfo[InsideBiz[playerid]][bMoney] += 100;
  456. return 1;
  457. }
  458.  
  459. forward LoadUser_data(playerid,name[],value[]);
  460. public LoadUser_data(playerid,name[],value[])
  461. {
  462. INI_Int("Password",PlayerInfo[playerid][pPass]);
  463. INI_Int("Money",PlayerInfo[playerid][Money]);
  464. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  465. INI_Int("Kills",PlayerInfo[playerid][pKills]);
  466. INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  467. return 1;
  468. }
  469.  
  470. stock UserPath(playerid)
  471. {
  472. new string[128],playername[MAX_PLAYER_NAME];
  473. GetPlayerName(playerid,playername,sizeof(playername));
  474. format(string,sizeof(string),PATH,playername);
  475. return string;
  476. }
  477.  
  478. /*Credits to Dracoblue*/
  479. stock udb_hash(buf[]) {
  480. new length=strlen(buf);
  481. new s1 = 1;
  482. new s2 = 0;
  483. new n;
  484. for (n=0; n<length; n++)
  485. {
  486. s1 = (s1 + buf[n]) % 65521;
  487. s2 = (s2 + s1) % 65521;
  488. }
  489. return (s2 << 16) + s1;
  490. }
  491.  
  492. public OnPlayerConnect(playerid)
  493. {
  494. if(fexist(UserPath(playerid)))
  495. {
  496. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  497. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
  498. }
  499. else
  500. {
  501. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
  502. }
  503. return 1;
  504. }
  505.  
  506. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  507. {
  508. switch( dialogid )
  509. {
  510. case DIALOG_REGISTER:
  511. {
  512. if (!response) return Kick(playerid);
  513. if(response)
  514. {
  515. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
  516. new INI:File = INI_Open(UserPath(playerid));
  517. INI_SetTag(File,"data");
  518. INI_WriteInt(File,"Password",udb_hash(inputtext));
  519. INI_WriteInt(File,"Cash",0);
  520. INI_WriteInt(File,"Admin",0);
  521. INI_WriteInt(File,"Kills",0);
  522. INI_WriteInt(File,"Deaths",0);
  523. INI_Close(File);
  524.  
  525. SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  526. SpawnPlayer(playerid);
  527. ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
  528. }
  529. }
  530.  
  531. case DIALOG_LOGIN:
  532. {
  533. if ( !response ) return Kick ( playerid );
  534. if( response )
  535. {
  536. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  537. {
  538. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  539. GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
  540. ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
  541. }
  542. else
  543. {
  544. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
  545. }
  546. return 1;
  547. }
  548. }
  549. }
  550. return 1;
  551. }
  552.  
  553. public OnPlayerDisconnect(playerid, reason)
  554. {
  555. new INI:File = INI_Open(UserPath(playerid));
  556. INI_SetTag(File,"data");
  557. INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  558. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  559. INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  560. INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  561. INI_Close(File);
  562. return 1;
  563. }
  564.  
  565. public OnPlayerDeath(playerid, killerid, reason)
  566. {
  567. PlayerInfo[killerid][pKills]++;
  568. PlayerInfo[playerid][pDeaths]++;
  569. return 1;
  570. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement