Advertisement
Guest User

sizeofSky

a guest
Oct 10th, 2009
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.69 KB | None | 0 0
  1. /*
  2.  
  3. This script has been made to basically "boost" the ZCMD command usage. It has been said many times that ZCMD is by far
  4. the most efficient command coding, so why doesn't it get used? Because nobody knows about it! This script will hopefully
  5. show you how to efficiently use ZCMD and get it to your likings, it's a piece of cake! Don't understand one of my explainations?
  6. Feel free to post on this topic, and I will explain it to you through the best of my ability.
  7.  
  8. Have Fun,
  9. sizeof(Sky));
  10.  
  11. */
  12.  
  13. /* Includes */
  14.  
  15. #include <a_samp>
  16. #include <zcmd>
  17.  
  18. /* Color Defines */
  19.  
  20. #define purple 0xC2A2DAAA
  21. #define grey 0xAFAFAFAA
  22. #define green 0x33AA33AA
  23. #define red 0xAA3333AA
  24. #define lightred 0xFF6347AA
  25. #define lb 0x33CCFFAA
  26. #define lg 0x9ACD32AA
  27. #define yellow 0xFFFF00AA
  28. #define yellow2 0xF5DEB3AA
  29. #define white 0xFFFFFFAA
  30. #define blue 0x4089BFFF
  31.  
  32. main() //Basically what happens in the command prompt when you open up the samp-server.exe.
  33. {
  34. new year, month, day; //Make sure you ALWAYS define what you're trying to make into a string, or pawno will say, "What are you trying to do?" and have a bitch-fit.
  35. getdate(year, month, day); //getdate is actually a built-in function to SA:MP, I actually did not figure this out until I started experimenting (About 3 years in?)
  36. printf("[SERVER]: Server has been started. (%d-%d-%d)", month, day, year);
  37. /*^ Prints "[SERVER]: Server has been started. (MONTH-DAY-YEAR) into the console.
  38. Example: [SERVER]: Server has been started. (10-10-2009)*/
  39. }
  40.  
  41. enum pInfo //This is just defining the variables for the Registration + Login System.
  42. {
  43. pKey[64],
  44. pAdmin,
  45. pReg
  46. };
  47.  
  48. new gPlayerLogged[MAX_PLAYERS]; new threesectimer; new SInfo[MAX_PLAYERS][pInfo]; //SInfo is what I use in place of PlayerInfo, because 1: It's shorter, 2: It's my RL name that the prefix is, so i think it's pretty cool.
  49. new adminusers; //Just a little variable for my /serverstats command.
  50.  
  51. forward Encrypt(string[]); //Password encryption, taken from Godfather because it's so useful. (Don't know where GF got it)
  52. forward OnPlayerLogin(playerid,password[]); //Just a quick forward for Public OnPlayerLogin(playerid, password[])
  53. forward OnPlayerRegister(playerid,password[]); //Just a quick forward for Public OnPlayerRegister(playerid, password[])
  54. forward ini_GetKey( line[] ); //Used to get the encrypted password, and to check if it cooresponds with the user-file.
  55. forward ini_GetValue( line[] );
  56. forward ThreeSecondTimer(); //Saves the files every three seconds compared to using OnPlayerUpdate. (Credits to oncedead)
  57. forward AChat(color,const string[],level); //Just a little Administrator Chat function, broadcasts it to every online administrator.
  58.  
  59. public OnGameModeInit()
  60. {
  61. SetGameModeText("LSDM"); //Sets the GameModeText, kind of self-explainatory.
  62. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); //Edit these to your liking.
  63. threesectimer = SetTimer("ThreeSecondTimer", 3000, 1); //Starts the 3 second timer, make sure this is on here!
  64. UsePlayerPedAnims(); //Makes you run like CJ does in single player whilst being in a Ped-Skin. (Anti-Gay-Run, I like to call it)
  65. return 1;
  66. }
  67.  
  68. /* Commands */
  69.  
  70.  
  71. zcmd(admins, playerid, params[]) //Just a simple /admins command, this will print the name of every single administrator online.
  72. {
  73. new admin[MAX_PLAYER_NAME], string[128];
  74. format(string, sizeof(string), ">> Administrative Users Online: (TOTAL: %d)", adminusers); //Just counts up every administrator that's logged in.
  75. SendClientMessage(playerid, blue, string);
  76. for(new i = 0; i < MAX_PLAYERS; i++) //This means it scans every player online for the variable "pAdmin" and checks if it equals 1 or more.
  77. {
  78. if(SInfo[i][pAdmin] >= 1)
  79. {
  80. GetPlayerName(i, admin, sizeof(admin));
  81. format(string, sizeof(string), "> %s [Level: %d]", admin, SInfo[i][pAdmin]);
  82. SendClientMessage(playerid, white, string); //If it does equal 1 or more, it sends a message with their name and Administrator Level.
  83. }
  84. }
  85. return 1;
  86. }
  87. zcmd(kick, playerid, params[]) //Simple command to just boot the selected player out of the server. (Basically /rcon kick)
  88. {
  89. new player, kicked[MAX_PLAYER_NAME], reason[128], administrator[MAX_PLAYER_NAME], string[128]; //All the variables you're going to need.
  90. if(!sscanf(params, "us", player, reason)) //U = User, S = String; Basically you have to think of it this way: First, think of the syntax.. Okay, /kick [Player ID/Part of Name] [Reason]
  91. { //You will be needing a user variable because you are going to kick via ID/Name; (/kick 3 will kick ID 3), You will need a String Variable for the reason, meaning it's going to print the message you send after it.
  92. if(player != INVALID_PLAYER_ID) //Checks to see if the user you entered is even online..
  93. {
  94. if(SInfo[playerid][pAdmin] >= 1) //After that check is done, and the user IS online, it will check if you are an Administrator.
  95. {
  96. GetPlayerName(player, kicked, sizeof(kicked));
  97. GetPlayerName(playerid, administrator, sizeof(administrator));
  98. format(string, sizeof(string), "%s has been kicked by Administrator %s, Reason: %s", kicked, administrator, reason);
  99. SendClientMessageToAll(red, string);
  100. printf("[ADMIN]: %s has been kicked by Administrator %s, Reason: %s", kicked, administrator, reason);
  101. Kick(player); //Here's all the things you need (well, you don't NEED a reason, but it's useful) to make a simple /kick command.
  102. }
  103. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator."); //If you're not an Administrator, it will send you this client message.
  104. }
  105. else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected."); //If the user you entered IS an INVALID_PLAYER_ID, it will sends you this client message.
  106. }
  107. else return SendClientMessage(playerid, lg, "[USAGE]: /Kick [Player ID/Part of Name] [Reason]"); //If you entered the wrong syntax, it will send you this, telling you the exact syntax.
  108. return 1;
  109. }
  110. zcmd(ban, playerid, params[]) //Simple command to ban the selected player out of the server. (Basically /rcon ban)
  111. {
  112. new player, reason[128], administrator[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], string[128];
  113. if(!sscanf(params, "us", player, reason))
  114. {
  115. if(player != INVALID_PLAYER_ID)
  116. {
  117. if(SInfo[playerid][pAdmin] >= 2)
  118. {
  119. GetPlayerName(player, banned, sizeof(banned));
  120. GetPlayerName(playerid, administrator, sizeof(administrator));
  121. format(string, sizeof(string), "%s has been banned by Administrator %s, Reason: %s", banned, administrator, reason);
  122. SendClientMessageToAll(red, string);
  123. printf(string);
  124. Ban(player);
  125. }
  126. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
  127. }
  128. else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
  129. }
  130. else return SendClientMessage(playerid, lg, "[USAGE]: /Ban [Player ID/Part of Name] [Reason]");
  131. return 1;
  132. }
  133. zcmd(sethp, playerid, params[]) //This time we'll be doing a simple /sethp command, Syntax: /SetHP [Player ID/Part of Name] [Amount].. Okay!
  134. { //Now, we will be needing a user variable for the Player ID, and a Integer variable for the amount.
  135. new player, health, string[128], administrator[MAX_PLAYER_NAME];
  136. if(!sscanf(params, "ui", player, health)) //U = User, I = Integer
  137. {
  138. if(player != INVALID_PLAYER_ID) //Checks to see if the selected player is online.
  139. {
  140. if(SInfo[playerid][pAdmin] >= 1) //Checks to see if you're an Administrator.
  141. {
  142. GetPlayerName(playerid, administrator, sizeof(administrator));
  143. SetPlayerHealth(player, health);
  144. format(string, sizeof(string), "[ADMIN]: Player ID %d's HP has been set to %d by %s.", player, health, administrator);
  145. AChat(blue, string, 1); //Broadcasts a message to every administrator.
  146. printf(string);
  147. }
  148. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administator."); //If you're not an Administrator it will send you this client message.
  149. }
  150. else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected."); //If you entered an INVALID_PLAYER_ID, it will send you this client message.
  151. }
  152. else return SendClientMessage(playerid, lg, "[USAGE]: /SetHP [Player ID/Part of Name] [Amount]"); //If you entered the wrong syntax, it will send you this, telling you the exact syntax.
  153. return 1; //Always include a return 1; after the syntax, or you will get "SERVER: Unknown Command."
  154. }
  155. zcmd(setarmor, playerid, params[]) //This time we'll be doing a simple /setarmor command, Syntax: /SetArmor [Player ID/Part of Name] [Amount]
  156. { //We'll need the same variables as /SetHP, just change health to armor (or leave it, doesn't matter), all we need to change is one line, and that is "SetPlayerHealth(player, health);", with this, just change it to "SetPlayerArmour(player, armor);
  157. new player, armor, string[128], administrator[MAX_PLAYER_NAME];
  158. if(!sscanf(params, "ui", player, armor))
  159. {
  160. if(player != INVALID_PLAYER_ID)
  161. {
  162. if(SInfo[playerid][pAdmin] >= 1)
  163. {
  164. GetPlayerName(playerid, administrator, sizeof(administrator));
  165. SetPlayerArmour(player, armor);
  166. format(string, sizeof(string), "[ADMIN]: Player ID %d's Armor has been set to %d by %s.", player, armor, administrator);
  167. AChat(blue, string, 1);
  168. printf(string);
  169. }
  170. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administator.");
  171. }
  172. else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
  173. }
  174. else return SendClientMessage(playerid, lg, "[USAGE]: /SetArmor [Player ID/Part of Name] [Amount]");
  175. return 1;
  176. }
  177. zcmd(a, playerid, params[])
  178. {
  179. new administrator[MAX_PLAYER_NAME], string[128],chat;
  180. if(!sscanf(params, "s", chat)) //With this we only need an "S" variable, which stands for string.. Syntax: /A [Chat]
  181. { //This means all you will need to do is Administrator-only broadcast a string, which is shown below.
  182. if(SInfo[playerid][pAdmin] >= 1)
  183. {
  184. GetPlayerName(playerid, administrator, sizeof(administrator));
  185. format(string, sizeof(string), "[Admin %s]: %s", administrator, chat);
  186. AChat(blue, string, 1); //Simple administrator chat.
  187. }
  188. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
  189. }
  190. else return SendClientMessage(playerid, lg, "[USAGE]: /A [Chat]");
  191. return 1;
  192. }
  193. zcmd(veh, playerid, params[]) //This just spawns a vehicle, and apparently invalid vehicle ids don't crash the server now, so i'm not restricting it.
  194. {
  195. new vehicle, color1, color2, string[128];
  196. if(!sscanf(params, "iii", vehicle, color1, color2)) //You will need three integers because of the syntax, "/Veh [Vehicle ID] [Color 1] [Color 2]"
  197. {
  198. if(SInfo[playerid][pAdmin] >= 3) //Checks if you're an administrator level 3.
  199. {
  200. new Float:x, Float:y, Float:z;
  201. GetPlayerPos(playerid, x, y, z);
  202. CreateVehicle(vehicle, x, y, z, 0.0, color1, color2, 60000);
  203. format(string, sizeof(string), "[ADMIN]: You have spawned a Vehicle ID %d at your position.", vehicle);
  204. SendClientMessage(playerid, blue, string);
  205. }
  206. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
  207. }
  208. else return SendClientMessage(playerid, lg, "[USAGE]: /Veh [Model ID] [Color 1] [Color 2]"); //Prints the syntax.
  209. return 1;
  210. }
  211. zcmd(wep, playerid, params[])
  212. {
  213. new player,gun,ammo;
  214. if(!sscanf(params, "uii", player,gun, ammo)) //With this, we're going to need a User, and two integers because of the syntax.. "/Wep [PLAYER ID] [WEAPON ID] [AMMO]"
  215. {
  216. if (SInfo[playerid][pAdmin] >= 3) //Checks if you're an administrator.
  217. {
  218. if(player != INVALID_PLAYER_ID)
  219. {
  220. new string[128];
  221. new name[MAX_PLAYER_NAME];
  222. GetPlayerName(player, name, sizeof(name));
  223. GivePlayerWeapon(player, gun, ammo);
  224. format(string, sizeof(string), "[ADMIN]: %s has given you a Weapon ID %d with %d Ammo.", name, gun, ammo);
  225. SendClientMessage(player, blue, string);
  226. }
  227. else
  228. {
  229. SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
  230. }
  231. }
  232. else
  233. {
  234. SendClientMessage(playerid, red, ">> Error: Unreliable User Permissions.");
  235. }
  236. }
  237. else
  238. {
  239. SendClientMessage(playerid, white, "[USAGE]: /Wep [Player ID/Part of Name] [Weapon ID] [Ammo]");
  240. SendClientMessage(playerid, yellow, "* HINT: Don't know the Weapon ID? Don't guess, type \"/wepids\"."); //Sends you a syntax message.
  241. }
  242. return 1;
  243. }
  244. zcmd(wepids, playerid, params[]) //Really simple command, since there's no user-input involved, we don't need sscanf.
  245. {
  246. if(SInfo[playerid][pAdmin] >= 3)
  247. {
  248. SendClientMessage(playerid, white, " ");
  249. SendClientMessage(playerid, white, " ");
  250. SendClientMessage(playerid, blue, " * LIST OF SUPPORTED WEAPON IDS, LAST UPDATE: OCTOBER 05, 2009 *");
  251. SendClientMessage(playerid, white, ">> 1: Brass Knuckles, 2: Golf Club, 3: Night Stick, 4: Knife, 5: Baseball Bat");
  252. SendClientMessage(playerid, white, ">> 6: Shovel, 7: Pool Cue, 8: Katana, 9: Chainsaw, 10: Dildo, 11: Short Vibrator");
  253. SendClientMessage(playerid, white, ">> 12: Long Vibrator, 13: White Dildo, 14: Flowers, 15: Cane, 16: Grenades, 17: Tear Gas");
  254. SendClientMessage(playerid, white, ">> 18: Molotov, 22: 9mm, 23: SDPistol, 24: Desert Eagle, 25: Pump Shotgun, 26: Sawn-off Shotgun");
  255. SendClientMessage(playerid, white, ">> 27: SPAS-12 Shotgun, 28: Mac 10, 29: MP5, 30: AK-47, 31: M4 Carbine, 32: Tec9, 33: Rifle");
  256. SendClientMessage(playerid, white, ">> 34: Sniper Rifle, 35: Rocket Launcher, 36: Heat Seeking Rocket Launcher, 37: Flame-Thrower");
  257. SendClientMessage(playerid, white, ">> 38: Minigun, 39: Satchel Charges, 41: Spray Can, 42: Fire Extinguisher, 43: Camera, 46: Parachute");
  258. }
  259. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
  260. return 1;
  261. }
  262. zcmd(slap, playerid, params[]) //Just a simple /slap command.
  263. {
  264. new player, distance, Float:x, Float:y, Float:z, string[128], admin[MAX_PLAYER_NAME], user[MAX_PLAYER_NAME];
  265. if(!sscanf(params, "ui", player, distance)) //We will be needing a user and an integer, because of the syntax: /Slap [PLAYER ID] [DISTANCE]
  266. {
  267. if(SInfo[playerid][pAdmin] >= 1)
  268. {
  269. if(player != INVALID_PLAYER_ID)
  270. {
  271. if(distance <= 20) //Limits the distance to 20 feet, anything over 20 will print "You cannot slap the user above 20 feet."
  272. {
  273. GetPlayerName(playerid, admin, sizeof(admin));
  274. GetPlayerName(player, user, sizeof(user));
  275. GetPlayerPos(player, x, y, z);
  276. SetPlayerPos(player, x, y, z+distance);
  277. format(string, sizeof(string), "[ADMIN]: You have been slapped %d feet in the air by Administrator %s.", distance, admin);
  278. SendClientMessage(player, blue, string);
  279. format(string, sizeof(string), "[ADMIN]: Player \"%s\" has been slapped %d feet.", user, distance);
  280. SendClientMessage(playerid, blue, string);
  281. }
  282. else return SendClientMessage(playerid, red, "[ERROR]: You cannot slap the user above 20 feet.");
  283. }
  284. else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
  285. }
  286. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
  287. }
  288. else return SendClientMessage(playerid, white, "[USAGE]: /Slap [Player ID/Part of Name] [Distance]");
  289. return 1;
  290. }
  291. zcmd(goto, playerid, params[]) //Sends you to the selected user.
  292. {
  293. new player, admin[MAX_PLAYER_NAME], user[MAX_PLAYER_NAME], Float:x, Float:y, Float:z, string[128];
  294. if(!sscanf(params, "u", player))
  295. {
  296. if(SInfo[playerid][pAdmin] >= 1)
  297. {
  298. if(player != INVALID_PLAYER_ID)
  299. {
  300. GetPlayerName(player, user, sizeof(user));
  301. GetPlayerName(playerid, admin, sizeof(admin));
  302. GetPlayerPos(player, x, y, z);
  303. SetPlayerPos(playerid, x+1, y, z);
  304. format(string, sizeof(string), "[ADMIN]: You have been teleported to %s.", user);
  305. SendClientMessage(playerid, blue, string);
  306. format(string, sizeof(string), "[ADMIN]: Administrator %s has teleported to you.", admin);
  307. SendClientMessage(player, blue, string);
  308. }
  309. else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
  310. }
  311. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
  312. }
  313. else return SendClientMessage(playerid, lg, "[USAGE]: /Goto [Player ID/Part of Name]");
  314. return 1;
  315. }
  316. zcmd(gethere, playerid, params[]) //Sends the selected user to you.
  317. {
  318. new player, string[128], user[MAX_PLAYER_NAME], admin[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
  319. if(!sscanf(params, "u", player))
  320. {
  321. if(SInfo[playerid][pAdmin] >= 1)
  322. {
  323. if(player != INVALID_PLAYER_ID)
  324. {
  325. GetPlayerName(playerid, admin, sizeof(admin));
  326. GetPlayerName(player, user, sizeof(user));
  327. GetPlayerPos(playerid, x, y, z);
  328. SetPlayerPos(player, x+1, y, z);
  329. format(string, sizeof(string), "[ADMIN]: You have teleported %s to you.", user);
  330. SendClientMessage(playerid, blue, string);
  331. format(string, sizeof(string), "[ADMIN]: Administrator %s has teleported you to them.", admin);
  332. SendClientMessage(player, blue, string);
  333. }
  334. else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
  335. }
  336. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
  337. }
  338. else return SendClientMessage(playerid, lg, "[USAGE]: /Gethere [Player ID/Part of Name]");
  339. return 1;
  340. }
  341. zcmd(makeadministrator, playerid, params[]) //Yet again, a simple USER + INTEGER.
  342. {
  343. new player, adminlevel, string[128], admin[MAX_PLAYER_NAME], user[MAX_PLAYER_NAME];
  344. if(!sscanf(params, "ui", player, adminlevel))
  345. {
  346. if(SInfo[playerid][pAdmin] >= 5)
  347. {
  348. if(player != INVALID_PLAYER_ID)
  349. {
  350. if(adminlevel <= 4)
  351. {
  352. GetPlayerName(playerid, admin, sizeof(admin));
  353. GetPlayerName(player, user, sizeof(user));
  354. SInfo[player][pAdmin] = adminlevel;
  355. format(string, sizeof(string), "[ADMIN]: Lead Administrator %s has given you Level %d Administrator.", admin, adminlevel);
  356. SendClientMessage(player, blue, string);
  357. format(string, sizeof(string), "[ADMIN]: You have made %s a Level %d Administrator.", user, adminlevel);
  358. SendClientMessage(playerid, blue, string);
  359. }
  360. else return SendClientMessage(playerid, red, "[ERROR]: You cannot use this command to make them a Lead Administrator.");
  361. }
  362. else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
  363. }
  364. else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator");
  365. }
  366. else return SendClientMessage(playerid, lg, "[USAGE]: /MakeAdministrator [Player ID/Part of Name] [Administrator Level]");
  367. return 1;
  368. }
  369.  
  370. public OnGameModeExit()
  371. {
  372. KillTimer(threesectimer); //When the gamemode exits, i don't think the accounts need to be saving, do you? :P
  373. return 1;
  374. }
  375.  
  376. public OnPlayerRequestClass(playerid, classid)
  377. {
  378. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  379. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  380. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); //Change these around, it's default at the moment.
  381. return 1;
  382. }
  383.  
  384. public OnPlayerConnect(playerid)
  385. {
  386. new string[50];
  387. gPlayerLogged[playerid] = 0;
  388. new plname[MAX_PLAYER_NAME];
  389. GetPlayerName(playerid, plname, sizeof(plname));
  390. format(string, sizeof(string), "LSDM/users/%s.ini", plname); //make sure to change this, and make the folder you wish to have the users in before-hand.
  391. if(fexist(string))
  392. {
  393. ShowPlayerDialog(playerid, 100, DIALOG_STYLE_INPUT, "Please login", "Type your password into the box and click \"Login\".", "Login", "Quit");
  394. }
  395. else
  396. {
  397. ShowPlayerDialog(playerid, 200, DIALOG_STYLE_INPUT, "Please register", "Type your password into the box and click \"Register\".", "Register", "Quit");
  398. }
  399. return 1;
  400. }
  401. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  402. {
  403. if(dialogid==100)
  404. {
  405. if(response == 0)
  406. {
  407. Kick(playerid);
  408. }
  409. if(response == 1)
  410. {
  411. if(strlen(inputtext)==0) return ShowPlayerDialog(playerid, 100, DIALOG_STYLE_INPUT, "Please login", "Type your password into the box and click \"Login\".", "Login", "Quit");
  412. Encrypt(inputtext);
  413. OnPlayerLogin(playerid,inputtext);
  414. }
  415. }
  416. if(dialogid==200)
  417. {
  418. if(response == 0)
  419. {
  420. Kick(playerid);
  421. }
  422. if(response == 1)
  423. {
  424. if(strlen(inputtext)==0) return ShowPlayerDialog(playerid, 200, DIALOG_STYLE_INPUT, "Please register", "Type your password into the box and click \"Register\".", "Register", "Quit");
  425. Encrypt(inputtext);
  426. OnPlayerRegister(playerid,inputtext);
  427. }
  428. }
  429. return 1;
  430. }
  431. public OnPlayerDisconnect(playerid, reason)
  432. {
  433. return 1;
  434. }
  435.  
  436. public OnPlayerSpawn(playerid)
  437. {
  438. return 1;
  439. }
  440.  
  441. public OnPlayerDeath(playerid, killerid, reason)
  442. {
  443. return 1;
  444. }
  445.  
  446. public OnPlayerText(playerid, text[])
  447. {
  448. return 1;
  449. }
  450.  
  451. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  452. {
  453. return 1;
  454. }
  455.  
  456. public OnPlayerStateChange(playerid, newstate, oldstate)
  457. {
  458. return 1;
  459. }
  460.  
  461. public OnRconCommand(cmd[])
  462. {
  463. return 1;
  464. }
  465.  
  466. public OnPlayerPickUpPickup(playerid, pickupid)
  467. {
  468. return 1;
  469. }
  470.  
  471. public AChat(color,const string[],level)
  472. {
  473. for(new i = 0; i < MAX_PLAYERS; i++)
  474. {
  475. if(IsPlayerConnected(i))
  476. {
  477. if (SInfo[i][pAdmin] >= level)
  478. {
  479. SendClientMessage(i, color, string);
  480. }
  481. }
  482. }
  483. return 1;
  484. }
  485.  
  486. public Encrypt(string[])
  487. {
  488. for(new x=0; x < strlen(string); x++)
  489. {
  490. string[x] += (3^x) * (x % 15);
  491. if(string[x] > (0xff))
  492. {
  493. string[x] -= 256;
  494. }
  495. }
  496. return 1;
  497. }
  498. ini_GetKey( line[] )
  499. {
  500. new keyRes[64];
  501. keyRes[0] = 0;
  502. if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  503. strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  504. return keyRes;
  505. }
  506.  
  507. ini_GetValue( line[] )
  508. {
  509. new valRes[64];
  510. valRes[0]=0;
  511. if ( strfind( line , "=" , true ) == -1 ) return valRes;
  512. strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  513. return valRes;
  514. }
  515. public OnPlayerRegister(playerid, password[])
  516. {
  517. new string3[50];
  518. new playername3[MAX_PLAYER_NAME];
  519. GetPlayerName(playerid, playername3, sizeof(playername3));
  520. format(string3, sizeof(string3), "LSDM/users/%s.ini", playername3); //Change this aswell to the same as above.
  521. new File: hFile = fopen(string3, io_write);
  522. if (hFile)
  523. {
  524. strmid(SInfo[playerid][pKey], password, 0, strlen(password), 128);
  525. new var[32];
  526. format(var, 32, "Key=%s\n", SInfo[playerid][pKey]);fwrite(hFile, var);
  527. format(var, 32, "AdminLevel=%d\n",SInfo[playerid][pAdmin]);fwrite(hFile, var);
  528. format(var, 32, "Registered=%d\n",SInfo[playerid][pReg]);fwrite(hFile, var);
  529. fclose(hFile);
  530. ShowPlayerDialog(playerid, 100, DIALOG_STYLE_INPUT, "Please login", "Type your password into the box and click \"Login\".", "Login", "Login");
  531. }
  532. return 1;
  533. }
  534. public OnPlayerLogin(playerid,password[])
  535. {
  536. new string2[50];
  537. new playername2[MAX_PLAYER_NAME];
  538. GetPlayerName(playerid, playername2, sizeof(playername2));
  539. format(string2, sizeof(string2), "LSDM/users/%s.ini", playername2); //Change this too.
  540. new File: UserFile = fopen(string2, io_read);
  541. if ( UserFile )
  542. {
  543. new PassData[64];
  544. new keytmp[64], valtmp[64];
  545. fread( UserFile , PassData , sizeof( PassData ) );
  546. keytmp = ini_GetKey( PassData );
  547. if( strcmp( keytmp , "Key" , true ) == 0 )
  548. {
  549. valtmp = ini_GetValue( PassData );
  550. strmid(SInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 128);
  551. }
  552. if(strcmp(SInfo[playerid][pKey],password, true ) == 0 )
  553. {
  554. new key[64],val[64];
  555. new Data[64];
  556. while ( fread( UserFile , Data , sizeof( Data ) ) )
  557. {
  558. key = ini_GetKey( Data );
  559. if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); SInfo[playerid][pAdmin] = strval( val ); }
  560. if( strcmp( key , "Registered" , true ) == 0 ) { val = ini_GetValue( Data ); SInfo[playerid][pReg] = strval( val ); }
  561. }
  562. fclose(UserFile);
  563. if(SInfo[playerid][pReg] == 0)
  564. {
  565. SInfo[playerid][pReg] = 1;
  566. }
  567. format(string2, sizeof(string2), "(System): Welcome to our server, %s!",playername2);
  568. SendClientMessage(playerid, lg,string2);
  569. printf("%s has logged in.",playername2);
  570. if (SInfo[playerid][pAdmin] > 0)
  571. {
  572. format(string2, sizeof(string2), "(System): You have been logged in as a Level %d Administrator.",SInfo[playerid][pAdmin]);
  573. SendClientMessage(playerid, lg,string2);
  574. adminusers++;
  575. }
  576. else{}
  577. gPlayerLogged[playerid] = 1;
  578. }
  579. else
  580. {
  581. fclose(UserFile);
  582. ShowPlayerDialog(playerid, 100, DIALOG_STYLE_INPUT, "Please login", "Type your password into the box and click \"Login\".", "Login", "Login");
  583. return 1;
  584. }
  585. }
  586. return 1;
  587. }
  588. public ThreeSecondTimer()
  589. {
  590. for(new i = 0; i < MAX_PLAYERS; i++)
  591. {
  592. if(gPlayerLogged[i])
  593. {
  594. new string3[50];
  595. new playername3[MAX_PLAYER_NAME];
  596. GetPlayerName(i, playername3, sizeof(playername3));
  597. format(string3, sizeof(string3), "LSDM/users/%s.ini", playername3); //Change this too x2.
  598. new File: hFile = fopen(string3, io_write);
  599. if (hFile)
  600. {
  601. new var[50];
  602. format(var, 32, "Key=%s\n", SInfo[i][pKey]);fwrite(hFile, var);
  603. format(var, 32, "AdminLevel=%d\n",SInfo[i][pAdmin]);fwrite(hFile, var);
  604. format(var, 32, "Registered=%d\n",SInfo[i][pReg]);fwrite(hFile, var);
  605. fclose(hFile);
  606. }
  607. }
  608. }
  609. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement