Advertisement
Guest User

The_Tough

a guest
Jul 30th, 2009
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.00 KB | None | 0 0
  1. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2])))))
  2. #include <a_samp>
  3. #include <dini>
  4. //
  5. #define COLOUR_GREEN 0x33AA33AA
  6. #define COLOUR_RED 0xFF0000AA
  7. #define COLOUR_YELLOW 0xFFFF00AA
  8. #define COLOUR_LIGHTBLUE 0x33CCFFAA
  9. #define COLOUR_ORANGE 0xFF9900AA
  10. #define PlayerFile "AdminScript/Users/%s.ini"
  11. #define SettingFile "AdminScript/Settings/MainSettings.ini"
  12. #define CommandFile "AdminScript/Settings/Commands.ini"
  13.  
  14. // This is a comment
  15. // uncomment the line below if you want to write a filterscript
  16. //#define FILTERSCRIPT
  17.  
  18. #if defined FILTERSCRIPT
  19.  
  20. public OnFilterScriptInit()
  21. {
  22. print("\n--------------------------------------");
  23. print(" Blank Filterscript by your name here");
  24. print("--------------------------------------\n");
  25. if(!fexist(SettingFile))
  26. {
  27. dini_Create(SettingFile);
  28. dini_IntSet(SettingFile, "PocketMoney", 3000);
  29. dini_IntSet(SettingFile, "JailCommands", 0);
  30. dini_IntSet(SettingFile, "AnnounceSeconds", 3);
  31. dini_IntSet(SettingFile, "PassMin", 3);
  32. dini_IntSet(SettingFile, "PassMax", 15);
  33. }
  34.  
  35. gSettings[POCKET_MONEY] = dini_Int(SettingFile, "PocketMoney");
  36. gSettings[JAIL_COMMANDS] = dini_Int(SettingFile, "JailCommands");
  37. gSettings[ANNOUNCE_SECONDS] = dini_Int(SettingFile, "AnnounceSeconds");
  38. gSettings[PASS_MIN] = dini_Int(SettingFile, "PassMin");
  39. gSettings[PASS_MAX] = dini_Int(SettingFile, "PassMax");
  40.  
  41. if(!fexist(CommandFile))
  42. {
  43. dini_Create(CommandFile);
  44. dini_IntSet(CommandFile, "Akill", 1);
  45. dini_IntSet(CommandFile, "Announce", 1);
  46. dini_IntSet(CommandFile, "Armourall", 3);
  47. dini_IntSet(CommandFile, "Ban", 1);
  48. dini_IntSet(CommandFile, "Explode", 2);
  49. dini_IntSet(CommandFile, "Telmeto", 1);
  50. dini_IntSet(CommandFile, "Teltome", 2);
  51. dini_IntSet(CommandFile, "Givearmour", 2);
  52. dini_IntSet(CommandFile, "Givehealth", 1);
  53. dini_IntSet(CommandFile, "Giveweapon", 2);
  54. dini_IntSet(CommandFile, "God", 4);
  55. dini_IntSet(CommandFile, "Healall", 2);
  56. dini_IntSet(CommandFile, "Imitate", 3);
  57. dini_IntSet(CommandFile, "Ip", 1);
  58. dini_IntSet(CommandFile, "Kick", 1);
  59. dini_IntSet(CommandFile, "Ping", 1);
  60. dini_IntSet(CommandFile, "Setlevel", 4);
  61. dini_IntSet(CommandFile, "Sban", 4);
  62. dini_IntSet(CommandFile, "Time", 2);
  63. dini_IntSet(CommandFile, "Weather", 1);
  64. }
  65.  
  66. gCommands[AKILL] = dini_Int(CommandFile, "Akill");
  67. gCommands[ANNOUNCE] = dini_Int(CommandFile, "Announce");
  68. gCommands[BAN] = dini_Int(CommandFile, "Ban");
  69. gCommands[EXPLODE] = dini_Int(CommandFile, "Explode");
  70. gCommands[TELMETO] = dini_Int(CommandFile, "Telmeto");
  71. gCommands[TELTOME] = dini_Int(CommandFile, "Teltome");
  72. gCommands[GIVEARMOUR] = dini_Int(CommandFile, "Givearmour");
  73. gCommands[GIVEHEALTH] = dini_Int(CommandFile, "Givehealth");
  74. gCommands[GIVEWEAPON] = dini_Int(CommandFile, "Giveweapon");
  75. gCommands[HEALALL] = dini_Int(CommandFile, "Healall");
  76. gCommands[IMITATE] = dini_Int(CommandFile, "Imitate");
  77. gCommands[IP] = dini_Int(CommandFile, "Ip");
  78. gCommands[KICK] = dini_Int(CommandFile, "Kick");
  79. gCommands[SETLEVEL] = dini_Int(CommandFile, "Setlevel");
  80. gCommands[SBAN] = dini_Int(CommandFile, "Sban");
  81. gCommands[TIME] = dini_Int(CommandFile, "Time");
  82. gCommands[WEATHER] = dini_Int(CommandFile, "Weather");
  83. return 1;
  84. }
  85. }
  86.  
  87. public OnFilterScriptExit()
  88. {
  89. return 1;
  90. }
  91.  
  92. #else
  93.  
  94. main()
  95. {
  96. print("\n----------------------------------");
  97. print(" Blank Gamemode by your name here");
  98. print("----------------------------------\n");
  99. }
  100.  
  101. #endif
  102.  
  103. strtok(const string[], &index)
  104. {
  105. new length = strlen(string);
  106. while((index < length) && (string[index] <= ' '))
  107. {
  108. index++;
  109. }
  110.  
  111. new offset = index;
  112. new result[20];
  113. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  114. {
  115. result[index - offset] = string[index];
  116. index++;
  117. }
  118. result[index - offset] = EOS;
  119. return result;
  120. }
  121.  
  122. enum PLAYER_MAIN {
  123. PLAYER_NAME[MAX_PLAYER_NAME],
  124. PLAYER_IP[16],
  125. PLAYER_REGGED,
  126. PLAYER_PASS,
  127. PLAYER_LOGGED,
  128. PLAYER_LEVEL,
  129. PLAYER_WIRED,
  130. PLAYER_JAILED
  131. }
  132.  
  133. new gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
  134.  
  135. enum SETTINGS_MAIN {
  136. POCKET_MONEY,
  137. JAIL_COMMANDS,
  138. ANNOUNCE_SECONDS,
  139. PASS_MIN,
  140. PASS_MAX
  141. }
  142.  
  143. new gSettings[SETTINGS_MAIN];
  144.  
  145. enum COMMANDS_MAIN {
  146. AKILL,
  147. ANNOUNCE,
  148. BAN,
  149. EXPLODE,
  150. FLIP,
  151. TELMETO,
  152. TELTOME,
  153. GIVEARMOUR,
  154. GIVEHEALTH,
  155. GIVEWEAPON,
  156. HEALALL,
  157. IMITATE,
  158. IP,
  159. KICK,
  160. PING,
  161. SETLEVEL,
  162. SBAN,
  163. TIME,
  164. WEATHER
  165. }
  166.  
  167.  
  168. public OnGameModeInit()
  169. {
  170. // Don't use these lines if it's a filterscript
  171. SetGameModeText("Blank Script");
  172. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  173. return 1;
  174. }
  175.  
  176. public OnGameModeExit()
  177. {
  178. return 1;
  179. }
  180.  
  181. public OnPlayerRequestClass(playerid, classid)
  182. {
  183. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  184. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  185. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  186. return 1;
  187. }
  188.  
  189. public OnPlayerRequestSpawn(playerid)
  190. {
  191. return 1;
  192. }
  193.  
  194. public OnPlayerConnect(playerid)
  195. {
  196. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  197. if(!dini_Exists(file)) {
  198. dini_Create(file);
  199. dini_Set(file,"Name",Name);
  200. dini_Set(file,"Ip",Ip);
  201. dini_IntSet(file,"Registered",-1);
  202. dini_IntSet(file,"Password",0);
  203. dini_IntSet(file,"Level",0);
  204. dini_IntSet(file,"Wired",0);
  205. dini_IntSet(file,"Jailed",0);
  206. SendClientMessage(playerid,COLOUR_ORANGE,"You're username is not recognized on this server. Please /register to continue.");
  207. }
  208. strcat(gPlayerInfo[playerid][PLAYER_NAME], dini_Get(file,"Name"));
  209. strcat(gPlayerInfo[playerid][PLAYER_IP], dini_Get(file,"Ip"));
  210. gPlayerInfo[playerid][PLAYER_REGGED] = dini_Int(file,"Registered");
  211. gPlayerInfo[playerid][PLAYER_PASS] = dini_Int(file,"Password");
  212. gPlayerInfo[playerid][PLAYER_LEVEL] = dini_Int(file,"Level");
  213. gPlayerInfo[playerid][PLAYER_WIRED] = dini_Int(file,"Wired");
  214. gPlayerInfo[playerid][PLAYER_JAILED] = dini_Int(file,"Jailed");
  215. if(gPlayerInfo[playerid][PLAYER_REGGED] == 0) SendClientMessage(playerid,COLOUR_ORANGE,"Username is regognized but not register.Please /register to continue.");
  216. else if(gPlayerInfo[playerid][PLAYER_REGGED] == 1) SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server. Please /login to continue.");
  217. gPlayerInfo[playerid][PLAYER_REGGED] = 0;
  218. return 1;
  219. }
  220.  
  221. public OnPlayerDisconnect(playerid, reason)
  222. {
  223. new file[100];
  224. format(file,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
  225. dini_Set(file,"Name",gPlayerInfo[playerid][PLAYER_NAME]);
  226. dini_Set(file,"Ip",gPlayerInfo[playerid][PLAYER_IP]);
  227. dini_IntSet(file,"Registered",gPlayerInfo[playerid][PLAYER_REGGED]);
  228. dini_IntSet(file,"Password",gPlayerInfo[playerid][PLAYER_PASS]);
  229. dini_IntSet(file,"Level",gPlayerInfo[playerid][PLAYER_LEVEL]);
  230. dini_IntSet(file,"Wired",gPlayerInfo[playerid][PLAYER_WIRED]);
  231. dini_IntSet(file,"Jailed",gPlayerInfo[playerid][PLAYER_JAILED]);
  232. gPlayerInfo[playerid][PLAYER_NAME] = 0;
  233. gPlayerInfo[playerid][PLAYER_IP] = 0;
  234. gPlayerInfo[playerid][PLAYER_REGGED] = 0;
  235. gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  236. gPlayerInfo[playerid][PLAYER_PASS] = 0;
  237. gPlayerInfo[playerid][PLAYER_LEVEL] = 0;
  238. gPlayerInfo[playerid][PLAYER_WIRED] = 0;
  239. gPlayerInfo[playerid][PLAYER_JAILED] = 0;
  240. return 1;
  241. }
  242.  
  243. public OnPlayerSpawn(playerid)
  244. {
  245. return 1;
  246. }
  247.  
  248. public OnPlayerDeath(playerid, killerid, reason)
  249. {
  250. return 1;
  251. }
  252.  
  253. public OnVehicleSpawn(vehicleid)
  254. {
  255. return 1;
  256. }
  257.  
  258. public OnVehicleDeath(vehicleid, killerid)
  259. {
  260. return 1;
  261. }
  262.  
  263. public OnPlayerText(playerid, text[])
  264. {
  265. return 1;
  266. }
  267.  
  268. public OnPlayerPrivmsg(playerid, recieverid, text[])
  269. {
  270. return 1;
  271. }
  272.  
  273. public OnPlayerCommandText(playerid, cmdtext[])
  274. {
  275. dcmd(register, 8, cmdtext);
  276. dcmd(login, 5, cmdtext);
  277. dcmd(password, 8, cmdtext);
  278. dcmd(akill, 5, cmdtext);
  279. return 0;
  280. }
  281. dcmd_register(playerid, params[])
  282. {
  283. if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
  284. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You have already registered!");
  285. else if(!params[0])
  286. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /register [password]");
  287. else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
  288. {
  289. new string[200];
  290. format(string, sizeof(string), "ERROR: Password must be between %d and $d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
  291. return SendClientMessage(playerid, COLOUR_ORANGE, string);
  292. }
  293. else
  294. {
  295. new password = num_hash(params);
  296. gPlayerInfo[playerid][PLAYER_PASS] = password;
  297. gPlayerInfo[playerid][PLAYER_REGGED] = 1;
  298. gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  299. GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  300. new string[256]; format(string, sizeof(string), "You have successfully registered your account with the password \'%s\'. You have been automatically logged in.", params);
  301. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  302. }
  303. return 0;
  304. }
  305. dcmd_login(playerid, params[])
  306. {
  307. if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  308. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  309. else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
  310. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-in.");
  311. else if(!params[0])
  312. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /login [password]");
  313. else
  314. {
  315. new password = num_hash(params);
  316. if(gPlayerInfo[playerid][PLAYER_PASS] == password)
  317. {
  318. gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  319. GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  320. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged in to your account.");
  321. }
  322. else
  323. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  324. }
  325. return 0;
  326. }
  327. dcmd_password(playerid, params[])
  328. {
  329. if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  330. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  331. else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  332. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must be logged-in to do that! Use /login [password] to login.");
  333. else
  334. {
  335. new tmp[30],
  336. tmp2[30],
  337. index;
  338. tmp = strtok(params, index);
  339. if(!strlen(tmp))
  340. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  341. tmp2 = strtok(params, index);
  342. if(!strlen(tmp2))
  343. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  344. new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
  345. if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
  346. {
  347. if(oldpassword == newpassword)
  348. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Your old password can not be the same as your new password.");
  349. else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
  350. {
  351. new string[100]; format(string, sizeof(string), "ERROR: Your new password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
  352. return SendClientMessage(playerid, COLOUR_ORANGE, string);
  353. }
  354. gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
  355. new string[256]; format(string, sizeof(string), "You have successfully changed your password from \'%s\' to \'%s\'.", tmp, tmp2);
  356. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  357. }
  358. else
  359. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  360. }
  361. return 0;
  362. }
  363.  
  364. dcmd_akill(playerid, params[])
  365. {
  366. if(gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[AKILL])
  367. {
  368. new string[100];
  369. format(string, sizeof(string), "You must be administrator level %d to use that command!", gCommands[AKILL]);
  370. return SendClientMessage(playerid, COLOUR_ORANGE, string);
  371. }
  372. else if(!strlen(params))
  373. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /akill [id | name]");
  374. else
  375. {
  376. new id = (isNumeric(params)) ? strval(params) : GetPlayerId(params);
  377. if(IsPlayerConnected(id) && id != playerid)
  378. {
  379. SetPlayerHealth(id, 0.0);
  380. new string[150];
  381. format(string, sizeof(string), "You have been admin-killed by administrator \'%s\'.", gPlayerInfo[playerid][PLAYER_NAME]);
  382. SendClientMessage(id, COLOUR_ORANGE, string);
  383. format(string, sizeof(string), "You have successfully admin-killed player \'%s\'.", gPlayerInfo[id][PLAYER_NAME]);
  384. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  385. }
  386. else
  387. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You can not admin-kill yourself or a disconnected player.");
  388. }
  389. }
  390.  
  391.  
  392. public OnPlayerInfoChange(playerid)
  393. {
  394. return 1;
  395. }
  396.  
  397. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  398. {
  399. return 1;
  400. }
  401.  
  402. public OnPlayerExitVehicle(playerid, vehicleid)
  403. {
  404. return 1;
  405. }
  406.  
  407. public OnPlayerStateChange(playerid, newstate, oldstate)
  408. {
  409. return 1;
  410. }
  411.  
  412. public OnPlayerEnterCheckpoint(playerid)
  413. {
  414. return 1;
  415. }
  416.  
  417. public OnPlayerLeaveCheckpoint(playerid)
  418. {
  419. return 1;
  420. }
  421.  
  422. public OnPlayerEnterRaceCheckpoint(playerid)
  423. {
  424. return 1;
  425. }
  426.  
  427. public OnPlayerLeaveRaceCheckpoint(playerid)
  428. {
  429. return 1;
  430. }
  431.  
  432. public OnRconCommand(cmd[])
  433. {
  434. return 1;
  435. }
  436.  
  437. public OnObjectMoved(objectid)
  438. {
  439. return 1;
  440. }
  441.  
  442. public OnPlayerObjectMoved(playerid, objectid)
  443. {
  444. return 1;
  445. }
  446.  
  447. public OnPlayerPickUpPickup(playerid, pickupid)
  448. {
  449. return 1;
  450. }
  451.  
  452. public OnPlayerSelectedMenuRow(playerid, row)
  453. {
  454. return 1;
  455. }
  456.  
  457. public OnPlayerExitedMenu(playerid)
  458. {
  459. return 1;
  460. }
  461.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement