Advertisement
Guest User

Untitled

a guest
Jul 26th, 2011
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI/y_ini>
  3.  
  4. #pragma tabsize 0
  5.  
  6. #define COL_WHITE "{FFFFFF}"
  7. #define COL_RED "{F81414}"
  8. #define COL_GREEN "{00FF22}"
  9. #define COL_LIGHTBLUE "{00CED1}"
  10. #define COL_ORANGE "{FFAF00}"
  11. #define COL_BLUE "{0025E1}"
  12. #define COL_PURPLE "{FF00FF}"
  13.  
  14. #define DIALOG_REGISTER 1
  15. #define DIALOG_LOGIN 2
  16.  
  17. #define PATH "/Users/%s.ini"
  18.  
  19. enum pInfo
  20. {
  21. pPass,
  22. pAdmin
  23. }
  24. new PlayerInfo[MAX_PLAYERS][pInfo];
  25.  
  26. new gPlayerLogged[MAX_PLAYERS];
  27.  
  28. forward LoadUser_data(playerid,name[],value[]);
  29.  
  30. public LoadUser_data(playerid,name[],value[])
  31. {
  32. INI_Int("Password",PlayerInfo[playerid][pPass]);
  33. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  34. return 1;
  35. }
  36.  
  37. stock UserPath(playerid)
  38. {
  39. new string[128],name[MAX_PLAYER_NAME];
  40. GetPlayerName(playerid,name,sizeof(name));
  41. format(string,sizeof(string),PATH,name);
  42. return string;
  43. }
  44.  
  45.  
  46.  
  47. main()
  48. {
  49. print("\n=====================================");
  50. print("OK");
  51. print("=====================================\n");
  52. }
  53.  
  54. public OnGameModeInit()
  55. {
  56. return 1;
  57. }
  58.  
  59. public OnGameModeExit()
  60. {
  61. return 1;
  62. }
  63.  
  64. public OnPlayerRequestClass(playerid, classid)
  65. {
  66. return 1;
  67. }
  68.  
  69. public OnPlayerConnect(playerid)
  70. {
  71. gPlayerLogged[playerid] = 0;
  72. SendClientMessage(playerid, COL_WHITE, "SERVER: Welcome to Sudden Evolution Roleplay!");
  73.  
  74. if(fexist(UserPath(playerid)))
  75. {
  76. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  77. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
  78. }
  79. else
  80. {
  81. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""WHITE"Registering...",""WHITE"Type your password below to register a new account.","Register","Quit");
  82. }
  83. return 1;
  84. }
  85.  
  86. public OnPlayerDisconnect(playerid, reason)
  87. {
  88. if(gPlayerLogged[playerid] == 1)
  89. {
  90. new INI:iFile = INI_Open(UserPath(playerid));
  91. INI_SetTag(iFile,"data");
  92. INI_Close(iFile);
  93. }
  94. gPlayerLogged[playerid] = 0;
  95. return 1;
  96. }
  97.  
  98. public OnPlayerSpawn(playerid)
  99. {
  100. return 1;
  101. }
  102.  
  103. public OnPlayerDeath(playerid, killerid, reason)
  104. {
  105. return 1;
  106. }
  107.  
  108. public OnVehicleSpawn(vehicleid)
  109. {
  110. return 1;
  111. }
  112.  
  113. public OnVehicleDeath(vehicleid, killerid)
  114. {
  115. return 1;
  116. }
  117.  
  118. public OnPlayerText(playerid, text[])
  119. {
  120. return 1;
  121. }
  122.  
  123. public OnPlayerCommandText(playerid, cmdtext[])
  124. {
  125. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  126. {
  127. // Do something here
  128. return 1;
  129. }
  130. return 0;
  131. }
  132.  
  133. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  134. {
  135. return 1;
  136. }
  137.  
  138. public OnPlayerExitVehicle(playerid, vehicleid)
  139. {
  140. return 1;
  141. }
  142.  
  143. public OnPlayerStateChange(playerid, newstate, oldstate)
  144. {
  145. return 1;
  146. }
  147.  
  148. public OnPlayerEnterCheckpoint(playerid)
  149. {
  150. return 1;
  151. }
  152.  
  153. public OnPlayerLeaveCheckpoint(playerid)
  154. {
  155. return 1;
  156. }
  157.  
  158. public OnPlayerEnterRaceCheckpoint(playerid)
  159. {
  160. return 1;
  161. }
  162.  
  163. public OnPlayerLeaveRaceCheckpoint(playerid)
  164. {
  165. return 1;
  166. }
  167.  
  168. public OnRconCommand(cmd[])
  169. {
  170. return 1;
  171. }
  172.  
  173. public OnPlayerRequestSpawn(playerid)
  174. {
  175. return 1;
  176. }
  177.  
  178. public OnObjectMoved(objectid)
  179. {
  180. return 1;
  181. }
  182.  
  183. public OnPlayerObjectMoved(playerid, objectid)
  184. {
  185. return 1;
  186. }
  187.  
  188. public OnPlayerPickUpPickup(playerid, pickupid)
  189. {
  190. return 1;
  191. }
  192.  
  193. public OnVehicleMod(playerid, vehicleid, componentid)
  194. {
  195. return 1;
  196. }
  197.  
  198. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  199. {
  200. return 1;
  201. }
  202.  
  203. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  204. {
  205. return 1;
  206. }
  207.  
  208. public OnPlayerSelectedMenuRow(playerid, row)
  209. {
  210. return 1;
  211. }
  212.  
  213. public OnPlayerExitedMenu(playerid)
  214. {
  215. return 1;
  216. }
  217.  
  218. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  219. {
  220. return 1;
  221. }
  222.  
  223. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  224. {
  225. return 1;
  226. }
  227.  
  228. public OnRconLoginAttempt(ip[], password[], success)
  229. {
  230. return 1;
  231. }
  232.  
  233. public OnPlayerUpdate(playerid)
  234. {
  235. return 1;
  236. }
  237.  
  238. public OnPlayerStreamIn(playerid, forplayerid)
  239. {
  240. return 1;
  241. }
  242.  
  243. public OnPlayerStreamOut(playerid, forplayerid)
  244. {
  245. return 1;
  246. }
  247.  
  248. public OnVehicleStreamIn(vehicleid, forplayerid)
  249. {
  250. return 1;
  251. }
  252.  
  253. public OnVehicleStreamOut(vehicleid, forplayerid)
  254. {
  255. return 1;
  256. }
  257.  
  258. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  259. {
  260. switch( dialogid )
  261. {
  262. case DIALOG_REGISTER:
  263. {
  264. if (!response) return Kick(playerid);
  265. if (response)
  266. {
  267. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
  268.  
  269. new INI:iFile = INI_Open(UserPath(playerid));
  270. INI_WriteString(iFile,"Password", inputtext);
  271. INI_Close(iFile);
  272.  
  273. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
  274. }
  275. }
  276.  
  277. case DIALOG_LOGIN:
  278. {
  279. if (!response) return Kick(playerid);
  280. if (response)
  281. {
  282. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
  283.  
  284. INI_ParseFile(UserPath(playerid), "LoadUser_%s", false, true, playerid, false);
  285. if(strcmp(PlayerInfo[playerid][pPass], inputtext, true))
  286. {
  287. SendClientMessage(playerid, COL_WHITE, "GOOD!");
  288. }
  289. else
  290. {
  291. SendClientMessage(playerid, COL_RED, "BAD!");
  292.  
  293. }
  294. }
  295. }
  296. }
  297. return 1;
  298. }
  299.  
  300.  
  301.  
  302. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  303. {
  304. return 1;
  305. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement