Guest User

Untitled

a guest
Aug 10th, 2012
39
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3. #include <zcmd>
  4.  
  5. native WP_Hash(buffer[],len,const str[]);
  6.  
  7. #define dregister 2011
  8. #define dlogin 2012
  9. #define UserPath "Users/%s.ini"
  10.  
  11. #define COLOR_PINK 0xFF80FFC8
  12.  
  13. enum PlayerInfo
  14. {
  15. Pass[129],
  16. AdminLevel,
  17. Money,
  18. Scores,
  19. Kills,
  20. Deaths
  21. }
  22. new pInfo[MAX_PLAYERS][PlayerInfo];
  23.  
  24. stock Path(playerid)
  25. {
  26. new str[128],name[MAX_PLAYER_NAME];
  27. GetPlayerName(playerid,name,sizeof(name));
  28. format(str,sizeof(str),UserPath,name);
  29. return str;
  30. }
  31.  
  32. forward loadaccount_user(playerid, name[], value[]);
  33.  
  34. public loadaccount_user(playerid, name[], value[])
  35. {
  36. INI_String("Password", pInfo[playerid][Pass],129);
  37. INI_Int("AdminLevel",pInfo[playerid][AdminLevel]);
  38. INI_Int("Money",pInfo[playerid][Money]);
  39. INI_Int("Scores",pInfo[playerid][Scores]);
  40. INI_Int("Kills",pInfo[playerid][Kills]);
  41. INI_Int("Deaths",pInfo[playerid][Kills]);
  42. return 1;
  43. }
  44.  
  45. main()
  46. {
  47. print("\n----------------------------------");
  48. print(" RolePlay");
  49. print("----------------------------------\n");
  50. }
  51.  
  52. public OnGameModeInit()
  53. {
  54. // Don't use these lines if it's a filterscript
  55. SetGameModeText("RolePlay");
  56. AddPlayerClass(281,1380.9154,-1088.9073,27.3844,272.3928,0,0,0,0,0,0); //
  57. return 1;
  58. }
  59.  
  60. public OnGameModeExit()
  61. {
  62. return 1;
  63. }
  64.  
  65. public OnPlayerRequestClass(playerid, classid)
  66. {
  67. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  68. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  69. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  70. return 1;
  71. }
  72.  
  73. public OnPlayerConnect(playerid)
  74. {
  75. new name[MAX_PLAYER_NAME], goodbyemessage[108];
  76. GetPlayerName(playerid, name, sizeof(name));
  77. if (!IsRPName(name))
  78. {
  79. format (goodbyemessage, sizeof(goodbyemessage), "* %s was kicked, come back with a proper RolePlay name such as John_Doe", name);
  80. SendClientMessageToAll(-1, goodbyemessage);
  81. SendClientMessage(playerid,-1,"Come back with a Proper RolePlay name such as John_Doe");
  82. return Kick(playerid);
  83. }
  84. if(fexist(Path(playerid)))
  85. {
  86. INI_ParseFile(Path(playerid),"loadaccount %s", .bExtra = true, .extra = playerid);
  87. ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome Back! This account is Registered. \nType your Password below yo Login","Login","Quit");
  88. }
  89. else
  90. {
  91. ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! You're not Registered Yet!\nEnter your password you want below to Register!","Register","Quit");
  92. return 1;
  93. }
  94.  
  95. return 1;
  96.  
  97. }
  98.  
  99. public OnPlayerDisconnect(playerid, reason)
  100. {
  101. if(fexist(Path(playerid)))
  102. {
  103. new INI:file = INI_Open(Path(playerid));
  104. INI_SetTag(file,"Player's Data");
  105. INI_WriteInt(file,"AdminLevel",pInfo[playerid][AdminLevel]);
  106. INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
  107. INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
  108. INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
  109. INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
  110. return 1;
  111. }
  112. return 1;
  113. }
  114.  
  115. public OnPlayerSpawn(playerid)
  116. {
  117. return 1;
  118. }
  119.  
  120. public OnPlayerDeath(playerid, killerid, reason)
  121. {
  122. pInfo[killerid][Kills]++;
  123. pInfo[playerid][Deaths]++;
  124. return 1;
  125. }
  126.  
  127. public OnVehicleSpawn(vehicleid)
  128. {
  129. return 1;
  130. }
  131.  
  132. public OnVehicleDeath(vehicleid, killerid)
  133. {
  134. return 1;
  135. }
  136.  
  137. public OnPlayerText(playerid, text[])
  138. {
  139. return 1;
  140. }
  141.  
  142. public OnPlayerCommandText(playerid, cmdtext[])
  143. {
  144. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  145. {
  146. // Do something here
  147. return 1;
  148. }
  149. return 0;
  150. }
  151.  
  152. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  153. {
  154. return 1;
  155. }
  156.  
  157. public OnPlayerExitVehicle(playerid, vehicleid)
  158. {
  159. return 1;
  160. }
  161.  
  162. public OnPlayerStateChange(playerid, newstate, oldstate)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnPlayerEnterCheckpoint(playerid)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnPlayerLeaveCheckpoint(playerid)
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerEnterRaceCheckpoint(playerid)
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnPlayerLeaveRaceCheckpoint(playerid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnRconCommand(cmd[])
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnPlayerRequestSpawn(playerid)
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnObjectMoved(objectid)
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnPlayerObjectMoved(playerid, objectid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnPlayerPickUpPickup(playerid, pickupid)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnVehicleMod(playerid, vehicleid, componentid)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnPlayerSelectedMenuRow(playerid, row)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnPlayerExitedMenu(playerid)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnRconLoginAttempt(ip[], password[], success)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnPlayerUpdate(playerid)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnPlayerStreamIn(playerid, forplayerid)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnPlayerStreamOut(playerid, forplayerid)
  263. {
  264. return 1;
  265. }
  266.  
  267. public OnVehicleStreamIn(vehicleid, forplayerid)
  268. {
  269. return 1;
  270. }
  271.  
  272. public OnVehicleStreamOut(vehicleid, forplayerid)
  273. {
  274. return 1;
  275. }
  276.  
  277. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  278. {
  279. if(dialogid == dregister)
  280. {
  281. if(!response) return Kick(playerid);
  282. if(response)
  283. {
  284. if(!strlen(inputtext))
  285. {
  286. ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! You're not Registered Yet!\nEnter your password you want below to Register!","Register","Quit");
  287. return 1;
  288. }
  289.  
  290. new hashpass[129];
  291. WP_Hash(hashpass,sizeof(hashpass),inputtext);
  292. new INI:file = INI_Open(Path(playerid));
  293. INI_SetTag(file,"Player's Data");
  294. INI_WriteString(file,"Password",hashpass);
  295. INI_WriteInt(file,"AdminLevel",0);
  296. INI_WriteInt(file,"Money",0);
  297. INI_WriteInt(file,"Scores",0);
  298. INI_WriteInt(file,"Kills",0);
  299. INI_WriteInt(file,"Deaths",0);
  300. SendClientMessage(playerid,-1,"You are now Registerd!");
  301. return 1;
  302. }
  303. }
  304. if(dialogid == dlogin)
  305. {
  306. if(!response) return Kick(playerid);
  307. if(response)
  308. {
  309. new hashpass[129];
  310. WP_Hash(hashpass,sizeof(hashpass),inputtext);
  311. if(!strcmp(hashpass,pInfo[playerid][Pass]))
  312. {
  313. INI_ParseFile(Path(playerid),"loadaccount %s",.bExtra = true, .extra = playerid);
  314. SetPlayerScore(playerid,pInfo[playerid][Scores]);
  315. GivePlayerMoney(playerid,pInfo[playerid][Money]);
  316. SendClientMessage(playerid,-1,"Welcome Back! You are now Logged in!");
  317. }
  318. else
  319. {
  320. ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome Back! This account is Registered. \nType your Password below yo Login","Login","Quit");
  321. return 1;
  322. }
  323. }
  324. }
  325. return 1;
  326. }
  327.  
  328. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  329. {
  330. return 1;
  331. }
  332.  
  333. stock IsRPName(const name[], max_underscores = 2)
  334. {
  335. new underscores = 0;
  336. if (name[0] < 'A' || name[0] > 'Z') return false; // First letter is not capital
  337. for(new i = 1; i < strlen(name); i++)
  338. {
  339. if(name[i] != '_' && (name[i] < 'A' || name[i] > 'Z') && (name[i] < 'a' || name[i] > 'z')) return false; // a-zA-Z_
  340. if( (name[i] >= 'A' && name[i] <= 'Z') && (name[i - 1] != '_') ) return false; // unneeded capital letter
  341. if(name[i] == '_')
  342. {
  343. underscores++;
  344. if(underscores > max_underscores || i == strlen(name)) return false; // More underlines than limit, or underline at the last pos
  345. if(name[i + 1] < 'A' || name[i + 1] > 'Z') return false; // Not a capital letter after underline
  346. }
  347. }
  348. if (underscores == 0) return false; // No underline detected
  349. return true;
  350. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×