Guest User

Untitled

a guest
Jun 6th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.82 KB | None | 0 0
  1. //iBot's colour: 0x7D7D7FFF
  2. //US team's colour: {669900} 0x006D00FF
  3. //Russia team's colour: {CC0033} 0xBD0000FF
  4.  
  5. #include <a_samp>
  6. #include <string>
  7. #include <a_mysql>
  8. #include <streamer>
  9. #include <sscanf2>
  10. #include <uf>
  11. #define mysql_host "SQL09.FREEMYSQL.NET" //Has to be a string
  12. #define mysql_user "shazz" //Has to be a string
  13. #define mysql_password "trololololololol" //There is none for wamp unless you set one.
  14. #define mysql_database "shazzsampserv" //Has to be a string
  15. #define iBot 0x7D7D7FFF
  16. #define retMessPl "iBot: You have made ID %d a moderator. If this was a mistake, please use /makeregular."
  17. #define retMessBt "iBot: You are now a moderator! /moderator to view your commands."
  18. new IsRegistered[MAX_PLAYERS];
  19. new MoneyGiven[MAX_PLAYERS];
  20. new Logged[MAX_PLAYERS]; //The variable to check if the player is logged.
  21.  
  22. //NOTE:Passwordstring has already been escaped. If you want to use
  23. //this in another script, make sure that you escape the passwordstring
  24. //before you
  25. stock MySQL_Register(playerid, passwordstring[])
  26. {
  27. new query[200], pname[24], IP[16];
  28. GetPlayerName(playerid, pname, 24);
  29. GetPlayerIp(playerid, IP, 16);
  30. format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, IP) VALUES('%s', SHA1('%s'), 0, 0, '%s', 1)", pname, passwordstring, IP);
  31. mysql_query(query);
  32. //We do not need to store or free a result as it
  33. //is not a select statement. We can now send the
  34. //client a registration success message and set the
  35. //Login variable to 1.
  36. SendClientMessage(playerid, iBot, "iBot: You have been registered on this server!");
  37. Logged[playerid] = 1; //Sets the login variable
  38. return 1;
  39. }
  40.  
  41. stock MySQL_Login(playerid)
  42. {
  43. new query[300], pname[24], savingstring[20];
  44. GetPlayerName(playerid, pname, 24);
  45. format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
  46. //We only select the variables that we want to use.
  47. //We don't need things like the password string or the user string.
  48. mysql_query(query); //Queries the result
  49. mysql_store_result(); //Store a result because it's a SELECT statement.
  50. while(mysql_fetch_row_format(query,"|"))
  51. {
  52. //We use while so that it does a single query, not multiple
  53. //Especially when we have more variables. If there is more
  54. //Variables, you should just split the line with sscanf. To
  55. //Make it easier.
  56. mysql_fetch_field_row(savingstring, "score"); SetPlayerScore(playerid, strval(savingstring));
  57. mysql_fetch_field_row(savingstring, "money"); MoneyGiven[playerid] = strval(savingstring);
  58. mysql_fetch_field_row(savingstring, "adminlevel"); SetPVarInt(playerid, "AdminLevel", strval(savingstring));
  59. //If you are wondering why I'm using savingstring instead
  60. //Of a variable like using MoneyGiven right away, it's because
  61. //mysql_fetch_field_row requires a string.
  62. }
  63. mysql_free_result(); //We must always free a stored result
  64. SendClientMessage(playerid, iBot, "iBot: You have been logged in!"); //Sends the client a message.
  65. Logged[playerid] = 1; //Sets our logged in variable to one
  66. return 1;
  67. }
  68.  
  69. #if defined FILTERSCRIPT
  70.  
  71. public OnFilterScriptInit()
  72. {
  73. print("\n--------------------------------------");
  74. print(" Blank Filterscript by your name here");
  75. print("--------------------------------------\n");
  76. return 1;
  77. }
  78.  
  79. public OnFilterScriptExit()
  80. {
  81. return 1;
  82. }
  83.  
  84. #else
  85.  
  86. main()
  87. {
  88. print("\n----------------------------------");
  89. print("Battlefield 3 by Shazz");
  90. print("----------------------------------\n");
  91. }
  92.  
  93. #endif
  94.  
  95. public OnGameModeInit()
  96. {
  97. SendRconCommand("mapname Caspian Border");
  98. SetGameModeText("Battlefield 3");
  99. DisableInteriorEnterExits();
  100. UsePlayerPedAnims();
  101. mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password);
  102. mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(41), score INT(20), money INT(20), IP VARCHAR(16), adminlevel INT(2) )");
  103. //Fields:
  104. //Field Name - Use - Type
  105. //user- Player Name - String
  106. //password- Players password - String
  107. //score - Players score - int
  108. //money - Players Cash - int
  109. //IP - Players IP - int
  110. //AdminLevel - Player's Admin Level - int - (0 = regular player; 1 = supervisors; 2 = moderators; 3 = admins)
  111. return 1;
  112. }
  113.  
  114. public OnGameModeExit()
  115. {
  116. return 1;
  117. }
  118.  
  119. public OnPlayerRequestClass(playerid, classid)
  120. {
  121. SetSpawnInfo(playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  122. SpawnPlayer(playerid);
  123. TogglePlayerControllable(playerid, 0);
  124. ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Choose a Team:","{669900}US\n{CC0033}Russia","Select", ""); //team_choose
  125. return 1;
  126. }
  127.  
  128. public OnPlayerConnect(playerid)
  129. {
  130. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: {663399}Welcome to Battlefield 3 Server!");
  131. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: {663399}Scripted by: {336600}Shazz!");
  132. new string[64], pName[MAX_PLAYER_NAME];
  133. GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  134. format(string,sizeof string,"iBot: %s has joined the server.",pName);
  135. SendClientMessageToAll(0x7D7D7FFF,string);
  136. MoneyGiven[playerid] = -1; //Resets the variable that you will discover later in the tutorial.
  137. SetPVarInt(playerid, "AdminLevel", 1);
  138. new query[200], pname[24]; //Creates our variables.
  139. GetPlayerName(playerid, pname, 24); //Gets the players name
  140. format(query, sizeof(query), "SELECT IP FROM `playerdata` WHERE user = '%s' LIMIT 1", pname); //Formats the query, view above the code for a explanation
  141. mysql_query(query); //This is our query function to query the string
  142. mysql_store_result(); //We store the result.
  143. new rows = mysql_num_rows(); //We get how many rows the query returned.
  144. if(!rows)
  145. {
  146. //If the rows are equal to 0. This means that the query did not find
  147. //anyone under the name we connected under in the database.
  148. //So here we send the player the register dialog.
  149. ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Register","Enter a password below:","Register","");
  150. }
  151. if(rows == 1)
  152. {
  153. //If the rows are equal to 1, this means there is a player already registered
  154. //so we can initiate the login dialog to the player or check if the players
  155. //current IP is the same one as in the database.
  156. new IP[2][16]; //We create a variable with two IP strings, one for retrieving the mysql field and one for GetPlayerIP.
  157. mysql_fetch_field_row(IP[0],"IP");
  158. GetPlayerIp(playerid, IP[1], 16);
  159. if(strlen(IP[0]) != 0 && !strcmp(IP[0], IP[1], true)) //Checks that the MySQL IP has a value and that they are the same.
  160. {
  161. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!","Login",""); //Shows our login dialog :).
  162. IsRegistered[playerid] = 1; //Sets the registered variable to 1 (Shows that the player is registered).
  163. }
  164. else if(!strlen(IP[0]) || strcmp(IP[0], IP[1], true))
  165. {
  166. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!","Login",""); //Shows our login dialog :).
  167. IsRegistered[playerid] = 1; //Sets the registered variable to 1 (Shows that the player is registered).
  168. }
  169. }
  170. mysql_free_result();
  171. //You must always free the mysql result to avoid
  172. //there being massive memory usage.
  173. return 1;
  174. }
  175.  
  176. public OnPlayerDisconnect(playerid, reason)
  177. {
  178. SetPVarInt(playerid, "AdminLevel", 1);
  179. new string[64],
  180. name[MAX_PLAYER_NAME];
  181. GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  182. switch(reason)
  183. {
  184. case 0: format(string,sizeof string,"iBot: %s left the server. (Reason: Timed Out)",name);
  185. case 1: format(string,sizeof string,"iBot: %s left the server. (Reason: Left)",name);
  186. case 2: format(string,sizeof string,"iBot: %s left the server. (Reason: Kicked/Banned)",name);
  187. }
  188. SendClientMessageToAll(0x7D7D7FFF,string);
  189. if(Logged[playerid] == 1)
  190. {
  191. //If the player disconnects before registering,
  192. //we want to make sure it doesn't try update
  193. //so we check if the player is logged in.
  194. new score = GetPlayerScore(playerid); //Gets players score
  195. new money = GetPlayerMoney(playerid); //Gets players money
  196. new query[200], pname[24]; //Creates the variables
  197. GetPlayerName(playerid, pname, 24); //Gets the players name.
  198. format(query, sizeof(query), "UPDATE playerdata SET score=%d, money=%d adminlevel = %d WHERE user='%s'", score, money, GetPVarInt(playerid, "AdminLevel"), pname);
  199. mysql_query(query);
  200. //No need to store a result for a update string
  201. }
  202. return 1;
  203. }
  204.  
  205. public OnPlayerSpawn(playerid)
  206. {
  207. return 1;
  208. }
  209.  
  210. public OnPlayerDeath(playerid, killerid, reason)
  211. {
  212. return 1;
  213. }
  214.  
  215. public OnVehicleDeath(vehicleid, killerid)
  216. {
  217. return 1;
  218. }
  219.  
  220. public OnPlayerText(playerid, text[])
  221. {
  222. return 1;
  223. }
  224.  
  225. public OnPlayerCommandText(playerid, cmdtext[])
  226. {
  227.  
  228. if (strcmp("/makemoderator", cmdtext, true, 10) == 0)
  229. {
  230. if (IsPlayerAdmin(playerid))
  231. {
  232. ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Make someone a moderator","Put in the playerid of the person you want to make a moderator.","GO!","Cancel");
  233. }
  234. else
  235. {
  236. SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
  237. }
  238. return 1;
  239. }
  240.  
  241.  
  242. if (strcmp("/makeadmin", cmdtext, true, 10) == 0)
  243. {
  244. if (IsPlayerAdmin(playerid))
  245. {
  246. ShowPlayerDialog(playerid, 9, DIALOG_STYLE_INPUT, "Make someone an administrator","Put in the playerid of the person you want to make an administrator.","GO!","Cancel");
  247. }
  248. else
  249. {
  250. SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
  251. }
  252. return 1;
  253. }
  254.  
  255.  
  256. if (strcmp("/makesupervisor", cmdtext, true, 10) == 0)
  257. {
  258. if (IsPlayerAdmin(playerid))
  259. {
  260. ShowPlayerDialog(playerid, 10, DIALOG_STYLE_INPUT, "Make someone a supervisor.","Put in the playerid of the person you want to make a supervisor.","GO!","Cancel");
  261. }
  262. else
  263. {
  264. SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
  265. }
  266. return 1;
  267. }
  268.  
  269.  
  270.  
  271. if (strcmp("/makeregular", cmdtext, true, 10) == 0)
  272. {
  273. if (IsPlayerAdmin(playerid))
  274. {
  275. ShowPlayerDialog(playerid, 11, DIALOG_STYLE_INPUT, "Make someone a regular player","Put in the playerdid of the person you want to make a regular player.","GO!","Cancel");
  276. }
  277. else
  278. {
  279. SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
  280. }
  281. return 1;
  282. }
  283.  
  284. if (strcmp("/checkadminlevel", cmdtext, true, 10) == 0)
  285. {
  286. printf("AdminLevel: %d", GetPVarInt(playerid, "AdminLevel"));
  287. return 1;
  288. }
  289. return 0;
  290. }
  291.  
  292. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  293. {
  294. return 1;
  295. }
  296.  
  297. public OnPlayerExitVehicle(playerid, vehicleid)
  298. {
  299. return 1;
  300. }
  301.  
  302. public OnPlayerStateChange(playerid, newstate, oldstate)
  303. {
  304. return 1;
  305. }
  306.  
  307. public OnPlayerEnterCheckpoint(playerid)
  308. {
  309. return 1;
  310. }
  311.  
  312. public OnPlayerLeaveCheckpoint(playerid)
  313. {
  314. return 1;
  315. }
  316.  
  317. public OnPlayerEnterRaceCheckpoint(playerid)
  318. {
  319. return 1;
  320. }
  321.  
  322. public OnPlayerLeaveRaceCheckpoint(playerid)
  323. {
  324. return 1;
  325. }
  326.  
  327. public OnRconCommand(cmd[])
  328. {
  329. return 1;
  330. }
  331.  
  332. public OnPlayerRequestSpawn(playerid)
  333. {
  334. return 1;
  335. }
  336.  
  337. public OnObjectMoved(objectid)
  338. {
  339. return 1;
  340. }
  341.  
  342. public OnPlayerObjectMoved(playerid, objectid)
  343. {
  344. return 1;
  345. }
  346.  
  347. public OnPlayerPickUpPickup(playerid, pickupid)
  348. {
  349. return 1;
  350. }
  351.  
  352. public OnVehicleMod(playerid, vehicleid, componentid)
  353. {
  354. return 1;
  355. }
  356.  
  357. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  358. {
  359. return 1;
  360. }
  361.  
  362. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  363. {
  364. return 1;
  365. }
  366.  
  367. public OnPlayerSelectedMenuRow(playerid, row)
  368. {
  369. return 1;
  370. }
  371.  
  372. public OnPlayerExitedMenu(playerid)
  373. {
  374. return 1;
  375. }
  376.  
  377. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  378. {
  379. return 1;
  380. }
  381.  
  382. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  383. {
  384. return 1;
  385. }
  386.  
  387. public OnRconLoginAttempt(ip[], password[], success)
  388. {
  389. return 1;
  390. }
  391.  
  392. public OnPlayerUpdate(playerid)
  393. {
  394. return 1;
  395. }
  396.  
  397. public OnPlayerStreamIn(playerid, forplayerid)
  398. {
  399. return 1;
  400. }
  401.  
  402. public OnPlayerStreamOut(playerid, forplayerid)
  403. {
  404. return 1;
  405. }
  406.  
  407. public OnVehicleStreamIn(vehicleid, forplayerid)
  408. {
  409. return 1;
  410. }
  411.  
  412. public OnVehicleStreamOut(vehicleid, forplayerid)
  413. {
  414. return 1;
  415. }
  416.  
  417. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  418. {
  419. if(response){
  420. switch(dialogid){
  421. case 1:{
  422. switch(listitem){
  423. case 0: //US
  424. {
  425. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: {669900}You have joined the US Team.");
  426. SetPlayerColor(playerid, 0x006D00FF);
  427. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose your class:", "Assault\nEngineer\nSupport\nSniper","Select", ""); //us_class_choose
  428. SetPlayerSkin(playerid, 287);
  429. SetPlayerTeam(playerid, 1);
  430. }
  431. case 1: //Russia
  432. {
  433. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: {CC0033}You have joined the Russian Team.");
  434. SetPlayerColor(playerid, 0xBD0000FF);
  435. ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Choose your class:", "Assault\nEngineer\nSupport\nSniper","Select", ""); //russia_class_choose
  436. SetPlayerSkin(playerid, 73);
  437. SetPlayerTeam(playerid, 2);
  438. }
  439.  
  440. }
  441. }
  442. }
  443. }
  444. if(response){
  445. switch(dialogid){
  446. case 2:{
  447. switch(listitem){
  448. case 0: //Assault
  449. {
  450. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Assault class.");
  451. GivePlayerWeapon(playerid, 31, 1000);
  452. GivePlayerWeapon(playerid, 24, 50);
  453. GivePlayerWeapon(playerid, 16, 1);
  454. ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //us_choose_spawn
  455. }
  456. case 1: //Engineer
  457. {
  458. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Engineer class.");
  459. GivePlayerWeapon(playerid, 28, 1000);
  460. GivePlayerWeapon(playerid, 35, 4);
  461. GivePlayerWeapon(playerid, 16, 1);
  462. ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //us_choose_spawn
  463. }
  464. case 2: //Support
  465. {
  466. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Support class.");
  467. GivePlayerWeapon(playerid, 27, 500);
  468. GivePlayerWeapon(playerid, 33, 30);
  469. GivePlayerWeapon(playerid, 16, 1);
  470. ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //us_choose_spawn
  471. }
  472. case 3: //Sniper
  473. {
  474. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Sniper class.");
  475. GivePlayerWeapon(playerid, 34, 300);
  476. GivePlayerWeapon(playerid, 23, 85);
  477. GivePlayerWeapon(playerid, 16, 1);
  478. ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //us_choose_spawn
  479. }
  480.  
  481. }
  482. }
  483. }
  484. }
  485. if(response){
  486. switch(dialogid){
  487. case 3:{
  488. switch(listitem){
  489. case 0: //Assault
  490. {
  491. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Assault class.");
  492. GivePlayerWeapon(playerid, 30, 1500);
  493. GivePlayerWeapon(playerid, 22, 120);
  494. GivePlayerWeapon(playerid, 16, 1);
  495. ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //russia_choose_spawn
  496. }
  497. case 1: //Engineer
  498. {
  499. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Engineer class.");
  500. GivePlayerWeapon(playerid, 32, 800);
  501. GivePlayerWeapon(playerid, 35, 4);
  502. GivePlayerWeapon(playerid, 16, 1);
  503. ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //russia_choose_spawn
  504. }
  505. case 2: //Support
  506. {
  507. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Support class.");
  508. GivePlayerWeapon(playerid, 26, 800);
  509. GivePlayerWeapon(playerid, 33, 35);
  510. GivePlayerWeapon(playerid, 16, 1);
  511. ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //russia_choose_spawn
  512. }
  513. case 3: //Sniper
  514. {
  515. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Sniper class.");
  516. GivePlayerWeapon(playerid, 34, 300);
  517. GivePlayerWeapon(playerid, 23, 85);
  518. GivePlayerWeapon(playerid, 16, 1);
  519. ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //russia_choose_spawn
  520. }
  521.  
  522. }
  523. }
  524. }
  525. }
  526. if(response){
  527. switch(dialogid){
  528. case 4:{
  529. switch(listitem){
  530. case 0: //US Base
  531. {
  532. SetPlayerPos(playerid,285.5240,2037.3401,17.6406);
  533. TogglePlayerControllable(playerid, 1);
  534. if(MoneyGiven[playerid] != -1)
  535. {
  536. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  537. MoneyGiven[playerid] = -1;
  538. }
  539. //Gives the player money if they haven't received it yet
  540. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  541. {
  542. if(!IsRegistered[playerid]) //If the player isn't registered
  543. {
  544. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  545. return 0; //Prevents the player from spawning
  546. }
  547. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  548. {
  549. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  550. return 0; //Prevents the player from spawning
  551. }
  552. }
  553. }
  554. case 1: //Sattelite
  555. {
  556. SetPlayerPos(playerid,-314.0954,1544.5754,75.5625);
  557. TogglePlayerControllable(playerid, 1);
  558. if(MoneyGiven[playerid] != -1)
  559. {
  560. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  561. MoneyGiven[playerid] = -1;
  562. }
  563. //Gives the player money if they haven't received it yet
  564. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  565. {
  566. if(!IsRegistered[playerid]) //If the player isn't registered
  567. {
  568. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  569. return 0; //Prevents the player from spawning
  570. }
  571. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  572. {
  573. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  574. return 0; //Prevents the player from spawning
  575. }
  576. }
  577. }
  578. case 2: //Gas Station
  579. {
  580. SetPlayerPos(playerid,663.0021,1694.6088,7.1875);
  581. TogglePlayerControllable(playerid, 1);
  582. if(MoneyGiven[playerid] != -1)
  583. {
  584. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  585. MoneyGiven[playerid] = -1;
  586. }
  587. //Gives the player money if they haven't received it yet
  588. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  589. {
  590. if(!IsRegistered[playerid]) //If the player isn't registered
  591. {
  592. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  593. return 0; //Prevents the player from spawning
  594. }
  595. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  596. {
  597. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  598. return 0; //Prevents the player from spawning
  599. }
  600. }
  601. }
  602. case 3: //Village
  603. {
  604. SetPlayerPos(playerid,-59.1335,920.0255,21.9530);
  605. TogglePlayerControllable(playerid, 1);
  606. if(MoneyGiven[playerid] != -1)
  607. {
  608. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  609. MoneyGiven[playerid] = -1;
  610. }
  611. //Gives the player money if they haven't received it yet
  612. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  613. {
  614. if(!IsRegistered[playerid]) //If the player isn't registered
  615. {
  616. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  617. return 0; //Prevents the player from spawning
  618. }
  619. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  620. {
  621. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  622. return 0; //Prevents the player from spawning
  623. }
  624. }
  625. }
  626. case 4: //Town
  627. {
  628. SetPlayerPos(playerid,-156.3550,1176.6068,19.7422);
  629. TogglePlayerControllable(playerid, 1);
  630. if(MoneyGiven[playerid] != -1)
  631. {
  632. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  633. MoneyGiven[playerid] = -1;
  634. }
  635. //Gives the player money if they haven't received it yet
  636. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  637. {
  638. if(!IsRegistered[playerid]) //If the player isn't registered
  639. {
  640. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  641. return 0; //Prevents the player from spawning
  642. }
  643. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  644. {
  645. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  646. return 0; //Prevents the player from spawning
  647. }
  648. }
  649. }
  650. }
  651. }
  652. }
  653. }
  654. if(response){
  655. switch(dialogid){
  656. case 5:{
  657. switch(listitem){
  658. case 0: //Russia Base
  659. {
  660. SetPlayerPos(playerid,405.0172,2535.2886,16.5460);
  661. TogglePlayerControllable(playerid, 1);
  662. if(MoneyGiven[playerid] != -1)
  663. {
  664. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  665. MoneyGiven[playerid] = -1;
  666. }
  667. //Gives the player money if they haven't received it yet
  668. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  669. {
  670. if(!IsRegistered[playerid]) //If the player isn't registered
  671. {
  672. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  673. return 0; //Prevents the player from spawning
  674. }
  675. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  676. {
  677. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  678. return 0; //Prevents the player from spawning
  679. }
  680. }
  681. }
  682. case 1: //Sattelite
  683. {
  684. SetPlayerPos(playerid,-314.0954,1544.5754,75.5625);
  685. TogglePlayerControllable(playerid, 1);
  686. if(MoneyGiven[playerid] != -1)
  687. {
  688. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  689. MoneyGiven[playerid] = -1;
  690. }
  691. //Gives the player money if they haven't received it yet
  692. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  693. {
  694. if(!IsRegistered[playerid]) //If the player isn't registered
  695. {
  696. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  697. return 0; //Prevents the player from spawning
  698. }
  699. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  700. {
  701. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  702. return 0; //Prevents the player from spawning
  703. }
  704. }
  705. }
  706. case 2: //Gas Station
  707. {
  708. SetPlayerPos(playerid,663.0021,1694.6088,7.1875);
  709. TogglePlayerControllable(playerid, 1);
  710. if(MoneyGiven[playerid] != -1)
  711. {
  712. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  713. MoneyGiven[playerid] = -1;
  714. }
  715. //Gives the player money if they haven't received it yet
  716. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  717. {
  718. if(!IsRegistered[playerid]) //If the player isn't registered
  719. {
  720. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  721. return 0; //Prevents the player from spawning
  722. }
  723. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  724. {
  725. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  726. return 0; //Prevents the player from spawning
  727. }
  728. }
  729. }
  730. case 3: //Village
  731. {
  732. SetPlayerPos(playerid,-59.1335,920.0255,21.9530);
  733. TogglePlayerControllable(playerid, 1);
  734. if(MoneyGiven[playerid] != -1)
  735. {
  736. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  737. MoneyGiven[playerid] = -1;
  738. }
  739. //Gives the player money if they haven't received it yet
  740. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  741. {
  742. if(!IsRegistered[playerid]) //If the player isn't registered
  743. {
  744. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  745. return 0; //Prevents the player from spawning
  746. }
  747. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  748. {
  749. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  750. return 0; //Prevents the player from spawning
  751. }
  752. }
  753. }
  754. case 4: //Town
  755. {
  756. SetPlayerPos(playerid,-156.3550,1176.6068,19.7422);
  757. TogglePlayerControllable(playerid, 1);
  758. if(MoneyGiven[playerid] != -1)
  759. {
  760. GivePlayerMoney(playerid, MoneyGiven[playerid]);
  761. MoneyGiven[playerid] = -1;
  762. }
  763.  
  764. //Gives the player money if they haven't received it yet
  765. if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
  766. {
  767. if(!IsRegistered[playerid]) //If the player isn't registered
  768. {
  769. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
  770. return 0; //Prevents the player from spawning
  771. }
  772. if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
  773. {
  774. ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
  775. return 0; //Prevents the player from spawning
  776. }
  777. }
  778. }
  779. }
  780. }
  781. }
  782. }
  783. {
  784.  
  785. }
  786. if(dialogid == 6) //If Dialog is our register dialog
  787. {
  788. if(response) //If they click the button register
  789. {
  790. if(!strlen(inputtext) || strlen(inputtext) > 100) //Password is not 1 to 100 characters
  791. {
  792. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You must insert a password between 1-100 characters!"); //Sends the client a error message
  793. ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:Please enter a password between 1-100 characters!","Register",""); //Shows our register dialog :).
  794. }
  795. else if(strlen(inputtext) > 0 && strlen(inputtext) < 100)
  796. {
  797. new escpass[100];
  798. mysql_real_escape_string(inputtext, escpass);
  799. MySQL_Register(playerid, escpass);
  800. new password[128];
  801. format(password, sizeof(password), "iBot: You registered with password: %s", inputtext);
  802. }
  803. //If the password is between 1 and 100 characters then we will
  804. //call our MySQL_register function which will register the player.
  805. }
  806. }
  807. if(dialogid == 7) //Dialog login
  808. {
  809.  
  810. if(response) //If the player clicked login
  811. {
  812. new query[200], pname[24], escapepass[100]; //
  813. GetPlayerName(playerid, pname, 24); //Gets the players name
  814. mysql_real_escape_string(inputtext, escapepass); //We escape the inputtext to avoid SQL injections.
  815. format(query, sizeof(query), "SELECT `user` FROM playerdata WHERE user = '%s' AND password = SHA1('%s')", pname, escapepass);
  816. mysql_query(query);
  817. mysql_store_result();
  818. new numrows = mysql_num_rows();
  819. if(numrows == 1) MySQL_Login(playerid);
  820. //This means that there is a user in the database with the same
  821. //password that we typed, we now proceed by using the login function.
  822. if(!numrows)
  823. {
  824. //This means that the password that the player
  825. //typed was incorrect and we will resend the dialog.
  826. //ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} The password you typed was incorrect!","Login","Cancel"); //Shows our login dialog :).
  827. SendClientMessage(playerid, 0x7D7D7FFF, "iBot: Incorrect password!"); //Sends the client a error message
  828. Kick(playerid);
  829. }
  830. mysql_free_result(); //Remember to always free a result if you stored one!
  831. }
  832. }
  833.  
  834. if(dialogid == 8) //Make Moderator
  835. {
  836.  
  837. if(response) //If the player clicked GO!
  838. {
  839. /*new string[4] = (inputtext[8]);
  840. new Iplayerid = strval(string);
  841. SetPVarInt(Iplayerid, "AdminLevel", 3);
  842. new string1[24];
  843. format(string1, sizeof(string1), "iBot: You have made ID %d a moderator. If this was a mistake, please use /makeregular.", Iplayerid);
  844. SendClientMessage(playerid, iBot, string1);
  845. SendClientMessage(Iplayerid, iBot, "iBot: You are now a moderator! /moderator to view your commands.");*/
  846. if (IsNumeric(inputtext))
  847. {
  848. print("test worked");
  849. new playerIDFS = strval(inputtext);
  850. SetPVarInt(playerIDFS,"AdminLevel",3);
  851. new clientMessage[240];
  852. format(clientMessage,240,retMessPl, playerIDFS);
  853. SendClientMessage(playerid, iBot, clientMessage);
  854. SendClientMessage(playerIDFS, iBot, retMessBt);
  855. }
  856. }
  857. }
  858.  
  859. if(dialogid == 9) //Make Admin
  860. {
  861.  
  862. if(response) //If the player clicked GO!
  863. {
  864. //
  865. new youmadeadmin[24];
  866. format(youmadeadmin, sizeof(youmadeadmin), "iBot: You have made ID %s an admin. If this was a mistake, please use /makeregular.", inputtext[9]);
  867. SendClientMessage(playerid, iBot, youmadeadmin);
  868. SendClientMessage(inputtext[8], iBot, "iBot: You are now an admin! /admincmds to view your commands.");
  869. }
  870. }
  871.  
  872. if(dialogid == 10) //Make Supervisor
  873. {
  874.  
  875. if(response) //If the player clicked GO!
  876. {
  877. //
  878. new youmadeadmin[24];
  879. format(youmadeadmin, sizeof(youmadeadmin), "iBot: You have made ID %s a supervisor. If this was a mistake, please use /makeregular.", inputtext[10]);
  880. SendClientMessage(playerid, iBot, youmadeadmin);
  881. SendClientMessage(inputtext[8], iBot, "iBot: You are now a supervisor! /supervisorcmds to view your commands.");
  882. }
  883. }
  884.  
  885. if(dialogid == 11) //Make Regular
  886. {
  887.  
  888. if(response) //If the player clicked GO!
  889. {
  890. //
  891. new string[24];
  892. format(string, sizeof(string), "iBot: You have made ID %s a regular player. If this was a mistake, please use /makeadmin, /makemoderator or /makesupervisor.", inputtext[11]);
  893. SendClientMessage(playerid, iBot, string);
  894. SendClientMessage(inputtext[11], iBot, "iBot: You are now a regular player! /cmds to view your commands.");
  895. }
  896. }
  897.  
  898. return 1;
  899. }
  900.  
  901. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  902. {
  903. return 1;
  904. }
Add Comment
Please, Sign In to add comment