Advertisement
Isigar

IRegister 2 (Opravená verze/Fixed)

Nov 30th, 2013
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 15.02 KB | None | 0 0
  1. #define ACC Account(playerid)
  2. stock GetName(playerid)
  3. {
  4.     new name[MAX_PLAYER_NAME];
  5.     GetPlayerName(playerid,name,sizeof(name));
  6.     return name;
  7. }
  8. stock Account(playerid)
  9. {
  10.     new path[200];
  11.     format(path,200,"Users/%s.ini",GetName(playerid));
  12.     return path;
  13. }
  14. stock GetIP(playerid)
  15. {
  16.     new ip[16];
  17.     GetPlayerIp(playerid,ip,sizeof(ip));
  18.     return ip;
  19. }
  20. enum dialogs
  21. {
  22.     DIALOG_NONE,//0
  23.     DIALOG_LOGIN,//1
  24.     DIALOG_REGISTER,//2
  25.     DIALOG_UCET,//ATD
  26.     DIALOG_CHANGEPASS,
  27.     DIALOG_CHANGEIP,
  28.     DIALOG_CHANGEPASS2,
  29.     DIALOG_UCETINFO,
  30.     DIALOG_SKYPE,
  31. }
  32.  
  33. enum DriveLicenceTypes//Není hotovo
  34. {
  35.     dA,//Normal auta
  36.     dB,//Nakladaky, vetsi auta
  37.     dC,//Autobusy
  38.     dAirvehicles
  39. }
  40. enum pDATA
  41. {
  42.     pZabiti,
  43.     pUmrti,
  44.     pAdminLevel,
  45.     pMoney,
  46.     pMoneyInBank,
  47.     pIP,
  48.     Float:pX,
  49.     Float:pY,
  50.     Float:pZ,
  51.     pSkin,
  52.     Float:pHP,
  53.     Float:pAR,
  54.     DriveLicence[DriveLicenceTypes]
  55. }
  56. new PlayerData[MAX_PLAYERS][pDATA];
  57. new PlayerWeapon[MAX_PLAYERS][13][2];
  58.  
  59. public OnPlayerConnect(playerid)
  60. {
  61.  
  62.     if(DOF2_FileExists(Account(playerid)))
  63.     {
  64.         if(strmatch(GetIP(playerid),DOF2_GetString(Account(playerid),"IP")))
  65.         {
  66.             PlayerData[playerid][pZabiti] = DOF2_GetInt(Account(playerid),"Zabiti","Informace");
  67.             PlayerData[playerid][pUmrti] = DOF2_GetInt(Account(playerid),"Umrti","Informace");
  68.             PlayerData[playerid][pAdminLevel] = DOF2_GetInt(Account(playerid),"AdminLevel","Informace");
  69.             PlayerData[playerid][pMoney] = DOF2_GetInt(Account(playerid),"Money","Penize");
  70.             PlayerData[playerid][pMoneyInBank] = DOF2_GetInt(Account(playerid),"MoneyInBank","Informace");
  71.             PlayerData[playerid][pX] = DOF2_GetFloat(Account(playerid),"X","Pozice");
  72.             PlayerData[playerid][pY] = DOF2_GetFloat(Account(playerid),"Y","Pozice");
  73.             PlayerData[playerid][pZ] = DOF2_GetFloat(Account(playerid),"Z","Pozice");
  74.             PlayerData[playerid][pHP] = DOF2_GetFloat(Account(playerid),"HP","Informace");
  75.             PlayerData[playerid][pAR] = DOF2_GetFloat(Account(playerid),"ARMOR","Informace");
  76.             PlayerData[playerid][pSkin] = DOF2_GetInt(Account(playerid),"Skin","Informace");
  77.             GivePlayerMoney(playerid,PlayerData[playerid][pMoney]);
  78.  
  79.             for(new i=0;i<13;i++)
  80.             {
  81.                 new strwep[50];
  82.                 format(strwep,50,"Weapon%d",i);
  83.                 new strwep2[50];
  84.                 format(strwep2,50,"Ammo%d",i);
  85.  
  86.                 PlayerWeapon[playerid][i][0] = DOF2_GetInt(Account(playerid),strwep,"WeaponsData");
  87.                 PlayerWeapon[playerid][i][1] = DOF2_GetInt(Account(playerid),strwep2,"WeaponsData");
  88.             }
  89.  
  90.             SendClientMessage(playerid,C_ERROR,""r"["inf"ParadoxGames"r"] "g"AutoLogin: "w"Byl jsi automaticky přihlášen.");
  91.         }
  92.         else
  93.         {
  94.             SendClientMessage(playerid,C_ERROR,""r"["inf"ParadoxGames"r"] "g"AutoLogin: "w"Automatické přihlášení se nezdařilo prosím zadej heslo manuálně.");
  95.             ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"[ParadoxGames] Life : Login","Vítej zpět!\n\n\tPravidla:\n{FFFFFF}1. {0055FF}Nemluvit sprostě\n{FFFFFF}2. {0055FF}Nezabijet na spawnu\n{FFFFFF}3.{0055FF} Dodržovat pravidla\n\nPřejeme příjemnou hru.","Login","Odejít");
  96.         }
  97.     }
  98.     else
  99.     {
  100.         ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"[ParadoxGames] Life : Register","Vítej pro hraní na tomto serveru se musíš zaregistrovat.\n\n\tPravidla:\n{FFFFFF}1. {0055FF}Nemluvit sprostě\n{FFFFFF}2. {0055FF}Nezabijet na spawnu\n{FFFFFF}3.{0055FF} Dodržovat pravidla\n\nPřejeme příjemnou hru.","Zaregistrovat","Odejít");
  101.     }
  102.     SetTimerEx("Autosave",1000*60*15,true,"inf",playerid);
  103.     return 1;
  104. }
  105.  
  106. public Autosave(playerid)
  107. {
  108.     GetPlayerPos(playerid,PlayerData[playerid][pX],PlayerData[playerid][pY],PlayerData[playerid][pZ]);
  109.     GetPlayerHealth(playerid,PlayerData[playerid][pHP]);
  110.     GetPlayerArmour(playerid,PlayerData[playerid][pAR]);
  111.     PlayerData[playerid][pSkin] = GetPlayerSkin(playerid);
  112.     PlayerData[playerid][pMoney] = GetPlayerMoney(playerid);
  113.  
  114.     DOF2_SetInt(Account(playerid),"Zabiti",PlayerData[playerid][pZabiti],"Informace");
  115.     DOF2_SetInt(Account(playerid),"Umrti",PlayerData[playerid][pUmrti],"Informace");
  116.     DOF2_SetInt(Account(playerid),"AdminLevel",PlayerData[playerid][pAdminLevel],"Informace");
  117.     DOF2_SetInt(Account(playerid),"Money",PlayerData[playerid][pMoney],"Penize");
  118.     DOF2_SetInt(Account(playerid),"MoneyInBank",PlayerData[playerid][pMoneyInBank],"Penize");
  119.     DOF2_SetFloat(Account(playerid),"X",PlayerData[playerid][pX],"Pozice");
  120.     DOF2_SetFloat(Account(playerid),"Y",PlayerData[playerid][pY],"Pozice");
  121.     DOF2_SetFloat(Account(playerid),"Z",PlayerData[playerid][pZ],"Pozice");
  122.     DOF2_SetFloat(Account(playerid),"HP",PlayerData[playerid][pHP],"Informace");
  123.     DOF2_SetFloat(Account(playerid),"ARMOR",PlayerData[playerid][pAR],"Informace");
  124.     DOF2_SetInt(Account(playerid),"Skin",PlayerData[playerid][pSkin],"Informace");
  125.  
  126.     for (new i = 0; i < 13; i++)
  127.     {
  128.         GetPlayerWeaponData(playerid, i, PlayerWeapon[playerid][i][0], PlayerWeapon[playerid][i][1]);
  129.         new strwep[50];
  130.         format(strwep,50,"Weapon%d",i);
  131.         new strwep2[50];
  132.         format(strwep2,50,"Ammo%d",i);
  133.  
  134.         DOF2_SetInt(Account(playerid),strwep,PlayerWeapon[playerid][i][0],"WeaponsData");
  135.         DOF2_SetInt(Account(playerid),strwep2,PlayerWeapon[playerid][i][1],"WeaponsData");
  136.     }
  137.  
  138.     GivePlayerMoney(playerid,PlayerData[playerid][pMoney]);
  139.     DOF2_SaveFile();
  140.     return true;
  141. }
  142.  
  143. public OnPlayerDisconnect(playerid, reason)
  144. {
  145.     GetPlayerPos(playerid,PlayerData[playerid][pX],PlayerData[playerid][pY],PlayerData[playerid][pZ]);
  146.     GetPlayerHealth(playerid,PlayerData[playerid][pHP]);
  147.     GetPlayerArmour(playerid,PlayerData[playerid][pAR]);
  148.     PlayerData[playerid][pSkin] = GetPlayerSkin(playerid);
  149.     PlayerData[playerid][pMoney] = GetPlayerMoney(playerid);
  150.  
  151.     DOF2_SetInt(Account(playerid),"Zabiti",PlayerData[playerid][pZabiti],"Informace");
  152.     DOF2_SetInt(Account(playerid),"Umrti",PlayerData[playerid][pUmrti],"Informace");
  153.     DOF2_SetInt(Account(playerid),"AdminLevel",PlayerData[playerid][pAdminLevel],"Informace");
  154.     DOF2_SetInt(Account(playerid),"Money",PlayerData[playerid][pMoney],"Penize");
  155.     DOF2_SetInt(Account(playerid),"MoneyInBank",PlayerData[playerid][pMoneyInBank],"Penize");
  156.     DOF2_SetFloat(Account(playerid),"X",PlayerData[playerid][pX],"Pozice");
  157.     DOF2_SetFloat(Account(playerid),"Y",PlayerData[playerid][pY],"Pozice");
  158.     DOF2_SetFloat(Account(playerid),"Z",PlayerData[playerid][pZ],"Pozice");
  159.     DOF2_SetFloat(Account(playerid),"HP",PlayerData[playerid][pHP],"Informace");
  160.     DOF2_SetFloat(Account(playerid),"ARMOR",PlayerData[playerid][pAR],"Informace");
  161.     DOF2_SetInt(Account(playerid),"Skin",PlayerData[playerid][pSkin],"Informace");
  162.  
  163.     for (new i = 0; i < 13; i++)
  164.     {
  165.         GetPlayerWeaponData(playerid, i, PlayerWeapon[playerid][i][0], PlayerWeapon[playerid][i][1]);
  166.         new strwep[50];
  167.         format(strwep,50,"Weapon%d",i);
  168.         new strwep2[50];
  169.         format(strwep2,50,"Ammo%d",i);
  170.  
  171.         DOF2_SetInt(Account(playerid),strwep,PlayerWeapon[playerid][i][0],"WeaponsData");
  172.         DOF2_SetInt(Account(playerid),strwep2,PlayerWeapon[playerid][i][1],"WeaponsData");
  173.     }
  174.  
  175.     GivePlayerMoney(playerid,PlayerData[playerid][pMoney]);
  176.     DOF2_SaveFile();
  177.     return 1;
  178. }
  179. public OnPlayerRequestClass(playerid, classid)
  180. {
  181.     SetSpawnInfo(playerid,0,PlayerData[playerid][pSkin],PlayerData[playerid][pX],PlayerData[playerid][pY],PlayerData[playerid][pZ],0,0,0,0,0,0,0);
  182.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  183.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  184.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  185.     return 1;
  186. }
  187. public OnPlayerSpawn(playerid)
  188. {
  189.     for(new i=0;i<13;i++)
  190.     {
  191.         GivePlayerWeapon(playerid,PlayerWeapon[playerid][i][0],PlayerWeapon[playerid][i][1]);
  192.     }
  193.  
  194.     SetTimerEx("SpawnProtect",5000,false,"inf",playerid);
  195.     SetPlayerHealth(playerid,100000000);
  196.     return 1;
  197. }
  198.  
  199. public SpawnProtect(playerid)
  200. {
  201.     SetPlayerHealth(playerid,DOF2_GetFloat(Account(playerid),"HP","Informace"));
  202.     return 1;
  203. }
  204.  
  205. public OnPlayerDeath(playerid, killerid, reason)
  206. {
  207.     SetPosFromFile[playerid] = false;
  208.     SendDeathMessage(killerid,playerid,reason);
  209.     PlayerData[playerid][pUmrti]++;
  210.     PlayerData[killerid][pZabiti]++;
  211.     return 1;
  212. }
  213.  
  214. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  215. {
  216.     switch(dialogid)
  217.     {
  218.  
  219.         case DIALOG_REGISTER:
  220.         {
  221.             if(!response) return Kick(playerid);
  222.             if(response)
  223.             {
  224.                 DOF2_CreateFile(Account(playerid),inputtext);
  225.                 DOF2_SetInt(Account(playerid),"Zabiti",0,"Informace");
  226.                 DOF2_SetInt(Account(playerid),"Umrti",0,"Informace");
  227.                 DOF2_SetInt(Account(playerid),"AdminLevel",0,"Informace");
  228.                 DOF2_SetInt(Account(playerid),"Money",0,"Penize");
  229.                 DOF2_SetInt(Account(playerid),"MoneyInBank",0,"Penize");
  230.                 DOF2_SetFloat(Account(playerid),"X",0,"Pozice");
  231.                 DOF2_SetFloat(Account(playerid),"Y",0,"Pozice");
  232.                 DOF2_SetFloat(Account(playerid),"Z",0,"Pozice");
  233.                 DOF2_SetFloat(Account(playerid),"HP",100,"Informace");
  234.                 DOF2_SetFloat(Account(playerid),"ARMOR",0,"Informace");
  235.                 DOF2_SetString(Account(playerid),"IP",GetIP(playerid));
  236.                 DOF2_SetInt(Account(playerid),"Skin",0,"Informace");
  237.                 DOF2_SaveFile();
  238.                 GivePlayerMoney(playerid,10000);
  239.                 ShowPlayerDialog(playerid,DIALOG_SKYPE,DIALOG_STYLE_INPUT,"[ParadoxGames] Dokončení registrace",""w"Pokud máte skype účet nebo email na který bychom vás mohli kontaktovat neváhejte a zadejteho.\n Na váš skype/email nebudou chodit žádné spamy kontaktní udaje potřebujeme pro řešení případných problémů.\n "r"(Nepoviné)","Zadat","Odejít");
  240.             }
  241.             return 1;
  242.         }
  243.         case DIALOG_SKYPE:
  244.         {
  245.             DOF2_SetString(Account(playerid),"Skype/Email",inputtext,"Informace");
  246.             DOF2_SaveFile();
  247.             return 1;
  248.         }
  249.         case DIALOG_LOGIN:
  250.         {
  251.             if(!response) return Kick(playerid);
  252.             if(response)
  253.             {
  254.                 if(DOF2_CheckLogin(Account(playerid),inputtext))
  255.                 {
  256.                     PlayerData[playerid][pZabiti] = DOF2_GetInt(Account(playerid),"Zabiti","Informace");
  257.                     PlayerData[playerid][pUmrti] = DOF2_GetInt(Account(playerid),"Umrti","Informace");
  258.                     PlayerData[playerid][pAdminLevel] = DOF2_GetInt(Account(playerid),"AdminLevel","Informace");
  259.                     PlayerData[playerid][pMoney] = DOF2_GetInt(Account(playerid),"Money","Penize");
  260.                     PlayerData[playerid][pMoneyInBank] = DOF2_GetInt(Account(playerid),"MoneyInBank","Informace");
  261.                     PlayerData[playerid][pX] = DOF2_GetFloat(Account(playerid),"X","Pozice");
  262.                     PlayerData[playerid][pY] = DOF2_GetFloat(Account(playerid),"Y","Pozice");
  263.                     PlayerData[playerid][pZ] = DOF2_GetFloat(Account(playerid),"Z","Pozice");
  264.                     PlayerData[playerid][pHP] = DOF2_GetFloat(Account(playerid),"HP","Informace");
  265.                     PlayerData[playerid][pAR] = DOF2_GetFloat(Account(playerid),"ARMOR","Informace");
  266.                     PlayerData[playerid][pSkin] = DOF2_GetInt(Account(playerid),"Skin","Informace");
  267.  
  268.                     for(new i=0;i<13;i++)
  269.                     {
  270.                         new wepdata[50];
  271.                         format(wepdata,50,"Weapon%d",i);
  272.                         new wepdata2[50];
  273.                         format(wepdata2,50,"Ammo%d",i);
  274.  
  275.                         PlayerWeapon[playerid][i][0] = DOF2_GetInt(Account(playerid),wepdata,"WeaponsData");
  276.                         PlayerWeapon[playerid][i][1] = DOF2_GetInt(Account(playerid),wepdata2,"WeaponsData");
  277.  
  278.                         GivePlayerWeapon(playerid,PlayerWeapon[playerid][i][0],PlayerWeapon[playerid][i][1]);
  279.                     }
  280.                 }
  281.                 else
  282.                 {
  283.                     ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"[ParadoxGames] Life : Login",""g"Vítej zpět!\n\n"r"Pravidla:\n\t"r"1."inf" {0055FF}Nemluvit sprostě\n\t"r"2. "inf"Nezabijet na spawnu\n\t3. "inf"Dodržovat pravidla\n\nPřejeme příjemnou hru.\n"r"Zadal jsi špatné heslo.","Login","Odejít");
  284.                 }
  285.             }
  286.             return 1;
  287.         }
  288.         case DIALOG_UCET:
  289.         {
  290.             if(response)
  291.             {
  292.                 switch(listitem)
  293.                 {
  294.                     case 0://Změnit heslo
  295.                     {
  296.                         ShowPlayerDialog(playerid,DIALOG_CHANGEPASS,DIALOG_STYLE_INPUT,"[ParadoxGames] Změnit heslo",""inf"Napiš svoje "r"staré heslo:","Potvrdit","Zpět");
  297.                         return 1;
  298.                     }
  299.                     case 1://Změnit IP
  300.                     {
  301.                         ShowPlayerDialog(playerid,DIALOG_CHANGEIP,DIALOG_STYLE_MSGBOX,"[ParadoxGames] Změnit heslo",""inf"Opravdu chceš změnit IP ?\n"r"Možná potom nebude fungovat autologin.","Potvrdit","Zpět");
  302.                         return 1;
  303.                     }
  304.                 }
  305.             }
  306.             return 1;
  307.         }
  308.         case DIALOG_CHANGEPASS:
  309.         {
  310.             if(!response) return ShowPlayerDialog(playerid,DIALOG_UCET,DIALOG_STYLE_LIST,"[ParadoxGames] Účet","Změnit heslo.\nZměnit IP","Vybrat","Odejít");
  311.             if(response)
  312.             {
  313.                 if(DOF2_CheckLogin(Account(playerid),inputtext))
  314.                 {
  315.                     ShowPlayerDialog(playerid,DIALOG_CHANGEPASS2,DIALOG_STYLE_INPUT,"[ParadoxGames] Změnit heslo","Napiš svoje nové heslo:","Potvrdit","Zpět");
  316.                 }
  317.                 else
  318.                 {
  319.                     SendClientMessage(playerid,C_ERROR,""r"["inf"ParadoxGames] "g"Změna hesla: "w"Zadané heslo neodpovídá heslo zadaném při registraci.");
  320.                 }
  321.             }
  322.             return 1;
  323.         }
  324.         case DIALOG_CHANGEIP:
  325.         {
  326.             if(!response) return ShowPlayerDialog(playerid,DIALOG_UCET,DIALOG_STYLE_LIST,"[ParadoxGames] Účet","Změnit heslo.\nZměnit IP","Vybrat","Odejít");
  327.             if(response)
  328.             {
  329.                 DOF2_SetString(Account(playerid),"IP",GetIP(playerid));
  330.                 DOF2_SaveFile();
  331.  
  332.                 new str[100];
  333.                 format(str,100,""r"["inf"ParadoxGames"r"] "g"Účet: "w"Změna vaší IP proběhla úspěšně. Vaše nová IP je - %s",GetIP(playerid));
  334.                 SendClientMessage(playerid,C_SUCCES,str);
  335.             }
  336.         }
  337.         case DIALOG_CHANGEPASS2:
  338.         {
  339.             DOF2_RemoveFile(Account(playerid));
  340.             DOF2_CreateFile(Account(playerid),inputtext);
  341.             DOF2_SetInt(Account(playerid),"Zabiti",PlayerData[playerid][pZabiti],"Informace");
  342.             DOF2_SetInt(Account(playerid),"Umrti",PlayerData[playerid][pUmrti],"Informace");
  343.             DOF2_SetInt(Account(playerid),"AdminLevel",PlayerData[playerid][pAdminLevel],"Informace");
  344.             DOF2_SetInt(Account(playerid),"Money",PlayerData[playerid][pMoney],"Penize");
  345.             DOF2_SetInt(Account(playerid),"MoneyInBank",PlayerData[playerid][pMoneyInBank],"Penize");
  346.             DOF2_SetFloat(Account(playerid),"X",PlayerData[playerid][pX],"Pozice");
  347.             DOF2_SetFloat(Account(playerid),"Y",PlayerData[playerid][pY],"Pozice");
  348.             DOF2_SetFloat(Account(playerid),"Z",PlayerData[playerid][pZ],"Pozice");
  349.             DOF2_SetFloat(Account(playerid),"HP",PlayerData[playerid][pHP],"Informace");
  350.             DOF2_SetFloat(Account(playerid),"ARMOR",PlayerData[playerid][pAR],"Informace");
  351.             DOF2_SetInt(Account(playerid),"Skin",PlayerData[playerid][pSkin],"Informace");
  352.             DOF2_SaveFile();
  353.             new str[100];
  354.             format(str,100,""r"["inf"ParadoxGames"r"] "g"Účet: "w"Změna hesla proběhla úspěšně. Vaše nové heslo je - %s",inputtext);
  355.             SendClientMessage(playerid,C_SUCCES,str);
  356.         }
  357.     }
  358.     return 1;
  359. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement