Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.58 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <a_mysql>
  7. #include <zcmd>
  8. #include <Float>
  9. #define WHITE 0xFFFFFFF
  10. #define SQL_HOST "64.120.14.202"
  11. #define SQL_USER "tkz227_rvrp"
  12. #define SQL_PASS "tyler5240"
  13. #define SQL_DB "tkz227_rvrp"
  14. #define mysql_fetch_row(%1) mysql_fetch_row_format(%1,"|")
  15. #undef MAX_PLAYERS
  16. #define MAX_PLAYERS 40 // Put this as low as you could!
  17. new PlayerLogged[MAX_PLAYERS];
  18.  
  19. #define DIALOG_REGISTER 1
  20.  
  21. #define DIALOG_LOGIN 2
  22.  
  23. main()
  24. {
  25. print("\n----------------------------------");
  26. print(" Blank Gamemode by your name here");
  27. print("----------------------------------\n");
  28. }
  29. forward ConnectMySQL();
  30. public ConnectMySQL()
  31. {
  32. if(mysql_connect(SQL_HOST,SQL_USER,SQL_DB,SQL_PASS))
  33. {
  34. mysql_debug(1);
  35. printf("[MYSQL]: Connection to `%s` succesful!",SQL_DB);
  36.  
  37. }
  38. else
  39. {
  40. printf("[MYSQL]: [ERROR]: Connection to `%s` failed!",SQL_DB);
  41. }
  42.  
  43. return 1;
  44. }
  45. CheckMySQL()
  46. {
  47. if(mysql_ping() == -1)
  48. mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
  49. }
  50. enum Player
  51. {
  52. AdminLevel,
  53. Cash,
  54. Skin
  55.  
  56. }
  57. new PlayerInfo[MAX_PLAYERS][Player];
  58.  
  59. CheckAccountExists(account[])
  60. {
  61. new string[128];
  62. format(string, sizeof(string), "SELECT * FROM user WHERE user = '%s'", account);
  63. mysql_query(string);
  64.  
  65. mysql_store_result();
  66.  
  67. new value;
  68. value = mysql_num_rows();
  69. mysql_free_result();
  70. return value;
  71. }
  72. public OnGameModeInit()
  73. {
  74. ConnectMySQL();
  75. // Don't use these lines if it's a filterscript
  76. SetGameModeText("Blank Script");
  77. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  78. return 1;
  79. }
  80.  
  81. public OnGameModeExit()
  82. {
  83. return 1;
  84. }
  85.  
  86. public OnPlayerRequestClass(playerid, classid)
  87. {
  88. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  89. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  90. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  91. return 1;
  92. }
  93.  
  94. public OnPlayerConnect(playerid)
  95. {
  96. new playername[MAX_PLAYER_NAME];
  97. GetPlayerName(playerid, playername, sizeof(playername));
  98. if(CheckAccountExists(playername))
  99. {
  100. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please input your password in the box below:", "Login", "Cancel");
  101. }
  102. else
  103. {
  104. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", "This account is not registered. Please input your desired\npassword in the box below:", "Register", "Cancel");
  105. }
  106. return 1;
  107. }
  108.  
  109. public OnPlayerDisconnect(playerid, reason)
  110. {
  111. new user[MAX_PLAYER_NAME];
  112. GetPlayerName(playerid,user,sizeof(user));
  113. new string[128];
  114. PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
  115. PlayerInfo[playerid][Cash] = GetPlayerMoney(playerid);
  116. format(string, sizeof(string), "UPDATE user WHERE username = '%s' SET admin='%i' cash='%i' skin '%i'", user, PlayerInfo[playerid][AdminLevel], PlayerInfo[playerid][Cash], PlayerInfo[playerid][Skin]);
  117. mysql_query(string);
  118. return 1;
  119. }
  120.  
  121. public OnPlayerSpawn(playerid)
  122. {
  123. SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
  124. return 1;
  125. }
  126.  
  127. public OnPlayerDeath(playerid, killerid, reason)
  128. {
  129. return 1;
  130. }
  131.  
  132. public OnVehicleSpawn(vehicleid)
  133. {
  134. return 1;
  135. }
  136.  
  137. public OnVehicleDeath(vehicleid, killerid)
  138. {
  139. return 1;
  140. }
  141.  
  142. public OnPlayerText(playerid, text[])
  143. {
  144. return 1;
  145. }
  146.  
  147. public OnPlayerCommandText(playerid, cmdtext[])
  148. {
  149. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  150. {
  151. // Do something here
  152. return 1;
  153. }
  154. return 0;
  155. }
  156.  
  157. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  158. {
  159. return 1;
  160. }
  161.  
  162. public OnPlayerExitVehicle(playerid, vehicleid)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnPlayerStateChange(playerid, newstate, oldstate)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnPlayerEnterCheckpoint(playerid)
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerLeaveCheckpoint(playerid)
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnPlayerEnterRaceCheckpoint(playerid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnPlayerLeaveRaceCheckpoint(playerid)
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnRconCommand(cmd[])
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnPlayerRequestSpawn(playerid)
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnObjectMoved(objectid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnPlayerObjectMoved(playerid, objectid)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnPlayerPickUpPickup(playerid, pickupid)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnVehicleMod(playerid, vehicleid, componentid)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnPlayerSelectedMenuRow(playerid, row)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerExitedMenu(playerid)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnRconLoginAttempt(ip[], password[], success)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnPlayerUpdate(playerid)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnPlayerStreamIn(playerid, forplayerid)
  263. {
  264. return 1;
  265. }
  266.  
  267. public OnPlayerStreamOut(playerid, forplayerid)
  268. {
  269. return 1;
  270. }
  271.  
  272. public OnVehicleStreamIn(vehicleid, forplayerid)
  273. {
  274. return 1;
  275. }
  276.  
  277. public OnVehicleStreamOut(vehicleid, forplayerid)
  278. {
  279. return 1;
  280. }
  281.  
  282. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  283. {
  284. if(dialogid == DIALOG_REGISTER)
  285. {
  286. if(response == 1)
  287. {
  288. CheckMySQL();
  289. new string[128];
  290. new playername[MAX_PLAYER_NAME];
  291. GetPlayerName(playerid, playername, sizeof(playername));
  292. format(string, sizeof(string), "INSERT INTO user (username, pass) VALUES ('%s', '%s')", playername, inputtext);
  293. mysql_query(string);
  294. SendClientMessage(playerid, 0xFFFFFFFF, "Thank you for registering. Now you must log in.");
  295. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please input your password in the box below:", "Login", "Cancel");
  296. }
  297. }
  298. if(dialogid == DIALOG_LOGIN)
  299. {
  300. if(response == 1)
  301. {
  302. new playername[MAX_PLAYER_NAME];
  303. GetPlayerName(playerid, playername, sizeof(playername));
  304. new string[128];
  305. format(string, sizeof(string), "SELECT * FROM user WHERE username = '%s' AND pass = '%s'", playername, inputtext);
  306. mysql_query(string);
  307. mysql_store_result();
  308. if(!mysql_num_rows()) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: That password is incorrect!");
  309. new row[128];
  310. new field[4][32];
  311. mysql_fetch_row_format(row, "|");
  312. explode(row, field, "|");
  313. mysql_free_result();
  314. PlayerInfo[playerid][AdminLevel] = strval(field[1]);
  315. PlayerInfo[playerid][Cash] = strval(field[2]);
  316. PlayerInfo[playerid][Skin] = strval(field[3]);
  317. SendClientMessage(playerid, 0xFFFFFFFF, "Thank you for logging in!");
  318. GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
  319. PlayerLogged[playerid] = 1;
  320. }
  321. }
  322. return 1;
  323. }
  324.  
  325. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  326. {
  327. return 1;
  328. }
  329. explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) // Created by Westie
  330. {
  331. new
  332. iNode,
  333. iPointer,
  334. iPrevious = -1,
  335. iDelimiter = strlen(sDelimiter);
  336.  
  337. while(iNode < iVertices)
  338. {
  339. iPointer = strfind(sSource, sDelimiter, false, iPointer);
  340.  
  341. if(iPointer == -1)
  342. {
  343. strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
  344. break;
  345. }
  346. else
  347. {
  348. strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
  349. }
  350.  
  351. iPrevious = (iPointer += iDelimiter);
  352. ++iNode;
  353. }
  354. return iPrevious;
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement