Advertisement
Guest User

Untitled

a guest
Oct 31st, 2011
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.77 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <YSI\y_ini>
  7. #include <zcmd>
  8. #include <sscanf2>
  9. //Dialog Defines//
  10. #define DIALOG_REGISTER 1
  11. #define DIALOG_LOGIN 2
  12. #define DIALOG_SUCCESS_1 3
  13. #define DIALOG_SUCCESS_2 4
  14. #define DIALOG_EMAIL 5
  15. #define DIALOG_CP1 6
  16. #define DIALOG_STATS 7
  17. //Color Defines//
  18. #define COL_WHITE "{FFFFFF}"
  19. #define COL_RED "{F81414}"
  20. #define COL_GREEN "{00FF22}"
  21. #define COL_LIGHTBLUE "{00CED1}"
  22.  
  23. #define COLOR_GREY 0xAFAFAFAA
  24. #define COLOR_GREEN 0x33AA33AA
  25. #define COLOR_RED 0xAA3333AA
  26. #define COLOR_YELLOW 0xFFFF00AA
  27. #define COLOR_WHITE 0xFFFFFFAA
  28. #define COLOR_BLUE 0x0000BBAA
  29. #define COLOR_LIGHTBLUE 0x33CCFFAA
  30. #define COLOR_ORANGE 0xFF9900AA
  31. #define COLOR_RED 0xAA3333AA
  32. #define COLOR_LIME 0x10F441AA
  33. #define COLOR_MAGENTA 0xFF00FFFF
  34. #define COLOR_NAVY 0x000080AA
  35. #define COLOR_AQUA 0xF0F8FFAA
  36. #define COLOR_CRIMSON 0xDC143CAA
  37. #define COLOR_FLBLUE 0x6495EDAA
  38. #define COLOR_BISQUE 0xFFE4C4AA
  39. #define COLOR_BLACK 0x000000AA
  40. #define COLOR_CHARTREUSE 0x7FFF00AA
  41. #define COLOR_BROWN 0XA52A2AAA
  42. #define COLOR_CORAL 0xFF7F50AA
  43. #define COLOR_GOLD 0xB8860BAA
  44.  
  45. //Path Defines//
  46. #define PATH "/Users/%s.ini"
  47. //Enums//
  48. enum pInfo
  49. {
  50. pPass,
  51. pCash,
  52. pAdmin,
  53. pKills,
  54. pDeaths,
  55. pEmail,
  56. pCpUse
  57. }
  58. new PlayerInfo[MAX_PLAYERS][pInfo];
  59.  
  60. //news//
  61. new Name[MAX_PLAYER_NAME];
  62. new String[260];
  63. //Forwards//
  64. forward LoadUser_data(playerid,name[],value[]);
  65. #if defined FILTERSCRIPT
  66.  
  67. public OnFilterScriptInit()
  68. {
  69. print("\n--------------------------------------");
  70. print(" Blank Filterscript by your name here");
  71. print("--------------------------------------\n");
  72. return 1;
  73. }
  74.  
  75. public OnFilterScriptExit()
  76. {
  77. return 1;
  78. }
  79.  
  80. #else
  81.  
  82. main()
  83. {
  84. print("\n----------------------------------");
  85. print(" Blank Gamemode by your name here");
  86. print("----------------------------------\n");
  87. }
  88.  
  89. #endif
  90.  
  91. public OnGameModeInit()
  92. {
  93. // Don't use these lines if it's a filterscript
  94. SetGameModeText("Blank Script");
  95. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  96. return 1;
  97. }
  98.  
  99. public OnGameModeExit()
  100. {
  101. return 1;
  102. }
  103.  
  104. public OnPlayerRequestClass(playerid, classid)
  105. {
  106. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  107.  
  108. return 1;
  109. }
  110.  
  111. public OnPlayerConnect(playerid)
  112. {
  113. SetPlayerCameraPos(playerid, 2042.5273,-1195.7321,28.4404);
  114. SetPlayerCameraLookAt(playerid, 1959.6987,-1200.5483,27.2866);
  115. if(fexist(UserPath(playerid)))
  116. {
  117. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  118. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
  119. }
  120. else
  121. {
  122. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"..Register..",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
  123. }
  124. return 1;
  125. }
  126.  
  127. public OnPlayerDisconnect(playerid, reason)
  128. {
  129. new INI:File = INI_Open(UserPath(playerid));
  130. INI_SetTag(File,"data");
  131. INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  132. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  133. INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  134. INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  135. INI_WriteInt(File,"pCpUse",PlayerInfo[playerid][pCpUse]);
  136. INI_Close(File);
  137. return 1;
  138. }
  139.  
  140. public OnPlayerSpawn(playerid)
  141. {
  142. SetPlayerPos(playerid,1742.9871,-1860.6019,13.5785);
  143. SetPlayerFacingAngle(playerid,1742.8663);
  144. return 1;
  145. }
  146.  
  147. public OnPlayerDeath(playerid, killerid, reason)
  148. {
  149. PlayerInfo[killerid][pKills]++;
  150. PlayerInfo[playerid][pDeaths]++;
  151. return 1;
  152. }
  153.  
  154. public OnVehicleSpawn(vehicleid)
  155. {
  156. return 1;
  157. }
  158.  
  159. public OnVehicleDeath(vehicleid, killerid)
  160. {
  161. return 1;
  162. }
  163.  
  164. public OnPlayerText(playerid, text[])
  165. {
  166. return 1;
  167. }
  168.  
  169. public OnPlayerCommandText(playerid, cmdtext[])
  170. {
  171.  
  172. return 0;
  173. }
  174.  
  175. //Player Commands//
  176. COMMAND:cp(playerid,params[])
  177. {
  178.  
  179. if(PlayerInfo[playerid][pCpUse] == 0)
  180. {
  181. SendClientMessage(playerid,COLOR_WHITE,"______________________________________________________________");
  182. SendClientMessage(playerid,COLOR_WHITE,"It seems that this is your first time using the {00CED1}CP.");
  183. SendClientMessage(playerid,COLOR_WHITE,"This is the control panel of your account.");
  184. SendClientMessage(playerid,COLOR_WHITE,"You can use it for different things.");
  185. SendClientMessage(playerid,COLOR_WHITE,"You can see your stats, change your name/password and more.");
  186. SendClientMessage(playerid,COLOR_WHITE,"______________________________________________________________");
  187. }
  188. ShowPlayerDialog(playerid,DIALOG_CP1,DIALOG_STYLE_LIST,"Control Panel","Stats\nChange Name\nReset Password","Ok","Cancel");
  189. GetPlayerName(playerid, Name, sizeof(Name));
  190. format(String,sizeof(String),"*%s is checking his {00CED1}CP",Name);
  191. SendClientMessageToAll(COLOR_WHITE,String);
  192. PlayerInfo[playerid][pCpUse] ++;
  193. return 1;
  194. }
  195.  
  196. //Admin Commands//
  197. COMMAND:cvec(playerid,params[])
  198. {
  199. new vehid,Float:X,Float:Y,Float:Z;
  200. if(sscanf(params,"d",vehid)) return SendClientMessage(playerid,0xFFFFFFAA,"USAGE: /cvec [vehid]");
  201. GetPlayerPos(playerid,X,Y,Z);
  202. CreateVehicle(vehid,X,Y,Z,1,1,1,10000);
  203. return 1;
  204. }
  205.  
  206.  
  207.  
  208. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  209. {
  210. return 1;
  211. }
  212.  
  213. public OnPlayerExitVehicle(playerid, vehicleid)
  214. {
  215. return 1;
  216. }
  217.  
  218. public OnPlayerStateChange(playerid, newstate, oldstate)
  219. {
  220. return 1;
  221. }
  222.  
  223. public OnPlayerEnterCheckpoint(playerid)
  224. {
  225. return 1;
  226. }
  227.  
  228. public OnPlayerLeaveCheckpoint(playerid)
  229. {
  230. return 1;
  231. }
  232.  
  233. public OnPlayerEnterRaceCheckpoint(playerid)
  234. {
  235. return 1;
  236. }
  237.  
  238. public OnPlayerLeaveRaceCheckpoint(playerid)
  239. {
  240. return 1;
  241. }
  242.  
  243. public OnRconCommand(cmd[])
  244. {
  245. return 1;
  246. }
  247.  
  248. public OnPlayerRequestSpawn(playerid)
  249. {
  250. return 1;
  251. }
  252.  
  253. public OnObjectMoved(objectid)
  254. {
  255. return 1;
  256. }
  257.  
  258. public OnPlayerObjectMoved(playerid, objectid)
  259. {
  260. return 1;
  261. }
  262.  
  263. public OnPlayerPickUpPickup(playerid, pickupid)
  264. {
  265. return 1;
  266. }
  267.  
  268. public OnVehicleMod(playerid, vehicleid, componentid)
  269. {
  270. return 1;
  271. }
  272.  
  273. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  274. {
  275. return 1;
  276. }
  277.  
  278. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  279. {
  280. return 1;
  281. }
  282.  
  283. public OnPlayerSelectedMenuRow(playerid, row)
  284. {
  285. return 1;
  286. }
  287.  
  288. public OnPlayerExitedMenu(playerid)
  289. {
  290. return 1;
  291. }
  292.  
  293. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  294. {
  295. return 1;
  296. }
  297.  
  298. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  299. {
  300. return 1;
  301. }
  302.  
  303. public OnRconLoginAttempt(ip[], password[], success)
  304. {
  305. return 1;
  306. }
  307.  
  308. public OnPlayerUpdate(playerid)
  309. {
  310. return 1;
  311. }
  312.  
  313. public OnPlayerStreamIn(playerid, forplayerid)
  314. {
  315. return 1;
  316. }
  317.  
  318. public OnPlayerStreamOut(playerid, forplayerid)
  319. {
  320. return 1;
  321. }
  322.  
  323. public OnVehicleStreamIn(vehicleid, forplayerid)
  324. {
  325. return 1;
  326. }
  327.  
  328. public OnVehicleStreamOut(vehicleid, forplayerid)
  329. {
  330. return 1;
  331. }
  332.  
  333. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  334. {
  335. switch( dialogid )
  336. {
  337. case DIALOG_REGISTER:
  338. {
  339. if (!response) return Kick(playerid);
  340. if(response)
  341. {
  342. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
  343. new INI:File = INI_Open(UserPath(playerid));
  344. INI_SetTag(File,"data");
  345. INI_WriteInt(File,"Password",udb_hash(inputtext));
  346. INI_WriteInt(File,"Cash",0);
  347. INI_WriteInt(File,"Admin",0);
  348. INI_WriteInt(File,"Kills",0);
  349. INI_WriteInt(File,"Deaths",0);
  350. INI_WriteInt(File,"pCpUse",0);
  351. INI_Close(File);
  352.  
  353. ShowPlayerDialog(playerid,DIALOG_EMAIL, DIALOG_STYLE_INPUT,""COL_WHITE"Email",""COL_WHITE"Please fill in your email to activate your account.\nYour email will be privat and we will not use it.","Activate","Quit");
  354. }
  355. return 1; // added this return
  356. }
  357.  
  358. case DIALOG_LOGIN:
  359. {
  360. if ( !response ) return Kick ( playerid );
  361. if( response )
  362. {
  363. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  364. {
  365. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  366. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  367. ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_WHITE"You have {00FF22}successfully{FFFFFF} logged in!","Ok","");
  368. }
  369. else
  370. {
  371. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
  372. }
  373. return 1;
  374. }
  375. return 1; // added this return
  376. }
  377. case DIALOG_EMAIL:
  378. {
  379.  
  380. if (!response) return Kick(playerid);
  381. if(response)
  382. {
  383.  
  384.  
  385. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, ""COL_WHITE"Email",""COL_RED"You have entered an invalid email.\n"COL_WHITE"Please fill in your email to activate your account.","Activate","Quit");
  386. new INI:File = INI_Open(UserPath(playerid));
  387. INI_WriteString(File,"Email",inputtext);
  388. INI_Close(File);
  389. ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_WHITE"You are {00FF22}successfully{FFFFFF} registered to our database","Ok","");
  390. }
  391. return 1;
  392. }
  393. case DIALOG_SUCCESS_2:
  394. {
  395.  
  396. if(response)
  397. {
  398. SpawnPlayer(playerid);
  399. SendClientMessage(playerid,COLOR_WHITE,"________________________________________________________");
  400. SendClientMessage(playerid,COLOR_WHITE,"Welcome back to {00CED1} Servername.");
  401. SendClientMessage(playerid,COLOR_WHITE,"Mind your behaviour and follow our rules.");
  402. SendClientMessage(playerid,COLOR_WHITE,"You can read our rules at any time by typing {00CED1}/help.");
  403. SendClientMessage(playerid,COLOR_WHITE,"________________________________________________________");
  404. }
  405. return 1;
  406. }
  407. case DIALOG_SUCCESS_1:
  408. {
  409.  
  410. if(response)
  411. {
  412. SpawnPlayer(playerid);
  413. SendClientMessage(playerid,COLOR_WHITE,"________________________________________________________");
  414. SendClientMessage(playerid,COLOR_WHITE,"Welcome to {00CED1} Servername.");
  415. SendClientMessage(playerid,COLOR_WHITE,"Since you're new, we strongly recommend you to read the rules.");
  416. SendClientMessage(playerid,COLOR_WHITE,"You can read our rules at any time by typing {00CED1}/help.");
  417. SendClientMessage(playerid,COLOR_WHITE,"________________________________________________________");
  418. }
  419. return 1;
  420. }
  421. case DIALOG_CP1:
  422. {
  423. if(response)
  424. {
  425. format(String,sizeof(String),"\nMoney: %d\nControl Panel Used: %d",PlayerInfo[playerid][pCash],PlayerInfo[playerid][pCpUse]);
  426. ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX,""COL_WHITE"Stats",String,"Ok","");
  427. }
  428. return 1;
  429. }
  430. }
  431. return 1;
  432. }
  433.  
  434. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  435. {
  436. return 1;
  437. }
  438.  
  439. //Non-Official publics//
  440. public LoadUser_data(playerid,name[],value[])
  441. {
  442. INI_Int("Password",PlayerInfo[playerid][pPass]);
  443. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  444. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  445. INI_Int("Kills",PlayerInfo[playerid][pKills]);
  446. INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  447. INI_Int("pCpUse",PlayerInfo[playerid][pCpUse]);
  448. return 1;
  449. }
  450. //Stocks//
  451. stock UserPath(playerid)
  452. {
  453. new string[128],playername[MAX_PLAYER_NAME];
  454. GetPlayerName(playerid,playername,sizeof(playername));
  455. format(string,sizeof(string),PATH,playername);
  456. return string;
  457. }
  458. stock udb_hash(buf[]) {
  459. new length=strlen(buf);
  460. new s1 = 1;
  461. new s2 = 0;
  462. new n;
  463. for (n=0; n<length; n++)
  464. {
  465. s1 = (s1 + buf[n]) % 65521;
  466. s2 = (s2 + s1) % 65521;
  467. }
  468. return (s2 << 16) + s1;
  469. }
  470.  
  471.  
  472.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement