Advertisement
Guest User

dasasd

a guest
Jan 4th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.70 KB | None | 0 0
  1. #include <a_samp>
  2. #include <a_mysql>
  3. #include <colors>
  4. #include <sscanf2>
  5. #include <CameraMover>
  6. #include <zcmd>
  7. #include <streamer>
  8. #include <intro>
  9.  
  10. #define function%0(%1) forward%0(%1); public%0(%1)
  11.  
  12.  
  13. enum pInfo {
  14. pSQLID,
  15. pName[MAX_PLAYER_NAME],
  16. pPassword[32],
  17. pEmail[32],
  18. pSkin,
  19. pMember,
  20. pLeader,
  21. pAdmin,
  22. pHelper,
  23. pTutorial
  24. }
  25.  
  26. enum {
  27. // Register
  28. DIALOG_REGISTER,
  29. DIALOG_EMAIL,
  30.  
  31. // Login
  32. DIALOG_LOGIN,
  33.  
  34. // Mesaje
  35. DIALOG_TUTORIAL_COLECTARE_BAGAJ
  36. }
  37.  
  38.  
  39. new PlayerInfo[MAX_PLAYERS][pInfo];
  40. new SQL = -1, gQuery[256], gString[256];
  41. new incercariParola[MAX_PLAYERS];
  42.  
  43. new bagaj, iesiretutorial;
  44.  
  45.  
  46. main() { print("Gamemode-ul e in curs de procesare..."); }
  47.  
  48. public OnGameModeInit()
  49. {
  50. SQL = mysql_connect("localhost", "root", "zoldix_db", "");
  51. SendRconCommand("hostname Zoldix RPG | BETA");
  52. SetGameModeText("Zoldix RPG v1.0");
  53. CreateGlobalTextDraws();
  54. CreateGlobalObjects();
  55. bagaj = CreatePickup(1210, 1, 266.9013,96.4856,1033.3784, -1); //Virtual World (-1) is all worlds
  56. Create3DTextLabel("Te rugam sa iei valiza pentru a continua", 0x008080FF, 266.9013, 96.4856, 1033.3784, 40.0, 0, 0);
  57. iesiretutorial = CreatePickup(1239, 1, 270.3147,147.4576,1033.3920, -1); //Virtual World (-1) is all worlds
  58. Create3DTextLabel("Te rugam sa iei valiza pentru a continua", 0x008080FF, 270.3147,147.4576,1033.3920, 40.0, 0, 0);
  59. }
  60.  
  61. public OnGameModeExit()
  62. {
  63. DestroyGlobalTextDraws();
  64. DestroyGlobalObjects();
  65. DestroyActors();
  66. ResetGlobalVariables();
  67. }
  68.  
  69. public OnPlayerRequestClass(playerid, classid)
  70. {
  71. if(PlayerInfo[playerid][pTutorial] == 0)
  72. {
  73. ClearPlayerChat(playerid, 32);
  74. TogglePlayerSpectating(playerid, 1);
  75. SetPlayerInterior(playerid, 12);
  76. SetPlayerCameraPos(playerid, 1093.000000, -2036.000000, 90.000000);
  77. SetPlayerCameraLookAt(playerid, 0.825859, 0.557950, -0.081537);
  78. ApplyActorAnimation(first_actor, "INT_SHOP", "shop_loop", 4.1, 1, 1, 1, 0, 0);
  79. return 1;
  80. }
  81. return 1;
  82. }
  83.  
  84.  
  85. public OnPlayerConnect(playerid) {
  86.  
  87. incercariParola[playerid] = 0;
  88. gQuery[0] = EOS;
  89. mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' LIMIT 1",GetName(playerid));
  90. mysql_tquery(SQL, gQuery, "checkAccount", "i", playerid);
  91. if(PlayerInfo[playerid][pTutorial] == 0) CreatePlayerTextDraws(playerid);
  92. return 1;
  93. }
  94.  
  95. public OnPlayerSpawn(playerid)
  96. {
  97. if(PlayerInfo[playerid][pTutorial] == 0)
  98. {
  99. SetPlayerInterior(playerid, 0);
  100. SetPlayerPos(playerid, 273.4211, 96.4937, 1033.3784);
  101. SetPlayerSkin(playerid, 26);
  102. SetPlayerVirtualWorld(playerid, 0);
  103. SetPlayerFacingAngle(playerid, 360.0);
  104. SetCameraBehindPlayer(playerid);
  105. StopAudioStreamForPlayer(playerid);
  106. }
  107. if(PlayerInfo[playerid][pTutorial] == 1)
  108. {
  109. SetPlayerInterior(playerid, 0);
  110. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  111. SetPlayerSkin(playerid, 26);
  112. SetPlayerVirtualWorld(playerid, 0);
  113. SetPlayerFacingAngle(playerid, 360.0);
  114. SetCameraBehindPlayer(playerid);
  115. StopAudioStreamForPlayer(playerid);
  116. }
  117. }
  118.  
  119.  
  120. public OnPlayerPickUpPickup(playerid, pickupid)
  121. {
  122. if(pickupid == bagaj)
  123. {
  124. if(PlayerInfo[playerid][pTutorial] == 0)
  125. {
  126. DestroyPickup(bagaj);
  127. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Inregistrare", "Pentru a merge mai departe te rugam sa iti setezi o parola", "Select", "Cancel");
  128. }
  129. }
  130. if(pickupid == iesiretutorial)
  131. {
  132. if(PlayerInfo[playerid][pTutorial] == 0) SendClientMessage(playerid, COLOR_RED, "Nu poti iesi fara sa iei valiza!");
  133. if(PlayerInfo[playerid][pTutorial] == 1) SetPlayerPos(playerid, 1481.2548, -1741.8038, 14.5469);
  134. }
  135.  
  136. }
  137.  
  138. public OnPlayerDisconnect(playerid, reason)
  139. {
  140. if(PlayerInfo[playerid][pTutorial] == 0)
  141. {
  142. KillPlayerTimers(playerid);
  143. DestroyPlayerTextDraws(playerid);
  144. ResetPlayerVariables(playerid);
  145. }
  146. return 1;
  147. }
  148.  
  149. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  150. switch(dialogid) {
  151. case DIALOG_REGISTER: {
  152. if(strlen(inputtext) < 6)
  153. return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Parola ta e prea scurta (minim 6 caractere). Incearca din nou:", "Select", "Cancel");
  154. if(strlen(inputtext) > 32)
  155. return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Parola ta e prea lunga (maxim 32 caractere). Incearca din nou:", "Select", "Cancel");
  156.  
  157. gQuery[0] = EOS;
  158. mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `users` (`Name`, `Password`, `Tutorial`) VALUES ('%s', '%s', '1')", GetName(playerid), inputtext);
  159. mysql_tquery(SQL, gQuery, "insertAccount", "i", playerid);
  160.  
  161. format(PlayerInfo[playerid][pPassword], 32 , inputtext);
  162.  
  163. ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa ta de email", "Select", "Cancel");
  164. }
  165. case DIALOG_EMAIL: {
  166. if(!response)
  167. return Kick(playerid);
  168.  
  169. if(strlen(inputtext) > 32)
  170. return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Email", "Email-ul tau e prea mare (maxim 32 caractere). Incearca din nou:", "Select", "Cancel");
  171.  
  172. gQuery[0] = EOS;
  173. mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Email`='%s', WHERE `ID`='%d'", GetName(playerid), inputtext);
  174. mysql_tquery(SQL, gQuery, "", "", playerid);
  175. PlayerInfo[playerid][pTutorial] = 1;
  176.  
  177. format(PlayerInfo[playerid][pEmail], 32 , inputtext);
  178. bagaj = CreatePickup(1210, 1, 266.9013,96.4856,1033.3784, -1); //Virtual World (-1) is all worlds
  179. ShowPlayerDialog(playerid, DIALOG_TUTORIAL_COLECTARE_BAGAJ, DIALOG_STYLE_MSGBOX, "Caption", "Ai colectat valiza!\nTe poti indrepta catre iesire!", "Ok", "");
  180.  
  181. }
  182. case DIALOG_LOGIN: {
  183. if(!response)
  184. return Kick(playerid);
  185.  
  186. mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' AND `Password`='%s' LIMIT 1",GetName(playerid), inputtext);
  187. mysql_tquery(SQL, gQuery, "onLogin", "i", playerid);
  188.  
  189. }
  190. }
  191. return 1;
  192. }
  193.  
  194. CMD:teleport(playerid,params[])//the command
  195. {//first bracket
  196. new Float:x;//pos x
  197. new Float:y;//oos y
  198. new Float:z;//pos z
  199. new interior;
  200.  
  201. new string[128];//the message string
  202. if(sscanf(params,"fffi", Float:x, Float:y, Float:z,interior)) return SendClientMessage(playerid, -1,"{FF0000}Error:{FFFFFF}/teleport [x] [y] [z] [interior]");//the message
  203. format(string,sizeof(string),"You have been teleported to coordinates: %.0f.%.0f.%.0f interior: %d",x,y,z,interior);//this is the format for our message
  204. SendClientMessage(playerid,-1,string);//now let's send him this message with the coordinates!
  205. SetPlayerInterior(playerid,interior);//now we will set the player interior
  206. SetPlayerPos(playerid,Float:x,Float:y,Float:z);//now let's teleport him to this pos!
  207. return 1;
  208. }
  209.  
  210. stock GetName(playerid) {
  211. new playerName[MAX_PLAYER_NAME];
  212. GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
  213. return playerName;
  214. }
  215.  
  216.  
  217. function checkAccount(playerid) {
  218. switch(cache_num_rows()) {
  219. case 0:
  220. {
  221. Streamer_Update(playerid);
  222. PlayerTimers[playerid][1] = SetTimerEx("PlayerIntroCallback", 4000, 0, "id", playerid, 0);
  223. Streamer_Update(playerid);
  224. }
  225. case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea autentifica", "Select", "Cancel");
  226. }
  227. return 1;
  228. }
  229.  
  230. function insertAccount(playerid) {
  231. PlayerInfo[playerid][pSQLID] = cache_insert_id();
  232. printf("$s s-a inregistrat cu SQLDID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
  233. return 1;
  234. }
  235.  
  236. function onLogin(playerid) {
  237. switch(cache_num_rows()) {
  238. case 0: {
  239. incercariParola[playerid] ++;
  240.  
  241. gString[0] = EOS;
  242. format(gString, sizeof(gString), "Parola incorecta! (%d/3 incercari ramase)", incercariParola[playerid]);
  243. SendClientMessage(playerid, COLOR_DARKRED, gString);
  244.  
  245. if(incercariParola[playerid] == 3 ) Kick(playerid);
  246. else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea autentifica", "Select", "Cancel");
  247. }
  248. case 1: {
  249. new
  250. result[64];
  251.  
  252. PlayerInfo[playerid][pSQLID] = cache_get_field_content_int(0, "ID");
  253.  
  254. cache_get_field_content(0, "Name", result);format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, result);
  255. cache_get_field_content(0, "Password", result);format(PlayerInfo[playerid][pPassword], 32, result);
  256. cache_get_field_content(0, "Email", result);format(PlayerInfo[playerid][pEmail], 32, result);
  257. cache_get_field_content(0, "Tutorial", result);format(PlayerInfo[playerid][pTutorial], 32, result);
  258.  
  259. printf("%s (user: %d) tocmai s-a logat.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
  260.  
  261. SpawnPlayer(playerid);
  262.  
  263. }
  264. }
  265. return 1;
  266. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement