Advertisement
Guest User

Untitled

a guest
Dec 4th, 2015
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.98 KB | None | 0 0
  1. //Include--
  2. #include <a_samp>
  3. #include <YSI\y_ini>
  4. #include <zcmd>
  5.  
  6.  
  7. //Forward--
  8. forward LoadUser_data(playerid,name[],value[]);
  9.  
  10. //Enum--
  11. enum pInfo
  12. {
  13. pPassword,
  14. pCash,
  15. pAdmin,
  16. pBanned,
  17. pBanName,
  18. pBanBy,
  19. pBanReason,
  20. Skin,
  21. Float:Xpos,
  22. Float:Ypos,
  23. Float:Zpos,
  24. Float:Anglelog
  25. }
  26.  
  27. //New--
  28. new pAntiHackSawnOff[MAX_PLAYERS]; // 1=Accepted, 0=Hacked
  29. new PlayerInfo[MAX_PLAYERS][pInfo];
  30.  
  31. //Define--
  32. #define Dialog_Register_Password 1
  33. #define Dialog_Login_Password 2
  34.  
  35. #define Dialog_AntiHackSawnOffMessage 3
  36. #define Dialog_AntiHackSawnOffAppeal 4
  37.  
  38. #define PATH "/Users/%s.ini"
  39.  
  40. #define Dialog_Color_Red "{F81414}"
  41.  
  42. //Main--
  43. main()
  44. {
  45. print("Roleplay GameMode Loaded.");
  46. }
  47.  
  48. //Public--
  49. public OnGameModeInit()
  50. {
  51. SetGameModeText("Blank Script");
  52. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  53. return 1;
  54. }
  55.  
  56. public OnGameModeExit()
  57. {
  58. return 1;
  59. }
  60.  
  61. public OnPlayerConnect(playerid)
  62. {
  63. pAntiHackSawnOff[playerid] = 0;
  64. if(fexist(UserPath(playerid)))
  65. {
  66. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  67. if(PlayerInfo[playerid][pBanned] == 1)
  68. {
  69. new stringban[2000];
  70. format(stringban, sizeof(stringban), "{FFFFFF}You {FC4949}%s{FFFFFF} have been banned by %s for: %s\nPlease write your appael below to let admins judge it.", PlayerInfo[playerid][pBanName], PlayerInfo[playerid][pBanBy], PlayerInfo[playerid][pBanReason]);
  71. ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffAppeal, DIALOG_STYLE_MSGBOX, "{FC4949}Banned!", stringban, "Send", "Quit");
  72. }
  73. else
  74. {
  75. ShowPlayerDialog(playerid, Dialog_Login_Password, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
  76. }
  77. }
  78. else
  79. {
  80. ShowPlayerDialog(playerid, Dialog_Register_Password, DIALOG_STYLE_INPUT,"Registering...","Type your password below to register a new account.","Register","Quit");
  81. }
  82. return 1;
  83. }
  84.  
  85. public OnPlayerDisconnect(playerid, reason)
  86. {
  87. new Float:Xlog, Float:Ylog, Float:Zlog, Float:Angle;
  88. GetPlayerFacingAngle(playerid, Angle);
  89. GetPlayerPos(playerid, Xlog, Ylog, Zlog);
  90. PlayerInfo[playerid][Xpos] = Xlog;
  91. PlayerInfo[playerid][Ypos] = Ylog;
  92. PlayerInfo[playerid][Zpos] = Zlog;
  93. PlayerInfo[playerid][Anglelog] = Angle;
  94. new playerskin = GetPlayerSkin(playerid);
  95. new INI:File = INI_Open(UserPath(playerid));
  96. INI_SetTag(File,"data");
  97. INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  98. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  99. INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
  100. INI_WriteInt(File,"BanName",PlayerInfo[playerid][pBanName]);
  101. INI_WriteInt(File,"BanBy",PlayerInfo[playerid][pBanBy]);
  102. INI_WriteInt(File,"BanReason",PlayerInfo[playerid][pBanReason]);
  103. INI_WriteInt(File,"Skin",playerskin);
  104. INI_WriteFloat(File,"Xpos",PlayerInfo[playerid][Xpos]);
  105. INI_WriteFloat(File,"Ypos",PlayerInfo[playerid][Ypos]);
  106. INI_WriteFloat(File,"Zpos",PlayerInfo[playerid][Zpos]);
  107. INI_WriteFloat(File,"Anglelog",PlayerInfo[playerid][Anglelog]);
  108. INI_Close(File);
  109. return 1;
  110. }
  111.  
  112. public OnPlayerUpdate(playerid)
  113. {
  114. if(GetPlayerWeapon(playerid) == 26)
  115. {
  116. if(pAntiHackSawnOff[playerid] == 0)
  117. {
  118. new name[MAX_PLAYER_NAME], BanReasonString[17], BanByString[10];
  119. GetPlayerName(playerid, name, sizeof(name));
  120. format(BanReasonString, sizeof(BanReasonString), "Sawn Off Hacking");
  121. format(BanByString, sizeof(BanByString), "Anti Hack");
  122. PlayerInfo[playerid][pBanned] = 1;
  123. PlayerInfo[playerid][pBanName] = name[playerid];
  124. PlayerInfo[playerid][pBanBy] = BanByString;
  125. PlayerInfo[playerid][pBanReason] = BanReasonString;
  126.  
  127. ResetPlayerWeapons(playerid);
  128. ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffMessage, DIALOG_STYLE_MSGBOX, ""Dialog_Color_Red"Banned!", "[Anti-Hack] You have been banned by the Anti-Hack system for: Sawn Off Hack.", "Appael", "Quit");
  129. }
  130. }
  131. return 1;
  132. }
  133.  
  134. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  135. {
  136. switch(dialogid)
  137. {
  138. case Dialog_AntiHackSawnOffMessage:
  139. {
  140. if(!response)
  141. {
  142. Kick(playerid);
  143. }
  144. if(response)
  145. {
  146. ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffAppeal, DIALOG_STYLE_INPUT, ""Dialog_Color_Red"Banned!","[Anti-Hack] You have been banned by the Anti-Hack system for: Sawn Off Hack.\nPlease write your appael below to let admins judge it.","Appael","Quit");
  147. }
  148. }
  149.  
  150. case Dialog_AntiHackSawnOffAppeal:
  151. {
  152. if(!response)
  153. {
  154. Kick(playerid);
  155. }
  156. if(response)
  157. {
  158. ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffAppeal, DIALOG_STYLE_INPUT, ""Dialog_Color_Red"Banned!","[Anti-Hack] You have been banned by the Anti-Hack system for: Sawn Off Hack.\nPlease write your appael below to let admins judge it.","Appael","Quit");
  159. }
  160. }
  161. case Dialog_Register_Password:
  162. {
  163. if (!response) return Kick(playerid);
  164. if(response)
  165. {
  166. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, Dialog_Register_Password, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
  167. new INI:File = INI_Open(UserPath(playerid));
  168. INI_SetTag(File,"data");
  169. INI_WriteInt(File,"Password",udb_hash(inputtext));
  170. INI_WriteInt(File,"Cash",0);
  171. INI_WriteInt(File,"Admin",0);
  172. INI_WriteInt(File,"Banned",0);
  173. INI_WriteInt(File,"BanName",0);
  174. INI_WriteInt(File,"BanBy",0);
  175. INI_WriteInt(File,"BanReason",0);
  176. INI_WriteInt(File,"Skin",0);
  177. INI_WriteInt(File,"Xpos",0);
  178. INI_WriteInt(File,"Ypos",0);
  179. INI_WriteInt(File,"Zpos",0);
  180. INI_WriteInt(File,"Anglelog",0);
  181. INI_Close(File);
  182.  
  183. SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  184. SpawnPlayer(playerid);
  185. }
  186. }
  187.  
  188. case Dialog_Login_Password:
  189. {
  190. if ( !response ) return Kick ( playerid );
  191. if( response )
  192. {
  193. if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
  194. {
  195. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  196. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  197. SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
  198. SetPlayerFacingAngle(playerid, PlayerInfo[playerid][Anglelog]);
  199. SetPlayerPos(playerid, PlayerInfo[playerid][Xpos], PlayerInfo[playerid][Ypos], PlayerInfo[playerid][Zpos]+0.3);
  200. SetSpawnInfo(playerid, PlayerInfo[playerid][Skin], PlayerInfo[playerid][Skin], PlayerInfo[playerid][Xpos], PlayerInfo[playerid][Ypos], PlayerInfo[playerid][Zpos]+0.3, PlayerInfo[playerid][Anglelog], 0, 0, 0, 0, 0, 0);
  201. SpawnPlayer(playerid);
  202. }
  203. else
  204. {
  205. ShowPlayerDialog(playerid, Dialog_Login_Password, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
  206. }
  207. return 1;
  208. }
  209. }
  210. }
  211. return 1;
  212. }
  213.  
  214. public LoadUser_data(playerid,name[],value[])
  215. {
  216. INI_Int("Password",PlayerInfo[playerid][pPassword]);
  217. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  218. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  219. INI_Int("Banned",PlayerInfo[playerid][pBanned]);
  220. INI_Int("BanName",PlayerInfo[playerid][pBanName]);
  221. INI_Int("BanBy",PlayerInfo[playerid][pBanBy]);
  222. INI_Int("BanReason",PlayerInfo[playerid][pBanReason]);
  223. INI_Int("Skin",PlayerInfo[playerid][Skin]);
  224. INI_Float("Xpos",PlayerInfo[playerid][Xpos]);
  225. INI_Float("Ypos",PlayerInfo[playerid][Ypos]);
  226. INI_Float("ZXpos",PlayerInfo[playerid][Zpos]);
  227. INI_Float("Anglelog",PlayerInfo[playerid][Anglelog]);
  228. return 1;
  229. }
  230.  
  231. //CMD--
  232. CMD:gunsawnofftrue(playerid, params[])
  233. {
  234. pAntiHackSawnOff[playerid] = 1;
  235. GivePlayerWeapon(playerid, 26, 64);
  236. return 1;
  237. }
  238.  
  239. CMD:gunsawnoff(playerid, params[]) // Hack Test
  240. {
  241. GivePlayerWeapon(playerid, 26, 64);
  242. return 1;
  243. }
  244.  
  245. //Stock--
  246. stock UserPath(playerid)
  247. {
  248. new string[128],playername[MAX_PLAYER_NAME];
  249. GetPlayerName(playerid,playername,sizeof(playername));
  250. format(string,sizeof(string),PATH,playername);
  251. return string;
  252. }
  253.  
  254.  
  255.  
  256. stock udb_hash(buf[]) {
  257. new length=strlen(buf);
  258. new s1 = 1;
  259. new s2 = 0;
  260. new n;
  261. for (n=0; n<length; n++)
  262. {
  263. s1 = (s1 + buf[n]) % 65521;
  264. s2 = (s2 + s1) % 65521;
  265. }
  266. return (s2 << 16) + s1;
  267. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement