Advertisement
Guest User

crpg.pwn

a guest
Jan 25th, 2017
148
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <dfile>
  3. #include <sscanf2>
  4. #include <nfunk>
  5.  
  6. #define FOLDERZAPISU "/Konta/" // Gdzie zapisywane są konta
  7. #define PLAYERMARKERRANGE 250 // Z jakiej odleglosci ma byc widziany marker (pickup)
  8. #define MESSAGERANGE 30 // Z jakiej odleglosci ma byc widziany czat loklany
  9. #define NAMETAGSRANGE 30 // Z jakiej odleglosci ma byc widziany name tag
  10.  
  11. new Text:Nazwa;
  12. new Text:Panel;
  13. new Text:LoginBox;
  14. new Text:LoginButton;
  15. new Text:RegisterBox;
  16. new Text:RegisterButton;
  17. new Text:ExitBox;
  18. new Text:ExitButton;
  19.  
  20. enum Graczyk
  21. {
  22. cammovcount,
  23. Wiek,
  24. Miasto,
  25. Plec
  26. };
  27. new Gracz[MAX_PLAYERS][Graczyk];
  28. new Text3D:Gracz3DText[MAX_PLAYERS];
  29.  
  30. /* Rangi
  31. 7 = Zarzad
  32. 6 = Administrator
  33. 5 = GameMaster
  34. 4 = Support
  35. 3 = Moderator
  36. 2 = Premium
  37. 1 = Gracz
  38. 0 = Zbanowany
  39. */
  40.  
  41. main
  42. ()
  43. {}
  44.  
  45. public OnGameModeInit()
  46. {
  47. //Ustawienia serwera
  48. ShowNameTags(false);
  49. ShowPlayerMarkers(1);
  50. LimitPlayerMarkerRadius(PLAYERMARKERRANGE);
  51. SetGameModeText("c-rp");
  52.  
  53. //TextDrawy uwaaga duże ich bo się dziwnie bugujo xd
  54.  
  55. Nazwa = TextDrawCreate(434.500000, 8.166609, "countyRolePlay"); // nazwa serwera panel
  56. TextDrawLetterSize(Nazwa, 0.725499, 2.947503);
  57. TextDrawAlignment(Nazwa, 1);
  58. TextDrawColor(Nazwa, -1);
  59. TextDrawSetShadow(Nazwa, 0);
  60. TextDrawSetOutline(Nazwa, 2);
  61. TextDrawBackgroundColor(Nazwa, 51);
  62. TextDrawFont(Nazwa, 0);
  63. TextDrawSetProportional(Nazwa, 1);
  64.  
  65. Panel = TextDrawCreate(364.000000, 1.500000, "usebox"); // sam panel
  66. TextDrawLetterSize(Panel, 0.000000, 49.396297);
  67. TextDrawTextSize(Panel, 637.500000, 0.000000);
  68. TextDrawAlignment(Panel, 1);
  69. TextDrawColor(Panel, 0);
  70. TextDrawUseBox(Panel, true);
  71. TextDrawBoxColor(Panel, 102);
  72. TextDrawSetShadow(Panel, 0);
  73. TextDrawSetOutline(Panel, 0);
  74. TextDrawFont(Panel, 0);
  75.  
  76. LoginBox = TextDrawCreate(580.000000, 153.166625, "usebox"); // LOGIN box
  77. TextDrawLetterSize(LoginBox, 0.000000, 4.800000);
  78. TextDrawTextSize(LoginBox, 434.000000, 0.000000);
  79. TextDrawAlignment(LoginBox, 1);
  80. TextDrawColor(LoginBox, 0);
  81. TextDrawUseBox(LoginBox, true);
  82. TextDrawBoxColor(LoginBox, 255);
  83. TextDrawSetShadow(LoginBox, 0);
  84. TextDrawSetOutline(LoginBox, 0);
  85. TextDrawFont(LoginBox, 0);
  86. TextDrawSetSelectable(LoginBox, true);
  87.  
  88. LoginButton = TextDrawCreate(463.500000, 162.166671, "ZALOGUJ"); // Zaloguj Przycisk
  89. TextDrawLetterSize(LoginButton, 0.652499, 2.410834);
  90. TextDrawAlignment(LoginButton, 1);
  91. TextDrawColor(LoginButton, -1);
  92. TextDrawSetShadow(LoginButton, 0);
  93. TextDrawSetOutline(LoginButton, 1);
  94. TextDrawBackgroundColor(LoginButton, 51);
  95. TextDrawFont(LoginButton, 3);
  96. TextDrawSetProportional(LoginButton, 1);
  97. TextDrawSetSelectable(LoginButton, true);
  98.  
  99. RegisterBox = TextDrawCreate(580.000000, 239.499954, "usebox"); // REGISTER box
  100. TextDrawLetterSize(RegisterBox, 0.000000, 4.738888);
  101. TextDrawTextSize(RegisterBox, 434.000000, 0.000000);
  102. TextDrawAlignment(RegisterBox, 1);
  103. TextDrawColor(RegisterBox, 0);
  104. TextDrawUseBox(RegisterBox, true);
  105. TextDrawBoxColor(RegisterBox, 255);
  106. TextDrawSetShadow(RegisterBox, 0);
  107. TextDrawSetOutline(RegisterBox, 0);
  108. TextDrawFont(RegisterBox, 0);
  109. TextDrawSetSelectable(RegisterBox, true);
  110.  
  111. RegisterButton = TextDrawCreate(443.000000, 247.916641, "ZAREJESTRUJ"); // Zarejestruj przycisk
  112. TextDrawLetterSize(RegisterButton, 0.585999, 2.626669);
  113. TextDrawAlignment(RegisterButton, 1);
  114. TextDrawColor(RegisterButton, -1);
  115. TextDrawSetShadow(RegisterButton, 0);
  116. TextDrawSetOutline(RegisterButton, 1);
  117. TextDrawBackgroundColor(RegisterButton, 51);
  118. TextDrawFont(RegisterButton, 3);
  119. TextDrawSetProportional(RegisterButton, 1);
  120. TextDrawSetSelectable(RegisterButton, true);
  121.  
  122. ExitBox = TextDrawCreate(580.000000, 370.750061, "usebox"); // FAQ box
  123. TextDrawLetterSize(ExitBox, 0.000000, -5.631481);
  124. TextDrawTextSize(ExitBox, 434.000000, 0.000000);
  125. TextDrawAlignment(ExitBox, 1);
  126. TextDrawColor(ExitBox, 0);
  127. TextDrawUseBox(ExitBox, true);
  128. TextDrawBoxColor(ExitBox, 255);
  129. TextDrawSetShadow(ExitBox, 0);
  130. TextDrawSetOutline(ExitBox, 0);
  131. TextDrawFont(ExitBox, 0);
  132. TextDrawSetSelectable(ExitBox, true);
  133.  
  134. ExitButton = TextDrawCreate(485.500000, 332.499908, "FAQ"); // Faq przycisk
  135. TextDrawLetterSize(ExitButton, 0.785000, 2.410833);
  136. TextDrawAlignment(ExitButton, 1);
  137. TextDrawColor(ExitButton, -1);
  138. TextDrawSetShadow(ExitButton, 0);
  139. TextDrawSetOutline(ExitButton, 1);
  140. TextDrawBackgroundColor(ExitButton, 51);
  141. TextDrawFont(ExitButton, 3);
  142. TextDrawSetProportional(ExitButton, 1);
  143. TextDrawSetSelectable(ExitButton, true);
  144.  
  145.  
  146. print("[GM] Uruchamiam i sprawdzam...");
  147. if(!dfile_FileExists(FOLDERZAPISU))
  148. {
  149. print("[GM] Folder z kontami nie zostal odnaleziony! Wylaczam serwer");
  150. SendRconCommand("exit");
  151. }
  152. else
  153. {
  154. print("[GM] Folder został odnaleziony, serwer zostal uruchomiony!");
  155. }
  156. return 1;
  157. }
  158.  
  159. public OnGameModeExit()
  160. {
  161. TextDrawDestroy(Panel);
  162. TextDrawDestroy(Nazwa);
  163. TextDrawDestroy(LoginBox);
  164. TextDrawDestroy(LoginButton);
  165. TextDrawDestroy(RegisterBox);
  166. TextDrawDestroy(RegisterButton);
  167. TextDrawDestroy(ExitBox);
  168. TextDrawDestroy(ExitButton);
  169. return 1;
  170. }
  171.  
  172. public OnPlayerConnect(playerid)
  173. {
  174. new string[500];
  175. new pName[MAX_PLAYER_NAME];
  176. GetPlayerName(playerid, pName, sizeof(pName));
  177. format(string, sizeof(string), "%s (ID: %i) Reputacja: 0",pName, playerid);
  178. Gracz3DText[playerid] = Create3DTextLabel(string, 0x807D7DFF, 0.0,0.0,0.0, NAMETAGSRANGE, 0);
  179. Attach3DTextLabelToPlayer(Gracz3DText[playerid],playerid, 0.0,0.0,0.0);
  180.  
  181. // Panel Logowania
  182. TextDrawShowForPlayer(playerid, Nazwa);
  183. TextDrawShowForPlayer(playerid, Panel);
  184. TextDrawShowForPlayer(playerid, LoginBox);
  185. TextDrawShowForPlayer(playerid, LoginButton);
  186. TextDrawShowForPlayer(playerid, RegisterBox);
  187. TextDrawShowForPlayer(playerid, RegisterButton);
  188. TextDrawShowForPlayer(playerid, ExitBox);
  189. TextDrawShowForPlayer(playerid, ExitButton);
  190.  
  191. return 1;
  192. }
  193.  
  194. public OnPlayerDisconnect(playerid, reason)
  195. {
  196. Delete3DTextLabel(Gracz3DText[playerid]);
  197. return 1;
  198. }
  199.  
  200. public OnPlayerRequestClass(playerid, classid)
  201. {
  202.  
  203. return 1;
  204. }
  205.  
  206. public OnPlayerSpawn(playerid)
  207. {
  208. TextDrawHideForPlayer(playerid, Panel);
  209. TextDrawHideForPlayer(playerid, Nazwa);
  210. TextDrawHideForPlayer(playerid, LoginButton);
  211. TextDrawHideForPlayer(playerid, LoginBox);
  212. TextDrawHideForPlayer(playerid, RegisterButton);
  213. TextDrawHideForPlayer(playerid, RegisterBox);
  214. TextDrawHideForPlayer(playerid, ExitButton);
  215. TextDrawHideForPlayer(playerid, ExitBox);
  216. return 1;
  217. }
  218.  
  219. public OnPlayerText(playerid, text[])
  220. {
  221. new pName[MAX_PLAYER_NAME];
  222. new Wiadomosc[500];
  223. GetPlayerName(playerid, pName, sizeof(pName));
  224. format(Wiadomosc, sizeof(Wiadomosc), "%s mowi: %s",pName, text);
  225. SendClientMessageInRange(playerid, Wiadomosc, 0x676767FF, MESSAGERANGE);
  226. SetPlayerChatBubble(playerid, text, 0xFF0000FF, 10,10000);
  227. return 1;
  228. }
  229.  
  230. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  231. {
  232. if(newkeys == KEY_FIRE)
  233. {
  234. TextDrawShowForPlayer(playerid, LoginButton);
  235. TextDrawShowForPlayer(playerid, LoginBox);
  236. TextDrawShowForPlayer(playerid, RegisterButton);
  237. TextDrawShowForPlayer(playerid, RegisterBox);
  238. TextDrawShowForPlayer(playerid, ExitButton);
  239. TextDrawShowForPlayer(playerid, ExitBox);
  240. SelectTextDraw(playerid, 0xFF4040AA);
  241. }
  242. return 1;
  243. }
  244.  
  245. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  246. {
  247. if(_:clickedid != INVALID_TEXT_DRAW) //
  248. {
  249. if(clickedid == LoginBox)
  250. {
  251. ShowPlayerDialog(playerid, 123, DIALOG_STYLE_MSGBOX, "TEST", "Textdraw działa poprawnie!", "OK", "OK");
  252. }
  253. else if(clickedid == LoginButton)
  254. {
  255. ShowPlayerDialog(playerid, 1234, DIALOG_STYLE_MSGBOX, "TEST", "Textdraw działa poprawnie!", "OK", "OK");
  256. }
  257. else if(clickedid == RegisterBox)
  258. {
  259. SendClientMessage(playerid, 0x000000FF, "Działa poprawnie");
  260. }
  261. else if(clickedid == RegisterButton)
  262. {
  263. SendClientMessage(playerid, 0x000000FF, "Działa poprawnie");
  264. }
  265. else if(clickedid == ExitBox)
  266. {
  267. SendClientMessage(playerid, 0x000000FF, "Działa poprawnie");
  268. }
  269. else if(clickedid == ExitButton)
  270. {
  271. SendClientMessage(playerid, 0x000000FF, "Działa poprawnie");
  272. }
  273. }
  274. return 1;
  275. }
  276.  
  277. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  278. {
  279.  
  280. return 1;
  281. }
  282.  
  283. stock SendClientMessageInRange(playerid, string[], color, Float:range)
  284. {
  285. new Float:X, Float:Y, Float:Z;
  286. GetPlayerPos(playerid, X, Y, Z);
  287. for(new i; i <= GetPlayerPoolSize(); i++)
  288. if(IsPlayerConnected(i))
  289. if(IsPlayerInRangeOfPoint(i, range, X, Y, Z))
  290. SendClientMessage(i, color, string);
  291. return 1;
  292. }
  293.  
  294. stock Register(playerid,haslo[])
  295. {
  296. new string[500];
  297. new pName[MAX_PLAYER_NAME];
  298. GetPlayerName(playerid, pName, sizeof(pName));
  299. format(string, sizeof(string), "/Konta/%s.ini",pName);
  300. dfile_Create(string);
  301.  
  302. dfile_MultiSet(string, "Haslo",haslo);
  303. dfile_MultiSet(string, "Kasa", 250);
  304. dfile_MultiSet(string, "Ranga", 1); // Spis rang jest na samej górze gm!!
  305. dfile_MultiSet(string, "Wiek", 0);
  306. dfile_MultiSet(string, "Plec", 0);
  307.  
  308. SendClientMessage(playerid, 000000FF, "Konto zostalo pomyslnie zalozone !");
  309. return 1;
  310. }
  311.  
  312. stock WczytajGracza(playerid)
  313. {
  314. new string[500];
  315. new pName[MAX_PLAYER_NAME];
  316. GetPlayerName(playerid, pName, sizeof(pName));
  317. format(string, sizeof(string), "/Konta/%s.ini",pName);
  318. //
  319.  
  320. ResetPlayerMoney(playerid);
  321. GivePlayerMoney(playerid, dfile_IsSet(string, "Kasa"));
  322. Gracz[playerid][Ranga] = dfile_IsSet(string, "Ranga");
  323. Gracz[playerid][Wiek] = dfile_IsSet(string, "Wiek");
  324. Gracz[playerid][Plec] = dfile_IsSett(string, "Plec");
  325.  
  326. return 1;
  327. }
  328.  
  329. stock ZapiszGracza(playerid)
  330. {
  331. new string[500];
  332. new pName[MAX_PLAYER_NAME];
  333. GetPlayerName(playerid, pName, sizeof(pName));
  334. format(string, sizeof(string), "/Konta/%s.ini",pName);
  335.  
  336. dfile_IsSet(string, "Kasa", GetPlayerMoney(playerid));
  337. dfile_IsSet(string, "Ranga", Gracz[playerid][Wiek]);
  338. dfile_IsSet(string, "Wiek", Gracz[playerid][Wiek]);
  339. dfile_IsSet(string, "Plec", Gracz[playerid][Plec]);
  340.  
  341. return 1;
  342. }
  343.  
  344. public OnPlayerCommandText(playerid, cmdtext[])
  345. {
  346. if(!strcmp(cmdtext, "/help", true))
  347. {
  348.  
  349. return 1;
  350. }
  351. return 0;
  352.  
  353. }
Advertisement
RAW Paste Data Copied
Advertisement