Guest User

Untitled

a guest
Jan 29th, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.23 KB | None | 0 0
  1. //============================================================================//
  2. // Basic GameMode Script //
  3. //----------------------------------------------------------------------------//
  4. // By SaNeLSANY //
  5. //============================================================================//
  6.  
  7. //============================================================================// INCLUDE
  8.  
  9. #include <a_samp>
  10. #include <sscanf2>
  11. #include <streamer>
  12. #include <YSI\y_ini>
  13. #include <zcmd>
  14. #include <foreach>
  15.  
  16. //============================================================================//
  17.  
  18. //============================================================================// DEFINE
  19.  
  20.  
  21. // COLORS
  22.  
  23. #define COLOR_PINK 0xFFC0CBFF
  24. #define COLOR_RED 0xFF0000FF
  25. #define COLOR_GREEN 0x008000FF
  26. #define COLOR_DARKBLUE 0x00008BFF
  27. #define COLOR_CADETBLUE 0x5F9EA0FF
  28. #define COLOR_LIGHTBLUE 0xADD8E6FF
  29. #define COLOR_YELLOW 0xECD400F6
  30. #define COLOR_LIGHTGREEN 0x90EE90FF
  31. #define COLOR_PEACHPUFF 0xFFDAB9FF
  32. #define LIGHTBLUE2 0xF6BB0AA
  33. #define COLOR_GREY 0x808080FF
  34. #define COLOR_ORANGE 0xFFA500FF
  35. #define COLOR_BISQUE 0xFFE4C4FF
  36. #define COLOR_BLANCHEDALMOND 0xFFEBCDFF
  37. #define COLOR_BLACK 0x000000AA
  38.  
  39. #define CYELLOW "{9DBD1E}"
  40. #define CORANGE "{E68C0E}"
  41. #define CBLUE "{39AACC}"
  42. #define CLGREEN "{30DB52}"
  43. #define CDGREEN "{6FA828}"
  44. #define CWHITE "{FFFFFF}"
  45. #define CREDISH "{CF0C43}"
  46. #define CRED "{FF0000}"
  47. #define CLBLUE "{55C2CF}"
  48. #define CCADET "{5F9EA0}"
  49. #define CPINK "{FC08CB}"
  50. #define CDBLUE "{1500FF}"
  51. #define CAQUA "{5CFFE9}"
  52. #define CGREY "{7D8584}"
  53. #define CMAROON "{912514}"
  54. #define CCORAL "{FF7F50}"
  55. #define CRACE "{F2DDC4}"
  56. #define CRACE2 "{2CC900}"
  57. #define CGAME1 "{E8DB20}"
  58. #define CGAME2 "{BA80BA}"
  59. #define CMINIG1 "{648832}"
  60. #define CMINIG2 "{4F927F}"
  61.  
  62. // DIALOGS
  63.  
  64. #define DIALOG_REGISTER 0
  65. #define DIALOG_LOGIN 1
  66.  
  67. // OTHER
  68.  
  69. #define SCM SendClientMessage
  70. #define USER_PATH "/Players/%s.ini"
  71. #define INI_Exists(%0) fexist(%0)
  72.  
  73. //============================================================================//
  74.  
  75. //============================================================================// NEW
  76. //============================================================================//
  77.  
  78. //============================================================================// FORWARD
  79. //============================================================================//
  80.  
  81. //============================================================================// ENUM
  82.  
  83. enum pInfo
  84. {
  85. pPassword[124],
  86. pKills,
  87. pDeaths,
  88. pAdmin,
  89. pLevel,
  90. pSkin,
  91. pMoney,
  92. pLogged
  93. };
  94. new PlayerInfo[MAX_PLAYERS][pInfo];
  95.  
  96. //============================================================================//
  97.  
  98. main()
  99. {
  100. print("\n----------------------------------");
  101. print(" Blank GameMode Script By SaNeLSANY ");
  102. print("----------------------------------\n");
  103. }
  104.  
  105.  
  106. public OnGameModeInit()
  107. {
  108. UsePlayerPedAnims();
  109. SetGameModeText("| Blank GameMode |");
  110. return 1;
  111. }
  112.  
  113. public OnGameModeExit()
  114. {
  115. return 1;
  116. }
  117.  
  118. public OnPlayerRequestClass(playerid, classid)
  119. {
  120. return 1;
  121. }
  122.  
  123. public OnPlayerConnect(playerid)
  124. {
  125. PlayerInfo[playerid][pLogged] = 0;
  126. new text[1024], strText[104];
  127. format(strText, 35, USER_PATH, PlayerName(playerid));
  128. if(!INI_Exists(strText))
  129. {
  130. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""#CCADET"Account Registration", ""CYELLOW"Hello! "CBLUE"You must register to play on this server!", "Register", "Leave");
  131. SCM(playerid, COLOR_BLACK, "");
  132. SCM(playerid, COLOR_BLACK, "");
  133. SCM(playerid, COLOR_BLACK, "");
  134. SCM(playerid, COLOR_BLACK, "");
  135. SCM(playerid, COLOR_BLACK, "");
  136. SCM(playerid, COLOR_BLACK, "");
  137. SCM(playerid, COLOR_BLACK, "");
  138. SCM(playerid, COLOR_BLACK, "");
  139. SCM(playerid, COLOR_BLACK, "");
  140. SCM(playerid, COLOR_BLACK, "");
  141. SCM(playerid, COLOR_BLACK, "");
  142. SCM(playerid, COLOR_BLACK, "");
  143. SCM(playerid, COLOR_BLACK, "");
  144. SCM(playerid, COLOR_BLACK, "");
  145. SCM(playerid, COLOR_BLACK, "");
  146. SCM(playerid, COLOR_BLACK, "");
  147. SCM(playerid, COLOR_BLACK, "");
  148. SCM(playerid, COLOR_BLACK, "");
  149. SCM(playerid, COLOR_BLACK, "");
  150. SCM(playerid, COLOR_BLACK, "");
  151. SCM(playerid, COLOR_BLACK, "");
  152. SCM(playerid, COLOR_BLACK, "");
  153. SCM(playerid, COLOR_BLACK, "");
  154. SCM(playerid, COLOR_BLACK, "");
  155. SCM(playerid, COLOR_BLACK, "");
  156. SCM(playerid, COLOR_BLACK, "");
  157. SCM(playerid, COLOR_BLACK, "");
  158. }
  159. else
  160. {
  161. format(text, sizeof(text)," {0095FF}________________________________________________\n\n{FFFFFF}Welcome to {0095FF}Basic GameMode {FFFFFF}server!\n\n\n{0095FF}%s\n{FFFFFF}Your Account are finded\n\n\nPlease enter your password to enter to this server:\n\n{0095FF}________________________________________________", PlayerName(playerid));
  162. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT, "Login",text, "Logiraj","Odustani");
  163. SCM(playerid, COLOR_BLACK, "");
  164. SCM(playerid, COLOR_BLACK, "");
  165. SCM(playerid, COLOR_BLACK, "");
  166. SCM(playerid, COLOR_BLACK, "");
  167. SCM(playerid, COLOR_BLACK, "");
  168. SCM(playerid, COLOR_BLACK, "");
  169. SCM(playerid, COLOR_BLACK, "");
  170. SCM(playerid, COLOR_BLACK, "");
  171. SCM(playerid, COLOR_BLACK, "");
  172. SCM(playerid, COLOR_BLACK, "");
  173. SCM(playerid, COLOR_BLACK, "");
  174. SCM(playerid, COLOR_BLACK, "");
  175. SCM(playerid, COLOR_BLACK, "");
  176. SCM(playerid, COLOR_BLACK, "");
  177. SCM(playerid, COLOR_BLACK, "");
  178. SCM(playerid, COLOR_BLACK, "");
  179. SCM(playerid, COLOR_BLACK, "");
  180. SCM(playerid, COLOR_BLACK, "");
  181. SCM(playerid, COLOR_BLACK, "");
  182. SCM(playerid, COLOR_BLACK, "");
  183. SCM(playerid, COLOR_BLACK, "");
  184. SCM(playerid, COLOR_BLACK, "");
  185. SCM(playerid, COLOR_BLACK, "");
  186. SCM(playerid, COLOR_BLACK, "");
  187. SCM(playerid, COLOR_BLACK, "");
  188. SCM(playerid, COLOR_BLACK, "");
  189. SCM(playerid, COLOR_BLACK, "");
  190. }
  191. return 1;
  192. }
  193.  
  194. public OnPlayerDisconnect(playerid, reason)
  195. {
  196. if(PlayerInfo[playerid][pLogged] == 1)
  197. {
  198. SavePlayer(playerid);
  199. }
  200. return 1;
  201. }
  202.  
  203. public OnPlayerSpawn(playerid)
  204. {
  205. return 1;
  206. }
  207.  
  208. public OnPlayerDeath(playerid, killerid, reason)
  209. {
  210. return 1;
  211. }
  212.  
  213. public OnVehicleSpawn(vehicleid)
  214. {
  215. return 1;
  216. }
  217.  
  218. public OnVehicleDeath(vehicleid, killerid)
  219. {
  220. return 1;
  221. }
  222.  
  223. public OnPlayerText(playerid, text[])
  224. {
  225. return 1;
  226. }
  227. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnPlayerExitVehicle(playerid, vehicleid)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerStateChange(playerid, newstate, oldstate)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerEnterCheckpoint(playerid)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnPlayerLeaveCheckpoint(playerid)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnPlayerEnterRaceCheckpoint(playerid)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnPlayerLeaveRaceCheckpoint(playerid)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnRconCommand(cmd[])
  263. {
  264. return 1;
  265. }
  266.  
  267. public OnPlayerRequestSpawn(playerid)
  268. {
  269. if(PlayerInfo[playerid][pLogged] == 0)
  270. {
  271. SCM(playerid,COLOR_RED,"You must be logged in before spawn");
  272. SetTimerEx("KickPlayer", 300, 0, "d", playerid);
  273. }
  274. return 1;
  275. }
  276.  
  277. public OnObjectMoved(objectid)
  278. {
  279. return 1;
  280. }
  281.  
  282. public OnPlayerObjectMoved(playerid, objectid)
  283. {
  284. return 1;
  285. }
  286.  
  287. public OnPlayerPickUpPickup(playerid, pickupid)
  288. {
  289. return 1;
  290. }
  291.  
  292. public OnVehicleMod(playerid, vehicleid, componentid)
  293. {
  294. return 1;
  295. }
  296.  
  297. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  298. {
  299. return 1;
  300. }
  301.  
  302. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  303. {
  304. return 1;
  305. }
  306.  
  307. public OnPlayerSelectedMenuRow(playerid, row)
  308. {
  309. return 1;
  310. }
  311.  
  312. public OnPlayerExitedMenu(playerid)
  313. {
  314. return 1;
  315. }
  316.  
  317. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  318. {
  319. return 1;
  320. }
  321.  
  322. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  323. {
  324. return 1;
  325. }
  326.  
  327. public OnRconLoginAttempt(ip[], password[], success)
  328. {
  329. return 1;
  330. }
  331.  
  332. public OnPlayerUpdate(playerid)
  333. {
  334. return 1;
  335. }
  336.  
  337. public OnPlayerStreamIn(playerid, forplayerid)
  338. {
  339. return 1;
  340. }
  341.  
  342. public OnPlayerStreamOut(playerid, forplayerid)
  343. {
  344. return 1;
  345. }
  346.  
  347. public OnVehicleStreamIn(vehicleid, forplayerid)
  348. {
  349. return 1;
  350. }
  351.  
  352. public OnVehicleStreamOut(vehicleid, forplayerid)
  353. {
  354. return 1;
  355. }
  356.  
  357. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  358. {
  359. if(dialogid == DIALOG_REGISTER)
  360. {
  361. if(!response)
  362. {
  363. SCM(playerid, COLOR_LIGHTBLUE, "Hey you, you must register to play on this server !");
  364. SetTimerEx("KickPlayer", 300, 0, "d", playerid);
  365. return 1;
  366. }
  367. if(response)
  368. {
  369. if(!strlen(inputtext))
  370. {
  371. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""#CCADET"Account Registration", ""CYELLOW"You must enter a password below to continue!", "Register", "Leave");
  372. return 1;
  373. }
  374. SCM(playerid, COLOR_GREEN, "All right, you are now registered!");
  375. new uFile[35];
  376. format(uFile, 35, USER_PATH, PlayerName(playerid));
  377. new INI:playerFile = INI_Open(uFile);
  378. INI_WriteInt(playerFile,"Password",udb_hash(inputtext));
  379. INI_WriteInt(playerFile, "AdminLVL", PlayerInfo[playerid][pAdmin]);
  380. INI_WriteInt(playerFile, "Money", PlayerInfo[playerid][pMoney]);
  381. INI_WriteInt(playerFile, "Level", PlayerInfo[playerid][pLevel]);
  382. INI_WriteInt(playerFile, "Skin", PlayerInfo[playerid][pSkin]);
  383. INI_Close(playerFile);
  384. PlayerInfo[playerid][pLevel] = 3;
  385. PlayerInfo[playerid][pLogged] = 1;
  386. PlayerInfo[playerid][pMoney] = 1000;
  387. GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
  388. SetPlayerSkin(playerid, 1);
  389. SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
  390. SetSpawnInfo(playerid, 0,PlayerInfo[playerid][pSkin], 1154.0653,-1458.0643,15.7969, 0,0,0,0,0,0,0);
  391. SpawnPlayer(playerid);
  392. }
  393. }
  394. if(dialogid == DIALOG_LOGIN)
  395. {
  396. if(!response)
  397. {
  398. SCM(playerid, COLOR_LIGHTBLUE, "Hey you, you must LogIn to play on this server !");
  399. SetTimerEx("KickPlayer", 300, 0, "d", playerid);
  400. return 1;
  401. }
  402. if(response)
  403. {
  404. new uFile[35];
  405. format(uFile, 35, USER_PATH, PlayerName(playerid));
  406. INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
  407. if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
  408. {
  409. new coordsstring[124];
  410. format(uFile, 35, USER_PATH, PlayerName(playerid));
  411. INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
  412. format(coordsstring, sizeof(coordsstring), "*Welcome %s on the server",PlayerName(playerid));
  413. SCM(playerid, 0x33CCFFAA,coordsstring);
  414. format(coordsstring,sizeof coordsstring,"~n~~n~~n~~n~~n~~n~~w~WELCOME~n~~r~%s!",PlayerName(playerid));
  415. GameTextForPlayer(playerid, coordsstring, 6000, 3);
  416. SetPlayerColor(playerid,0xFFFFFFFF);
  417. PlayerInfo[playerid][pLogged] = 1;
  418. SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
  419. GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
  420. SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  421. SetSpawnInfo(playerid, 0,PlayerInfo[playerid][pSkin], 1154.0653,-1458.0643,15.7969, 0,0,0,0,0,0,0);
  422. SpawnPlayer(playerid);
  423. }
  424. else
  425. {
  426. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT, "Login","Wrong password", "Logiraj","Odustani");
  427. }
  428. }
  429. }
  430. return 1;
  431. }
  432.  
  433. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  434. {
  435. return 1;
  436. }
  437. //============================================================================//
  438.  
  439. forward LoadUserData(playerid, name[], value[]);
  440. public LoadUserData(playerid, name[], value[])
  441. {
  442. INI_Int("Password",PlayerInfo[playerid][pPassword]);
  443. INI_Int("Level",PlayerInfo[playerid][pLevel]);
  444. INI_Int("Money",PlayerInfo[playerid][pMoney]);
  445. INI_Int("AdminLVL",PlayerInfo[playerid][pAdmin]);
  446. INI_Int("Skin",PlayerInfo[playerid][pSkin]);
  447. return 1;
  448. }
  449. forward KickPlayer(playerid);
  450. public KickPlayer(playerid)
  451. {
  452. Kick(playerid);
  453. }
  454.  
  455. //============================================================================// STOCKS
  456.  
  457. stock SavePlayer(playerid)
  458. {
  459. new uFile[35];
  460. format(uFile, 35, USER_PATH, PlayerName(playerid));
  461. new INI:playerFile = INI_Open(uFile);
  462. INI_WriteInt(playerFile, "AdminLVL", PlayerInfo[playerid][pAdmin]);
  463. INI_WriteInt(playerFile, "Money", PlayerInfo[playerid][pMoney]);
  464. INI_WriteInt(playerFile, "Level", PlayerInfo[playerid][pLevel]);
  465. INI_WriteInt(playerFile, "Skin", PlayerInfo[playerid][pSkin]);
  466. INI_Close(playerFile);
  467. return 1;
  468. }
  469. stock UserPath(playerid)
  470. {
  471. new string[128],playername[MAX_PLAYER_NAME];
  472. GetPlayerName(playerid,playername,sizeof(playername));
  473. format(string,sizeof(string),PATH,playername);
  474. return string;
  475. }
  476. stock PlayerName(playerid)
  477. {
  478. new pName[MAX_PLAYER_NAME];
  479. GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  480. return pName;
  481. }
  482.  
  483.  
  484. stock udb_hash(buf[])
  485. {
  486. new length=strlen(buf);
  487. new s1 = 1;
  488. new s2 = 0;
  489. new n;
  490. for (n=0; n<length; n++)
  491. {
  492. s1 = (s1 + buf[n]) % 65521;
  493. s2 = (s2 + s1) % 65521;
  494. }
  495. return (s2 << 16) + s1;
  496. }
  497.  
  498.  
  499. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment