Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. #include <a_samp>
  2. #include <crashdetect>
  3. #include <a_mysql>
  4.  
  5.  
  6. //-------| Define's
  7. //---> Server
  8. #define SERVERDISPLAYNAME1 ".::: City"
  9. #define SERVERDISPLAYNAME2 "..:: City of"
  10. #define SERVERDISPLAYNAME3 "..:: City of Roleplay ::.."
  11. #define SERVERNAME "City of Roleplay"
  12. #define SERVERTAG "CoR"
  13. #define SERVERCOLOR ""
  14. #define SCRIPT_VERSION "1.0.0"
  15.  
  16.  
  17. //---> MySQL
  18. #define SQL_HOST "127.0.0.1"
  19. #define SQL_PASS ""
  20. #define SQL_USER "root"
  21. #define SQL_DATA "cor"
  22. new handle;
  23. //---> Dialoge
  24. #define DIALOG_REGISTER (1)
  25. #define DIALOG_LOGIN (2)
  26. //-------| Enum's
  27. //---> SpielerEnum
  28. enum PlayerEnum{
  29. ORM:ORM_ID,
  30.  
  31. pID,
  32. pName[MAX_PLAYER_NAME],
  33. pPasswort[129],
  34.  
  35.  
  36.  
  37. bool:IsLogin
  38. };
  39. new pInfo[MAX_PLAYERS][PlayerEnum];
  40.  
  41.  
  42.  
  43. main(){}
  44. public OnGameModeInit()
  45. {
  46. //-------| MySQL
  47. handle = mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
  48. mysql_log(LOG_ALL);
  49. return 1;
  50. }
  51.  
  52. public OnGameModeExit()
  53. {
  54. mysql_close(handle);
  55. return 1;
  56. }
  57.  
  58. public OnPlayerRequestClass(playerid, classid)
  59. {
  60. return 1;
  61. }
  62.  
  63. public OnPlayerConnect(playerid)
  64. {
  65. //-------| ORM
  66. GetPlayerName(playerid, pInfo[playerid][pName], MAX_PLAYER_NAME+1);
  67. new ORM:ormid = pInfo[playerid][ORM_ID] = orm_create(""SERVERTAG"_accounts");
  68.  
  69. orm_addvar_int(ormid, pInfo[playerid][pID], "ID");
  70. orm_addvar_string(ormid, pInfo[playerid][pName], MAX_PLAYER_NAME+1, "Spielername");
  71.  
  72. orm_setkey(ormid, "Spielername");
  73. orm_select(ormid, "OnPlayerDataLoad", "d", playerid);
  74. return 1;
  75. }
  76.  
  77. public OnPlayerDisconnect(playerid, reason)
  78. {
  79. if(pInfo[playerid][pID] != 0)
  80. orm_update(pInfo[playerid][ORM_ID]);
  81.  
  82. orm_destroy(pInfo[playerid][ORM_ID]);
  83. for(new PlayerEnum:e; e < PlayerEnum; ++e)
  84. pInfo[playerid][e] = 0;
  85. return 1;
  86. }
  87.  
  88. public OnPlayerSpawn(playerid)
  89. {
  90. return 1;
  91. }
  92.  
  93. public OnPlayerDeath(playerid, killerid, reason)
  94. {
  95. return 1;
  96. }
  97.  
  98. public OnVehicleSpawn(vehicleid)
  99. {
  100. return 1;
  101. }
  102.  
  103. public OnVehicleDeath(vehicleid, killerid)
  104. {
  105. return 1;
  106. }
  107.  
  108. public OnPlayerText(playerid, text[])
  109. {
  110. return 1;
  111. }
  112.  
  113. public OnPlayerCommandText(playerid, cmdtext[])
  114. {
  115. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  116. {
  117. // Do something here
  118. return 1;
  119. }
  120. return 0;
  121. }
  122.  
  123. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  124. {
  125. return 1;
  126. }
  127.  
  128. public OnPlayerExitVehicle(playerid, vehicleid)
  129. {
  130. return 1;
  131. }
  132.  
  133. public OnPlayerStateChange(playerid, newstate, oldstate)
  134. {
  135. return 1;
  136. }
  137.  
  138. public OnPlayerEnterCheckpoint(playerid)
  139. {
  140. return 1;
  141. }
  142.  
  143. public OnPlayerLeaveCheckpoint(playerid)
  144. {
  145. return 1;
  146. }
  147.  
  148. public OnPlayerEnterRaceCheckpoint(playerid)
  149. {
  150. return 1;
  151. }
  152.  
  153. public OnPlayerLeaveRaceCheckpoint(playerid)
  154. {
  155. return 1;
  156. }
  157.  
  158. public OnRconCommand(cmd[])
  159. {
  160. return 1;
  161. }
  162.  
  163. public OnPlayerRequestSpawn(playerid)
  164. {
  165. return 1;
  166. }
  167.  
  168. public OnObjectMoved(objectid)
  169. {
  170. return 1;
  171. }
  172.  
  173. public OnPlayerObjectMoved(playerid, objectid)
  174. {
  175. return 1;
  176. }
  177.  
  178. public OnPlayerPickUpPickup(playerid, pickupid)
  179. {
  180. return 1;
  181. }
  182.  
  183. public OnVehicleMod(playerid, vehicleid, componentid)
  184. {
  185. return 1;
  186. }
  187.  
  188. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  189. {
  190. return 1;
  191. }
  192.  
  193. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  194. {
  195. return 1;
  196. }
  197.  
  198. public OnPlayerSelectedMenuRow(playerid, row)
  199. {
  200. return 1;
  201. }
  202.  
  203. public OnPlayerExitedMenu(playerid)
  204. {
  205. return 1;
  206. }
  207.  
  208. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  209. {
  210. return 1;
  211. }
  212.  
  213. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  214. {
  215. return 1;
  216. }
  217.  
  218. public OnRconLoginAttempt(ip[], password[], success)
  219. {
  220. return 1;
  221. }
  222.  
  223. public OnPlayerUpdate(playerid)
  224. {
  225. return 1;
  226. }
  227.  
  228. public OnPlayerStreamIn(playerid, forplayerid)
  229. {
  230. return 1;
  231. }
  232.  
  233. public OnPlayerStreamOut(playerid, forplayerid)
  234. {
  235. return 1;
  236. }
  237.  
  238. public OnVehicleStreamIn(vehicleid, forplayerid)
  239. {
  240. return 1;
  241. }
  242.  
  243. public OnVehicleStreamOut(vehicleid, forplayerid)
  244. {
  245. return 1;
  246. }
  247.  
  248. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  249. {
  250. if(dialogid == DIALOG_REGISTER)
  251. {
  252. if(response)
  253. {
  254. orm_insert(pInfo[playerid][ORM_ID], "OnPlayerRegister", "d", playerid);
  255. }
  256. else
  257. {
  258. Kick(playerid);
  259. }
  260. }
  261. }
  262.  
  263. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  264. {
  265. return 1;
  266. }
  267. ////////////////////////////////////////////////////////////////////////////////
  268. //------| Public's
  269. forward OnPlayerDataLoad(playerid);
  270. public OnPlayerDataLoad(playerid)
  271. {
  272. switch(orm_errno(pInfo[playerid][ORM_ID]))
  273. {
  274. case ERROR_OK: {
  275. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""SERVERNAME" - Login", "Bitte geb dein Passwort ein:", "Login", "Abbruch");
  276. }
  277. case ERROR_NO_DATA: {
  278. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""SERVERNAME" - Regestation", "Bitte geb ein Passwort ein:", "Register", "Abbruch");
  279. }
  280. }
  281. orm_setkey(pInfo[playerid][ORM_ID], "ID");
  282. return 1;
  283. }
  284.  
  285. forward OnPlayerRegister(playerid);
  286. public OnPlayerRegister(playerid)
  287. {
  288. printf("Spieler %s hat sich registriert und hat die ID %d.", pInfo[playerid][pName], pInfo[playerid][pID]);
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement