Advertisement
Guest User

Login & Register System

a guest
Nov 21st, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.04 KB | None | 0 0
  1. /*Login und Register System. Besierend auf SII. Alles mit Dialogen.
  2. Einfach und in deutscher Sprache. Das richtige für Anfänger.
  3.  
  4. Die Credits im Script müssen drin bleiben, sieht ja keiner!*/
  5.  
  6. #include <a_samp>
  7. #include <SII>
  8.  
  9. #define DIALOG_REGIST   1
  10. #define DIALOG_LOGIN    2
  11.  
  12. #define WEISS       0xFFFFFFFF
  13. #define ROT         0xFF0000FF
  14. #define GRUEN       0x00FF1EFF
  15. #define HELLBLAU    0x0091FFFF
  16.  
  17. enum pInfo
  18. {
  19.     pPasswort,
  20.     pGeld,
  21.     pLevel,
  22.     pAdmin,
  23.     pKills,
  24.     pTote
  25. }
  26. new PlayerInfo[MAX_PLAYERS][pInfo];
  27. new gPlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];
  28.  
  29. main()
  30. {
  31.     print("\n----------------------------------");
  32.     print("Login & Register System");
  33.     print("Gescriptet von Apple_5g aká Grape_Fruit");
  34.     print("----------------------------------\n");
  35. }
  36.  
  37.  
  38. public OnGameModeInit()
  39. {
  40.     SetGameModeText("Login & Register System");
  41.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  42.     return 1;
  43. }
  44.  
  45. public OnGameModeExit()
  46. {
  47.     return 1;
  48. }
  49.  
  50. public OnPlayerRequestClass(playerid, classid)
  51. {
  52.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  53.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  54.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  55.     return 1;
  56. }
  57.  
  58. public OnPlayerConnect(playerid)
  59. {
  60.     GetPlayerName(playerid, gPlayerName[playerid], MAX_PLAYER_NAME);
  61.     if(fexist(getINI(playerid)))
  62.     {
  63.         ShowPlayerDialog(playerid,DIALOG_REGIST,DIALOG_STYLE_PASSWORD,"Registrieren","Schön, dass du uns gefunden hast.\n Wähle ein Passwort, damit du dich einloggen kannst.","Registrieren","Abbrechen");
  64.     }
  65.     else
  66.     {
  67.         ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Herzlich Willkommen zurück.\n Gib dein Passwort ein um mit deinem Account weiter zu spielen.","Einloggen","Abbrechen");
  68.     }
  69.     return 1;
  70. }
  71.  
  72. public OnPlayerDisconnect(playerid, reason)
  73. {
  74.     if(INI_Open(getINI(playerid)))
  75.     {
  76.         INI_WriteInt("Level",PlayerInfo[playerid][pLevel]);
  77.         INI_WriteInt("Geld",PlayerInfo[playerid][pGeld]);
  78.         INI_WriteInt("Admin",PlayerInfo[playerid][pAdmin]);
  79.         INI_WriteInt("Kills",PlayerInfo[playerid][pKills]);
  80.         INI_WriteInt("Tote",PlayerInfo[playerid][pTote]);
  81.        
  82.         INI_Save();
  83.         INI_Close();
  84.     }
  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.         return 1;
  118.     }
  119.     return 0;
  120. }
  121.  
  122. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  123. {
  124.     return 1;
  125. }
  126.  
  127. public OnPlayerExitVehicle(playerid, vehicleid)
  128. {
  129.     return 1;
  130. }
  131.  
  132. public OnPlayerStateChange(playerid, newstate, oldstate)
  133. {
  134.     return 1;
  135. }
  136.  
  137. public OnPlayerEnterCheckpoint(playerid)
  138. {
  139.     return 1;
  140. }
  141.  
  142. public OnPlayerLeaveCheckpoint(playerid)
  143. {
  144.     return 1;
  145. }
  146.  
  147. public OnPlayerEnterRaceCheckpoint(playerid)
  148. {
  149.     return 1;
  150. }
  151.  
  152. public OnPlayerLeaveRaceCheckpoint(playerid)
  153. {
  154.     return 1;
  155. }
  156.  
  157. public OnRconCommand(cmd[])
  158. {
  159.     return 1;
  160. }
  161.  
  162. public OnPlayerRequestSpawn(playerid)
  163. {
  164.     return 1;
  165. }
  166.  
  167. public OnObjectMoved(objectid)
  168. {
  169.     return 1;
  170. }
  171.  
  172. public OnPlayerObjectMoved(playerid, objectid)
  173. {
  174.     return 1;
  175. }
  176.  
  177. public OnPlayerPickUpPickup(playerid, pickupid)
  178. {
  179.     return 1;
  180. }
  181.  
  182. public OnVehicleMod(playerid, vehicleid, componentid)
  183. {
  184.     return 1;
  185. }
  186.  
  187. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  188. {
  189.     return 1;
  190. }
  191.  
  192. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  193. {
  194.     return 1;
  195. }
  196.  
  197. public OnPlayerSelectedMenuRow(playerid, row)
  198. {
  199.     return 1;
  200. }
  201.  
  202. public OnPlayerExitedMenu(playerid)
  203. {
  204.     return 1;
  205. }
  206.  
  207. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  208. {
  209.     return 1;
  210. }
  211.  
  212. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  213. {
  214.     return 1;
  215. }
  216.  
  217. public OnRconLoginAttempt(ip[], password[], success)
  218. {
  219.     return 1;
  220. }
  221.  
  222. public OnPlayerUpdate(playerid)
  223. {
  224.     return 1;
  225. }
  226.  
  227. public OnPlayerStreamIn(playerid, forplayerid)
  228. {
  229.     return 1;
  230. }
  231.  
  232. public OnPlayerStreamOut(playerid, forplayerid)
  233. {
  234.     return 1;
  235. }
  236.  
  237. public OnVehicleStreamIn(vehicleid, forplayerid)
  238. {
  239.     return 1;
  240. }
  241.  
  242. public OnVehicleStreamOut(vehicleid, forplayerid)
  243. {
  244.     return 1;
  245. }
  246.  
  247. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  248. {
  249.     switch(dialogid)
  250.     {
  251.         case DIALOG_REGIST:
  252.         {
  253.             if(!response) return Kick(playerid);
  254.             if(response)
  255.             {
  256.                 if(!strlen(inputtext))
  257.                 {
  258.                     ShowPlayerDialog(playerid,DIALOG_REGIST,DIALOG_STYLE_PASSWORD,"Registrieren","Du hast ein ungültiges Passwort eingegeben.\n Wähle ein neues Passwort","Registrieren","Abbrechen");
  259.                 }
  260.                 if(INI_Open(getINI(playerid)))
  261.                 {
  262.                     INI_WriteString("Passwort",inputtext);
  263.                     INI_WriteInt("Geld",5000);
  264.                     INI_WriteInt("Level",1);
  265.                     INI_WriteInt("Admin",0);
  266.                     INI_WriteInt("Kills",0);
  267.                     INI_WriteInt("Tote",0);
  268.                    
  269.                     INI_Save();
  270.                     INI_Close();
  271.                    
  272.                     ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Herzlich Willkommen zurück.\nGib dein Passwort ein um mit deinem Account weiter zu spielen","Einloggen","Abbrechen");
  273.                 }
  274.             }
  275.         }
  276.         case DIALOG_LOGIN:
  277.         {
  278.             if(!response) return Kick(playerid);
  279.             if(response)
  280.             {
  281.                 if(!strlen(inputtext))
  282.                 {
  283.                     ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Du hast ein falsches Passwort eingegeben.\n Gib dein Passwort erneut ein.\n\n Tipp: Bist du mit dem richtigen Spielername verbunden?","Login","Abbrechen");
  284.                 }
  285.                 if(INI_Open(getINI(playerid)))
  286.                 {
  287.                     INI_ReadString(PlayerInfo[playerid][pPasswort],"Passwort",20);
  288.                     if(strcmp(inputtext,PlayerInfo[playerid][pPasswort],false))
  289.                     {
  290.                         ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Du hast ein falsches Passwort eingegeben.\n Gib dein Passwort erneut ein.\n\n Tipp: Bist du mit dem richtigen Spielername verbunden?","Login","Abbrechen");
  291.                     }
  292.                     SetPlayerScore(playerid,INI_ReadInt("Level"));
  293.                     ResetPlayerMoney(playerid);
  294.                     GivePlayerMoney(playerid,INI_ReadInt("Geld"));
  295.                     PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
  296.                     PlayerInfo[playerid][pKills] = INI_ReadInt("Kills");
  297.                     PlayerInfo[playerid][pTote] = INI_ReadInt("Tote");
  298.                     INI_Close();
  299.                 }
  300.             }
  301.         }
  302.     }
  303.     return 1;
  304. }
  305.  
  306. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  307. {
  308.     return 1;
  309. }
  310.  
  311. stock getINI(playerid)
  312. {
  313.     new account[64];
  314.     format(account,30,"Benutzer/%s.ini",gPlayerName[playerid]);
  315.     return account;
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement