Guest User

asad

a guest
Aug 31st, 2011
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.88 KB | None | 0 0
  1. //=========================================================================================================================================//
  2. //===|INCLUDE|===
  3. #include <a_samp>
  4. #include <dini>
  5.  
  6.  
  7.  
  8. //===|DEFINE|===
  9. #define COLOR_ORANGE 0xffcc00FF
  10. #define COLOR_GRAD1 0xB4B5B7FF
  11. #define COLOR_GREEN 0x33AA33AA
  12. #define COLOR_BASIC 0x0066FFAA
  13. #define COLOR_RED 0xAA3333AA
  14. #define COLOR_GREY 0xAFAFAFAA
  15. #define COLOR_GREEN 0x33AA33AA
  16. #define COLOR_RED 0xAA3333AA
  17. #define COLOR_YELLOW 0xFFFF00AA
  18. #define COLOR_WHITE 0xFFFFFFAA
  19. #define COLOR_LIGHTBLUE 0x6DC5F3FF
  20. #define COLOR_BLACK 0x000000FF
  21. //Chat
  22. #define COLOR_FADE1 0xFFFFFFFF
  23. #define COLOR_FADE2 0xC8C8C8C8
  24. #define COLOR_FADE3 0xAAAAAAAA
  25. #define COLOR_FADE4 0x8C8C8C8C
  26. #define COLOR_FADE5 0x6E6E6E6E
  27. #define SERVER_USER_FILE "SERVER/Accounts/%s.ini"
  28. //===|ENUM|===
  29. enum pInfo
  30. {
  31. pAdminLevel,
  32. pCash,
  33. pSkin,
  34. }
  35.  
  36. //===|NEW|===
  37. new PlayerInfo[MAX_PLAYERS][pInfo];
  38. new gPlayerLogged[MAX_PLAYERS];
  39. new gLoginAttempts[MAX_PLAYERS];
  40. new timer[MAX_PLAYERS];
  41. //==============================================================================//
  42.  
  43.  
  44. //==============================================================================//
  45. main()
  46. {
  47. print("\n----------------------------------");
  48. print(" Mod je uspjesno ucitan. ");
  49. print("----------------------------------\n");
  50. }
  51. //==============================================================================//
  52.  
  53. public OnGameModeInit()
  54. {
  55. SetGameModeText("1.0.0|By Notix");
  56. ShowPlayerMarkers(PLAYER_MARKERS_MODE_GLOBAL);
  57. ShowNameTags(1);
  58. SetNameTagDrawDistance(30.0);
  59. EnableStuntBonusForAll(0);
  60. DisableInteriorEnterExits();
  61. SetWeather(1);
  62. SetWorldTime(11);
  63. UsePlayerPedAnims();
  64. ShowPlayerMarkers(0);
  65. AddPlayerClass(0,1240.5282,-1639.7385,13.5469,86.2016,0,0,0,0,0,0); //Civilian Spawn
  66. return 1;
  67. }
  68.  
  69. public OnGameModeExit()
  70. {
  71. return 1;
  72. }
  73.  
  74. public OnPlayerRequestClass(playerid, classid)
  75. {
  76. if(PlayerInfo[playerid][pSkin] != 0)
  77. {
  78. return SpawnPlayer(playerid);
  79. }
  80. SetPlayerPos(playerid, 2426.8420, 1821.9703, 16.3222);
  81. SetPlayerCameraPos(playerid, 2422.4617, 1821.9310, 17.2204);
  82. SetPlayerCameraLookAt(playerid, 2426.8420, 1821.9703, 16.3222);
  83. SetPlayerFacingAngle(playerid, 92.0174);
  84. return 1;
  85. }
  86.  
  87. public OnPlayerConnect(playerid)
  88. {
  89. gPlayerLogged[playerid] = 0;
  90. new name[MAX_PLAYER_NAME], file[256];
  91.  
  92. GetPlayerName(playerid, name, sizeof(name));
  93. format(file, sizeof(file), SERVER_USER_FILE, name);
  94.  
  95. if (!dini_Exists(file))
  96. {
  97. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{0x33AA33AAA}REGISTER", "Vas profil nije registriran,unesite zeljenu lozinku da se registrirate", "{0x33AA33AAA}Register", "Quit");
  98. }
  99. if(fexist(file))
  100. {
  101. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account is registered!", "This account is registered, please your password to login!", "Enter", "Quit");
  102. }
  103. return 1;
  104. }
  105.  
  106. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  107. {
  108. if (dialogid == 1)
  109. {
  110. new name[MAX_PLAYER_NAME], file[256];
  111. GetPlayerName(playerid, name, sizeof(name));
  112. format(file, sizeof(file), SERVER_USER_FILE, name);
  113. if(!response) return Kick(playerid);
  114. if (!strlen(inputtext)) return
  115. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Account not found!", "This account has not been registered yet, please enter a password below to register it:", "Register", "Quit");
  116. dini_Create(file);
  117. dini_IntSet(file, "Password", udb_hash(inputtext));
  118. dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
  119. dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 10000);
  120. dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 0);
  121. dini_FloatSet(file, "Health", 100);
  122. dini_FloatSet(file, "Armour", 0);
  123. gPlayerLogged[playerid] = 1;
  124. }
  125. if (dialogid == 2)
  126. {
  127. new name[MAX_PLAYER_NAME], file[256];
  128. GetPlayerName(playerid, name, sizeof(name));
  129. format(file, sizeof(file), SERVER_USER_FILE, name);
  130. if(!response) return Kick(playerid);
  131. if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account is registered!", "This account is registered, please your password to login!", "Enter", "Quit");
  132. new tmp;
  133. tmp = dini_Int(file, "Password");
  134. if(udb_hash(inputtext) != tmp) {
  135. if(gLoginAttempts[playerid] > 1)
  136. {
  137. gLoginAttempts[playerid] = 0;
  138. return Kick(playerid);
  139. }
  140. else
  141. {
  142. new string[128];
  143. format(string, sizeof(string), "You have entered an incorrect password, you have %i attempts left before you get kicked.", 2 - gLoginAttempts[playerid]);
  144. SendClientMessage(playerid, COLOR_YELLOW, string);
  145.  
  146. gLoginAttempts[playerid]++;
  147. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account is registered!", "This account is registered, please your password to login!", "Enter", "Quit");
  148. }
  149. }
  150. else
  151. {
  152. gPlayerLogged[playerid] = 1;
  153. timer[playerid] = SetTimerEx("SavePlayer", 30000, true, "i", playerid);
  154.  
  155. PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
  156. PlayerInfo[playerid][pSkin] = dini_Int(file, "Skin");
  157. PlayerInfo[playerid][pCash] = dini_Int(file, "Money");
  158. }
  159. }
  160. return 1;
  161. }
  162.  
  163.  
  164.  
  165. public OnPlayerDisconnect(playerid, reason)
  166. {
  167. new name[MAX_PLAYER_NAME], file[256];
  168. GetPlayerName(playerid, name, sizeof(name));
  169. format(file, sizeof(file), SERVER_USER_FILE, name);
  170. if(gPlayerLogged[playerid] == 1)
  171. {
  172. SavePlayer(playerid);
  173. }
  174. KillTimer(timer[playerid]);
  175. gPlayerLogged[playerid] = 0;
  176. return 1;
  177. }
  178.  
  179. public OnPlayerSpawn(playerid)
  180. {
  181. return 1;
  182. }
  183.  
  184. public OnPlayerDeath(playerid, killerid, reason)
  185. {
  186. return 1;
  187. }
  188.  
  189. public OnVehicleSpawn(vehicleid)
  190. {
  191. return 1;
  192. }
  193.  
  194. public OnVehicleDeath(vehicleid, killerid)
  195. {
  196. return 1;
  197. }
  198.  
  199. public OnPlayerText(playerid, text[])
  200. {
  201. new pname[MAX_PLAYER_NAME], str[128];
  202. GetPlayerName(playerid, pname, sizeof(pname));
  203. strreplace(pname, '_', ' ');
  204. format(str, sizeof(str), "%s kaze: %s", pname, text);
  205. ProxDetector(30.0, playerid, str, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
  206. return 0;
  207. }
  208.  
  209. public OnPlayerCommandText(playerid, cmdtext[])
  210. {
  211. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  212. {
  213. // Do something here
  214. return 1;
  215. }
  216. return 0;
  217. }
  218.  
  219. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  220. {
  221. return 1;
  222. }
  223.  
  224. public OnPlayerExitVehicle(playerid, vehicleid)
  225. {
  226. return 1;
  227. }
  228.  
  229. public OnPlayerStateChange(playerid, newstate, oldstate)
  230. {
  231. return 1;
  232. }
  233.  
  234. public OnPlayerEnterCheckpoint(playerid)
  235. {
  236. return 1;
  237. }
  238.  
  239. public OnPlayerLeaveCheckpoint(playerid)
  240. {
  241. return 1;
  242. }
  243.  
  244. public OnPlayerEnterRaceCheckpoint(playerid)
  245. {
  246. return 1;
  247. }
  248.  
  249. public OnPlayerLeaveRaceCheckpoint(playerid)
  250. {
  251. return 1;
  252. }
  253.  
  254. public OnRconCommand(cmd[])
  255. {
  256. return 1;
  257. }
  258.  
  259. public OnPlayerRequestSpawn(playerid)
  260. {
  261. return 1;
  262. }
  263.  
  264. public OnObjectMoved(objectid)
  265. {
  266. return 1;
  267. }
  268.  
  269. public OnPlayerObjectMoved(playerid, objectid)
  270. {
  271. return 1;
  272. }
  273.  
  274. public OnPlayerPickUpPickup(playerid, pickupid)
  275. {
  276. return 1;
  277. }
  278.  
  279. public OnVehicleMod(playerid, vehicleid, componentid)
  280. {
  281. return 1;
  282. }
  283.  
  284. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  285. {
  286. return 1;
  287. }
  288.  
  289. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  290. {
  291. return 1;
  292. }
  293.  
  294. public OnPlayerSelectedMenuRow(playerid, row)
  295. {
  296. return 1;
  297. }
  298.  
  299. public OnPlayerExitedMenu(playerid)
  300. {
  301. return 1;
  302. }
  303.  
  304. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  305. {
  306. return 1;
  307. }
  308.  
  309. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  310. {
  311. return 1;
  312. }
  313.  
  314. public OnRconLoginAttempt(ip[], password[], success)
  315. {
  316. return 1;
  317. }
  318.  
  319. public OnPlayerUpdate(playerid)
  320. {
  321. return 1;
  322. }
  323.  
  324. public OnPlayerStreamIn(playerid, forplayerid)
  325. {
  326. return 1;
  327. }
  328.  
  329. public OnPlayerStreamOut(playerid, forplayerid)
  330. {
  331. return 1;
  332. }
  333.  
  334. public OnVehicleStreamIn(vehicleid, forplayerid)
  335. {
  336. return 1;
  337. }
  338.  
  339. public OnVehicleStreamOut(vehicleid, forplayerid)
  340. {
  341. return 1;
  342. }
  343.  
  344. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  345. {
  346. return 1;
  347. }
  348. ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  349. {
  350. if(IsPlayerConnected(playerid))
  351. {
  352. new Float:posx, Float:posy, Float:posz;
  353. new Float:oldposx, Float:oldposy, Float:oldposz;
  354. new Float:tempposx, Float:tempposy, Float:tempposz;
  355. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  356. for(new i = 0; i < MAX_PLAYERS; i++)
  357. {
  358. if(IsPlayerConnected(i))
  359. {
  360. GetPlayerPos(i, posx, posy, posz);
  361. tempposx = (oldposx -posx);
  362. tempposy = (oldposy -posy);
  363. tempposz = (oldposz -posz);
  364. if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
  365. {
  366. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  367. {
  368. SendClientMessage(i, col1, string);
  369. }
  370. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  371. {
  372. SendClientMessage(i, col2, string);
  373. }
  374. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  375. {
  376. SendClientMessage(i, col3, string);
  377. }
  378. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  379. {
  380. SendClientMessage(i, col4, string);
  381. }
  382. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  383. {
  384. SendClientMessage(i, col5, string);
  385. }
  386. }
  387. }
  388. }
  389. }
  390. return 1;
  391. }
  392. //
  393. stock udb_hash(buf[]) {
  394. new length=strlen(buf);
  395. new s1 = 1;
  396. new s2 = 0;
  397. new n;
  398. for (n=0; n<length; n++)
  399. {
  400. s1 = (s1 + buf[n]) % 65521;
  401. s2 = (s2 + s1) % 65521;
  402. }
  403. return (s2 << 16) + s1;
  404. }
  405.  
  406. forward SavePlayer(playerid);
  407. public SavePlayer(playerid)
  408. {
  409. new name[MAX_PLAYER_NAME], file[256];
  410. GetPlayerName(playerid, name, sizeof(name));
  411. format(file, sizeof(file), SERVER_USER_FILE, name);
  412. if(gPlayerLogged[playerid] == 1)
  413. {
  414. new Float:x, Float:y, Float:z, Float:angle, Float:health, Float:armour, playerskin;
  415. GetPlayerPos(playerid, x, y, z);
  416. GetPlayerHealth(playerid,health);
  417. GetPlayerArmour(playerid, armour);
  418. GetPlayerFacingAngle(playerid, angle);
  419.  
  420. dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
  421. dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][pAdminLevel]);
  422. dini_FloatSet(file, "Health",health);
  423. dini_FloatSet(file, "Armour",armour);
  424. playerskin = GetPlayerSkin(playerid);
  425. dini_IntSet(file, "Skin", playerskin);
  426. return 1;
  427. }
  428. gPlayerLogged[playerid] = 0;
  429. return 0;
  430. }
  431.  
  432. stock SetPlayerMoney(playerid, cash)
  433. {
  434. ResetPlayerMoney(playerid);
  435. return GivePlayerMoney(playerid, cash);
  436. }
  437.  
  438. stock strreplace(string[], find, replace)
  439. {
  440. for(new i=0; string[i]; i++)
  441. {
  442. if(string[i] == find)
  443. {
  444. string[i] = replace;
  445. }
  446. }
  447. }
Advertisement
Add Comment
Please, Sign In to add comment