proking

Advert

Jul 16th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 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. #include <a_samp>
  6. #include <sscanf2>
  7.  
  8. #define MAX_ADS 15
  9. enum Ads
  10. {
  11. Sub[20],
  12. Advert[128],
  13. Placeby[24],
  14. };
  15.  
  16. new AdsInfo[MAX_ADS][Ads];
  17.  
  18.  
  19. main()
  20. {
  21. print("\n----------------------------------");
  22. print(" Blank Gamemode by your name here");
  23. print("----------------------------------\n");
  24. }
  25.  
  26.  
  27.  
  28. public OnGameModeInit()
  29. {
  30. // Don't use these lines if it's a filterscript
  31. SetGameModeText("Blank Script");
  32. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  33. LoadAds();
  34. return 1;
  35. }
  36.  
  37. public OnGameModeExit()
  38. {
  39. return 1;
  40. }
  41.  
  42. public OnPlayerRequestClass(playerid, classid)
  43. {
  44. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  45. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  46. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  47. return 1;
  48. }
  49.  
  50. public OnPlayerCommandText(playerid, cmdtext[])
  51. {
  52. if (strcmp("/ads", cmdtext, true, 10) == 0)
  53. {
  54. ShowPlayerDialog(playerid,1, DIALOG_STYLE_INPUT, "Subject", "Subject Enter Ads:", "Login", "Cancel");
  55. return 1;
  56. }
  57. if (strcmp("/sads", cmdtext, true, 10) == 0)
  58. {
  59. SaveAds();
  60. return 1;
  61. }
  62.  
  63. return 0;
  64. }
  65.  
  66.  
  67. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  68. {
  69. if(dialogid == 1)
  70. {
  71. if(response)
  72. {
  73. if(!strlen(inputtext)) return SendClientMessage(playerid, 1, "ERROR: You must enter something!");
  74. if(strlen(inputtext) > 19) return SendClientMessage(playerid, 1, "ERROR: 20 Greater");
  75. MoveAds();
  76. AdsInfo[0][Sub] = strval(inputtext);
  77. ShowPlayerDialog(playerid,2, DIALOG_STYLE_INPUT, "ADS", "Enter Ads:", "Login", "Cancel");
  78. }
  79. }
  80. if(dialogid == 2)
  81. {
  82. if(response)
  83. {
  84. new name[MAX_PLAYERS];
  85. if(!strlen(inputtext)) return SendClientMessage(playerid, 1, "ERROR: You must enter something!");
  86. if(strlen(inputtext) > 66) return SendClientMessage(playerid, 1, "ERROR: 66 Greater");
  87. AdsInfo[0][Advert] = strval(inputtext);
  88. GetPlayerName(playerid, name, sizeof(name));
  89. AdsInfo[0][Placeby] = strval(name);
  90.  
  91. }
  92. }
  93. return 1;
  94. }
  95.  
  96. LoadAds()
  97. {
  98. if(!fexist("Ads.cfg")) return 1;
  99. new
  100. szFileStr[512],
  101. iIndex,
  102. File: iFileHandle = fopen("Ads.cfg", io_read);
  103.  
  104. while (iIndex < sizeof(AdsInfo) && fread(iFileHandle, szFileStr)) {
  105. sscanf(szFileStr, "p<|>s[20]s[128]s[24]",
  106. AdsInfo[iIndex][Sub],
  107. AdsInfo[iIndex][Advert],
  108. AdsInfo[iIndex][Placeby]
  109. );
  110. ++iIndex;
  111. }
  112. return fclose(iFileHandle);
  113. }
  114.  
  115. SaveAds()
  116. {
  117. new idx;
  118. new File: file2;
  119. while (idx < sizeof(AdsInfo))
  120. {
  121. new coordsstring[512];
  122. format(coordsstring, sizeof(coordsstring), "%s|%s|%s\n",
  123. AdsInfo[idx][Sub],
  124. AdsInfo[idx][Advert],
  125. AdsInfo[idx][Placeby]);
  126. if(idx == 0)
  127. {
  128. file2 = fopen("Ads.cfg", io_write);
  129. }else
  130. {
  131. file2 = fopen("Ads.cfg", io_append);
  132. }
  133. fwrite(file2, coordsstring);
  134. idx++;
  135. fclose(file2);
  136. }
  137. return 1;
  138. }
  139. MoveAds(){
  140. new Subs[20], Adve[128], Placer[24],iIndex;
  141. while (iIndex < 15){
  142. Subs = strval(AdsInfo[iIndex][Sub]);
  143. Adve = strval(AdsInfo[iIndex][Advert]);
  144. Placer = strval(AdsInfo[iIndex][Placeby]);
  145. ++iIndex;
  146. AdsInfo[iIndex][Sub] = strval(Subs);
  147. AdsInfo[iIndex][Advert] = strval(Adve);
  148. AdsInfo[iIndex][Placeby] = strval(Placer);
  149. }
  150. return 1;
  151. }
Advertisement
Add Comment
Please, Sign In to add comment