Advertisement
BoxBoy

Untitled

Feb 13th, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.55 KB | None | 0 0
  1. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  2. {
  3. if(dialogid == dregister) //If dialog id is a register dialog
  4. {//then
  5. if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
  6. if(response) //if they clicked the first button "Register"
  7. {//then
  8. if(!strlen(inputtext)) //If they didn't enter any password
  9. {// then we will tell to them to enter the password to register
  10. ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
  11. return 1;
  12. }
  13. //If they have entered a correct password for his/her account...
  14. new hashpass[129]; //Now we will create a new variable to hash his/her password
  15. WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
  16. new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
  17. INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
  18. INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
  19. INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
  20. INI_WriteInt(file,"VIPLevel",0);//As explained above
  21. INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
  22. INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
  23. INI_WriteInt(file,"Kills",0);//As explained above
  24. INI_WriteInt(file,"Deaths",0);//As explained above
  25. INI_Close(file);//Now after we've done saving their data, we now need to close the file
  26. SendClientMessage(playerid,-1,"You have been successfully registered");//Tell to them that they have successfully registered a new account
  27. return 1;
  28. }
  29. }
  30. if(dialogid == dlogin) //If dialog id is a login dialog
  31. {//then
  32. if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
  33. if(response) //if they clicked the first button "Register"
  34. {//then
  35. new hashpass[129]; //Will create a new variable to hash his/her password
  36. WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
  37. if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
  38. {//then
  39. INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
  40. SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
  41. GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
  42. SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
  43. }
  44. else //If they've entered an incorrect password
  45. {//then
  46. ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
  47. return 1;
  48. }
  49. }
  50. }
  51. if(dialogid == 1)
  52. {
  53. new Float:x,Float:y,Float:z;
  54. if(response)
  55. {
  56. switch(listitem)
  57. {
  58. case 0:
  59. {
  60. GetPlayerPos(playerid,x,y,z);
  61. CreateVehicle(411,x-3.0,y,z,0.0,1,1,300);
  62. }
  63. case 1:
  64. {
  65. GetPlayerPos(playerid,x,y,z);
  66. CreateVehicle(569,x-3.0,y,z,0.0,1,3,300);
  67. }
  68. case 2:
  69. {
  70. GetPlayerPos(playerid,x,y,z);
  71. CreateVehicle(468,x-3.0,y,z,0.0,1,0,300);
  72. }
  73. case 3:
  74. {
  75. GetPlayerPos(playerid,x,y,z);
  76. CreateVehicle(451,x-3.0,y,z,0.0,0,1,300);
  77. }
  78. case 4:
  79. {
  80. GetPlayerPos(playerid,x,y,z);
  81. CreateVehicle(443,x-3.0,y,z,0.0,1,1,300);
  82. }
  83. case 5:
  84. {
  85. GetPlayerPos(playerid,x,y,z);
  86. CreateVehicle(522,x-3.0,y,z,0.0,1,1,300);
  87. }
  88. }
  89. }
  90. }
  91. return 1;
  92. }
  93. if(dialogid == 2)
  94. {
  95. if(response)
  96. {
  97. switch(listitem)
  98. {
  99. case 0:
  100. {
  101. if(GetPlayerMoney(playerid) <1500) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item! chea!");
  102. SendClientMessage(playerid, COLOR_GRAD, "You bought a deagle for 15k!");
  103. GivePlayerMoney(playerid, -1500);
  104. GivePlayerWeapon(playerid,24, 9999999);
  105. }
  106. case 1:
  107. {
  108. if(GetPlayerMoney(playerid) <2500) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
  109. SendClientMessage(playerid, COLOR_GRAD, "You bought a shotgun for 2.5k!");
  110. GivePlayerMoney(playerid, -2500);
  111. GivePlayerWeapon(playerid, 25, 9999999);
  112. }
  113. case 2:
  114. {
  115. if(GetPlayerMoney(playerid) <5000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
  116. SendClientMessage(playerid, COLOR_GRAD, "You bought an MP5 for 5k!");
  117. GivePlayerMoney(playerid, -5000);
  118. GivePlayerWeapon(playerid, 29 ,9999999);
  119. }
  120. case 3:
  121. {
  122. if(GetPlayerMoney(playerid) <170000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
  123. SendClientMessage(playerid, COLOR_GRAD, "You bought a spas12 for 170k!");
  124. GivePlayerMoney(playerid, -170000);
  125. GivePlayerWeapon(playerid, 27, 9999999);
  126. }
  127. case 4:
  128. {
  129. if(GetPlayerMoney(playerid) <50000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
  130. SendClientMessage(playerid, COLOR_GRAD, "You bought an AK-47 for 50k!");
  131. GivePlayerMoney(playerid, -50000);
  132. GivePlayerWeapon(playerid,30 ,9999999);
  133. }
  134. case 5:
  135. {
  136. if(GetPlayerMoney(playerid) <60000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
  137. SendClientMessage(playerid, COLOR_GRAD, "You bought an M4 for 60k!");
  138. GivePlayerMoney(playerid, -60000);
  139. GivePlayerWeapon(playerid, 31, 9999999);
  140. }
  141. case 6:
  142. {
  143. if(GetPlayerMoney(playerid) <150000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
  144. SendClientMessage(playerid, COLOR_GRAD, "You bought a sniper for 150k!");
  145. GivePlayerMoney(playerid, -150000);
  146. GivePlayerWeapon(playerid, 34, 9999999);
  147. }
  148. return 1;
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement