Guest User

Untitled

a guest
Apr 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.77 KB | None | 0 0
  1. //////////////////////////////////////////////
  2. // Unknown Roleplay //
  3. // Type: Roleplay //
  4. // Author: Jake Johnson & David W. //
  5. // Licensing: CCC //
  6. // Completion time: Unknown //
  7. // Bugs: None at this time. //
  8. //////////////////////////////////////////////
  9.  
  10.  
  11.  
  12. //////////////////////////
  13. /* Includes */
  14. //////////////////////////
  15.  
  16. #include <a_samp>
  17. #include <CMD>
  18. #include <foreach>
  19. #include <dini>
  20. #include <dutils>
  21.  
  22. //////////////////////////////
  23. /* Color defines */
  24. //////////////////////////////
  25.  
  26. #define white 0xFFFFFFFAA
  27.  
  28. //////////////////////////////////////
  29. /* Other defines[Random] */
  30. //////////////////////////////////////
  31.  
  32. #define gmdev "Jake Johnson"
  33. #define gmver "Version 1.0.0"
  34. #define gmstability "STABLE"
  35. #define gmgravity "0.008"
  36.  
  37. #define SCM SendClientMessage
  38. #define SPP SetPlayerPos
  39.  
  40. #define mapname "San Andreas"
  41.  
  42. #define chatcmds 1
  43. #define chatcmds1 10
  44. #define chatcmds2 2
  45. #define chatcmds3 3
  46. #define chatcmds4 4
  47. #define chatcmds5 5
  48. #define chatcmds6 6
  49. #define chatcmds7 7
  50. #define chatcmds8 8
  51. #define chatcmds9 9
  52. #define RequestClass 10
  53. #define Login 11
  54. #define Register 12
  55. #define RegistrationSuccess 13
  56.  
  57. forward waitdisplay();
  58. forward OnPlayerLogin(playerid, password[]);
  59. forward OnPlayerRegister(playerid, password[]);
  60. forward OnPlayerUpdate(playerid);
  61.  
  62. //////////////////////////////////////
  63. /* Main Defines [Random] */
  64. //////////////////////////////////////
  65.  
  66. new LoggedIn[MAX_PLAYERS];
  67. new LoginTries[MAX_PLAYERS];
  68. new PlayerAccount[MAX_PLAYERS];
  69. new Typed[MAX_PLAYERS][64];
  70.  
  71. enum PlayerEnumeration
  72. {
  73. Level,
  74. Password,
  75. Money,
  76. }
  77. new PI[MAX_PLAYERS][PlayerEnumeration];
  78.  
  79. public OnGameModeInit()
  80. {
  81. return 1;
  82. }
  83.  
  84.  
  85.  
  86. stock playerfirstname(playerid)
  87. {
  88. new
  89. namestring[2][MAX_PLAYER_NAME],
  90. name[MAX_PLAYER_NAME];
  91.  
  92. GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  93. split(name, namestring, '_');
  94. return namestring[0];
  95. }
  96.  
  97. stock split(const strsrc[], strdest[][], delimiter)
  98. {
  99. new i, li;
  100. new aNum;
  101. new len;
  102. while(i <= strlen(strsrc)){
  103. if(strsrc[i]==delimiter || i==strlen(strsrc)){
  104. len = strmid(strdest[aNum], strsrc, li, i, 128);
  105. strdest[aNum][len] = 0;
  106. li = i+1;
  107. aNum++;
  108. }
  109. i++;
  110. }
  111. return 1;
  112. }
  113.  
  114. Log(sz_fileName[], sz_input[]) {
  115.  
  116. new
  117. sz_logEntry[156],
  118. i_dateTime[2][3],
  119. File: fileHandle = fopen(sz_fileName, io_append);
  120.  
  121. gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
  122. getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
  123.  
  124. format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
  125. fwrite(fileHandle, sz_logEntry);
  126. return fclose(fileHandle);
  127. }
  128.  
  129.  
  130.  
  131. public waitdisplay()
  132. {
  133. foreach(Player, i)
  134. {
  135. ShowPlayerDialog(i, chatcmds, DIALOG_STYLE_LIST, "Server Commands", "General Commands\nNulled\nNulled\nNulled\nNulled\nNulled\nNulled\nNulled", "Select", "Cancel");
  136. }
  137. }
  138.  
  139. public OnPlayerCommandPerformed(playerid, cmdtext[], success)
  140. {
  141. if(!success)
  142. {
  143. new string[500];
  144. format(string, sizeof(string), "{F81414}[Info]:{FFFFFF} That command is invalid - (%s).", cmdtext);
  145. SCM(playerid, white, string);
  146. }
  147. return 1;
  148. }
  149.  
  150. public OnPlayerCommandReceived(playerid, cmdtext[])
  151. {
  152. new pname[MAX_PLAYER_NAME];
  153. new string[500];
  154. GetPlayerName(playerid, pname, sizeof(pname));
  155. format(string, sizeof(string), "[Logging]: %s has typed a command - (%s).", pname, cmdtext);
  156. print(string);
  157. Log("logging/cmd.log", string);
  158. return 1;
  159. }
  160.  
  161.  
  162. public OnPlayerConnect(playerid)
  163. {
  164. new connectstring[128];
  165. new name[MAX_PLAYER_NAME];
  166. GetPlayerName(playerid, name, sizeof(name));
  167. PI[playerid][Level] = 0;
  168. PI[playerid][Money] = 0;
  169. format(connectstring, sizeof(connectstring), "%s.ini", name);
  170. if(dini_Exists(connectstring))
  171. {
  172. PlayerAccount[playerid] = 1;
  173. }
  174. else
  175. {
  176. PlayerAccount[playerid] = 0;
  177. }
  178. return 1;
  179. }
  180.  
  181. public OnPlayerRegister(playerid, password[])
  182. {
  183. if(IsPlayerConnected(playerid))
  184. {
  185. new file[64];
  186. new playername3[MAX_PLAYER_NAME];
  187. GetPlayerName(playerid, playername3, sizeof(playername3));
  188. format(file, sizeof(file), "%s.ini", playername3);
  189.  
  190. if(dini_Exists(file))
  191. {
  192. return SCM(playerid, white,"Error: This account is already registered.");
  193. }
  194. else
  195. {
  196. dini_Create(file);
  197. new password2 = num_hash(password);
  198. PI[playerid][Password] = password2;
  199. dini_IntSet(file, "Password",password2);
  200. dini_IntSet(file, "Level",PI[playerid][Level]);
  201. dini_IntSet(file, "Money",PI[playerid][Money]);
  202. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,"Registration","You've sucessfully registered!\nPlease type your password below to login","Login","Quit");
  203. }
  204. }
  205. return 1;
  206. }
  207.  
  208. public OnPlayerUpdate(playerid)
  209. {
  210. if(IsPlayerConnected(playerid))
  211. {
  212. if(LoggedIn[playerid] == 1)
  213. {
  214. new string3[64];
  215. new playername3[MAX_PLAYER_NAME];
  216. GetPlayerName(playerid, playername3, sizeof(playername3));
  217. format(string3, sizeof(string3), "%s.ini", playername3);
  218.  
  219. dini_IntSet(string3, "Password",PI[playerid][Password]);
  220. dini_IntSet(string3, "Level",PI[playerid][Level]);
  221. dini_IntSet(string3, "Money",PI[playerid][Money]);
  222. }
  223. }
  224. return 1;
  225. }
  226.  
  227. public OnPlayerLogin(playerid,password[])
  228. {
  229. new string2[64];
  230. new playername3[MAX_PLAYER_NAME];
  231. GetPlayerName(playerid, playername3, sizeof(playername3));
  232.  
  233. format(string2, sizeof(string2), "%s.ini", playername3);
  234.  
  235. if (dini_Exists(string2))
  236. {
  237. new password2 = num_hash(password);
  238. if(dini_Int(string2,"Password") == password2)
  239. {
  240. PI[playerid][Password] = dini_Int(string2,"Password");
  241. PI[playerid][Level] = dini_Int(string2,"Level");
  242. PI[playerid][Money] = dini_Int(string2,"Money");
  243. }
  244. else
  245. {
  246. LoginTries[playerid] += 1;
  247. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,"Invalid password","That password is invalid.\nPlease enter your password below:","Login","Quit");
  248. if(LoginTries[playerid] == 3)
  249. {
  250. SCM(playerid, white, "You've been kicked for too many invalid password attempts.");
  251. Kick(playerid);
  252. }
  253. return 1;
  254. }
  255. }
  256. return 1;
  257. }
  258. public OnPlayerRequestClass(playerid, classid)
  259. {
  260. ShowPlayerDialog(playerid, RequestClass, DIALOG_STYLE_MSGBOX,"Test1","Test2","Accept","Refuse");
  261. SetPlayerCameraPos(playerid, 1890.1014,-1194.7969,25.8091);
  262. SetPlayerCameraLookAt(playerid, 1933.4393,-1196.2479,18.8163);
  263. return 1;
  264. }
  265.  
  266. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  267. {
  268. if(dialogid == chatcmds)
  269. {
  270. if(response)
  271. {
  272. if(listitem == 0)
  273. {
  274. ShowPlayerDialog(playerid, chatcmds1, DIALOG_STYLE_MSGBOX, "General Commands", " ", "Thanks", "Cancel");
  275. }
  276. if(listitem == 1)
  277. {
  278. ShowPlayerDialog(playerid, chatcmds2, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
  279. }
  280. if(listitem == 2)
  281. {
  282. ShowPlayerDialog(playerid, chatcmds3, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
  283. }
  284. if(listitem == 3)
  285. {
  286. ShowPlayerDialog(playerid, chatcmds4, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
  287. }
  288. if(listitem == 4)
  289. {
  290. ShowPlayerDialog(playerid, chatcmds5, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
  291. }
  292. if(listitem == 5)
  293. {
  294. ShowPlayerDialog(playerid, chatcmds6, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
  295. }
  296. if(listitem == 6)
  297. {
  298. ShowPlayerDialog(playerid, chatcmds7, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
  299. }
  300. if(listitem == 7)
  301. {
  302. ShowPlayerDialog(playerid, chatcmds8, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
  303. }
  304. if(listitem == 8)
  305. {
  306. ShowPlayerDialog(playerid, chatcmds9, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
  307. }
  308. }
  309. }
  310. if(dialogid == RequestClass)
  311. {
  312. if(response)
  313. {
  314. new playername[MAX_PLAYER_NAME];
  315. GetPlayerName(playerid, playername, sizeof(playername));
  316. new string[64];
  317. format(string, sizeof(string), "%s.ini", playername);
  318. if (dini_Exists(string))
  319. {
  320. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,"Server Login","Welcome back!\nPlease enter your password below to login:","Login","Quit");
  321. }
  322. else
  323. {
  324. ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT,"Registration", "Welcome to our server!\nPlease type a password below to register here:","Register","Quit");
  325. }
  326. }
  327. else
  328. {
  329. SCM(playerid, white, "You've been kicked due to hitting 'Quit'.");
  330. Kick(playerid);
  331. }
  332. }
  333. if(dialogid == Login)
  334. {
  335. if(response)
  336. {
  337. strmid(Typed[playerid], inputtext, 0, strlen(inputtext), 255);
  338. if(!strcmp(Typed[playerid], "None", true))
  339. {
  340. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,"Server Login","Welcome back!\nPlease enter your password below to login:","Login","Quit");
  341. }
  342. else
  343. {
  344. OnPlayerLogin(playerid, inputtext);
  345. }
  346. }
  347. else
  348. {
  349. Kick(playerid);
  350. }
  351. }
  352. if(dialogid == Register)
  353. {
  354. if(response == 1)
  355. {
  356. new sendername[MAX_PLAYER_NAME];
  357. GetPlayerName(playerid, sendername, sizeof(sendername));
  358. new string[512];
  359. format(string, sizeof(string),"Thanks for registering, %s\nYou've been given 500 dollars and level 1 to start you off.",sendername);
  360. ShowPlayerDialog(playerid, RegistrationSuccess, DIALOG_STYLE_MSGBOX, "Sucessfull Registration",string,"Ok","");
  361. GivePlayerMoney(playerid, 500);
  362. SetPlayerScore(playerid, 1);
  363. OnPlayerRegister(playerid, inputtext);
  364. }
  365. else
  366. {
  367. Kick(playerid);
  368. }
  369. }
  370. return 0;
  371. }
  372.  
  373. //////////////////////////////////////
  374. /* Commands[ZCMD + sscanf] */
  375. //////////////////////////////////////
  376. // format format(string, sizeof(string)
  377.  
  378.  
  379.  
  380. CMD:cmds(playerid, params[])
  381. {
  382. return cmd_commands(playerid, params);
  383. }
  384. CMD:commands(playerid, params[])
  385. {
  386. new string[32];
  387. format(string, sizeof(string), "Our commands are as followed, %s.", playerfirstname(playerid));
  388. SCM(playerid, white, string);
  389. SetTimer("waitdisplay", 5000, false);
  390. return 1;
  391. }
Add Comment
Please, Sign In to add comment