Advertisement
Guest User

Dajnius

a guest
Jul 10th, 2009
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 20.89 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #include <utils>
  4.  
  5. #define FILTERSCRIPT
  6.  
  7. #if defined FILTERSCRIPT
  8. #define COLOR_GREY 0xBEBEBEAA
  9. #define COLOR_WHITE 0xFFFFFFAA
  10. #define COLOR_GREEN 0x33AA33AA
  11. #define COLOR_GRAD5 0xE3E3E3FF
  12. #define COLOR_GRAD1 0xB4B5B7FF
  13. #define COLOR_YELLOW 0xFFFF00AA
  14. #define COLOR_GRAD2 0xBFC0C2FF
  15. #define COLOR_GRAD4 0xD8D8D8FF
  16. #define COLOR_GRAD6 0xF0F0F0FF
  17. #define COLOR_GRAD2 0xBFC0C2FF
  18. #define COLOR_GRAD3 0xCBCCCEFF
  19.  
  20. forward ShowStats(playerid,targetid);
  21. forward OnPlayerUpdate(playerid);
  22. forward Encrypt(string[]);
  23. forward OnPlayerLogin(playerid,password[]);
  24. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  25. forward ABroadCast(color,const string[],level);
  26. forward CustomPickups();
  27. forward OnPlayerRegister(playerid, password[]);
  28.  
  29. enum pInfo
  30. {
  31.     pPassword[128],
  32.     pKills,
  33.     pDeaths,
  34.     pCash,
  35.     pBank,
  36. };
  37.  
  38. new PlayerInfo[MAX_PLAYERS][pInfo];
  39. new gPlayerLogged[MAX_PLAYERS];
  40. new gPlayerAccount[MAX_PLAYERS];
  41. new ConsumingMoney[MAX_PLAYERS];
  42. new sendername[MAX_PLAYER_NAME];
  43. new playermoney;
  44. new gPlayerLogTries[MAX_PLAYERS];
  45.  
  46.  
  47. public OnFilterScriptInit()
  48. {
  49.     print("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
  50.     print(" Kevin433's Login/Register Filterscript");
  51.     print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
  52.     SetTimer("CustomPickups", 1000, 1);
  53.     AddStaticPickup(1274, 2,2026.4064,1017.9352,10.8203);
  54.     return 1;
  55. }
  56.  
  57. public OnFilterScriptExit()
  58. {
  59.     return 1;
  60. }
  61.  
  62. public OnPlayerRequestClass(playerid, classid)
  63. {
  64.     return 1;
  65. }
  66.  
  67. public OnPlayerRequestSpawn(playerid)
  68. {
  69.     return 1;
  70. }
  71.  
  72. public OnPlayerConnect(playerid)
  73. {
  74.     new playrname[MAX_PLAYER_NAME];
  75.     new connect[128];
  76.     GetPlayerName(playerid, playrname, sizeof(playrname));
  77.     format(connect, sizeof(connect), "%s.cer", playrname);
  78.     if(fexist(connect))
  79.     {
  80.         gPlayerAccount[playerid] = 1;
  81.         SendClientMessage(playerid, COLOR_YELLOW, "You are registered, please login with /login password");
  82.         return 1;
  83.     }
  84.     else
  85.     {
  86.         gPlayerAccount[playerid] = 0;
  87.         SendClientMessage(playerid, COLOR_YELLOW, "You are new here or not registered, please register with /register password");
  88.     }
  89.     return 1;
  90. }
  91.  
  92. public OnPlayerDisconnect(playerid, reason)
  93. {
  94.     OnPlayerUpdate(playerid);
  95.     gPlayerLogged[playerid] = 0;
  96.     return 1;
  97. }
  98.  
  99. public OnPlayerSpawn(playerid)
  100. {
  101.     return 1;
  102. }
  103.  
  104. public OnPlayerDeath(playerid, killerid, reason)
  105. {
  106.     new kills = PlayerInfo[playerid][pKills];
  107.     SetPlayerScore(playerid, kills);
  108.     new Float:Health;
  109.     GetPlayerHealth(playerid, Health);
  110.     if(Health == 0.0)
  111.     {
  112.     PlayerInfo[playerid][pDeaths] += 1;
  113.     }
  114.     GivePlayerMoney(killerid,2000);
  115.     PlayerInfo[killerid][pKills] = PlayerInfo[killerid][pKills] + 1;
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerCommandText(playerid, cmdtext[])
  120. {
  121.     new cmd[256];
  122.     new idx;
  123.     cmd = strtok(cmdtext, idx);
  124.     new tmp[256];
  125.     new playername[MAX_PLAYER_NAME];
  126.     new string[256];
  127.     new moneys;
  128.     new giveplayer[MAX_PLAYER_NAME];
  129.     new giveplayerid;
  130.     if (strcmp(cmd, "/login", true) ==0 )
  131.     {
  132.         if(IsPlayerConnected(playerid))
  133.         {
  134.             new tmppass[64];
  135.             if(gPlayerLogged[playerid] == 1)
  136.             {
  137.                 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
  138.                 return 1;
  139.             }
  140.             tmp = strtok(cmdtext, idx);
  141.             if(!strlen(tmp))
  142.             {
  143.                 SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /login [password]");
  144.                 return 1;
  145.             }
  146.             strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
  147.             Encrypt(tmppass);
  148.             OnPlayerLogin(playerid,tmppass);
  149.         }
  150.         return 1;
  151.     }
  152.     if (strcmp(cmd, "/register", true) ==0 )
  153.     {
  154.         if(IsPlayerConnected(playerid))
  155.         {
  156.             if(gPlayerLogged[playerid] == 1)
  157.             {
  158.                 SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
  159.                 return 1;
  160.             }
  161.             GetPlayerName(playerid, sendername, sizeof(sendername));
  162.             format(string, sizeof(string), "%s.cer", sendername);
  163.             new File: hFile = fopen(string, io_read);
  164.             if (hFile)
  165.             {
  166.                 SendClientMessage(playerid, COLOR_YELLOW, "That Username is already taken, please choose a different one.");
  167.                 fclose(hFile);
  168.                 return 1;
  169.             }
  170.             new tmppass[64];
  171.             tmp = strtok(cmdtext, idx);
  172.             if(!strlen(tmp))
  173.             {
  174.                 SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /register [password]");
  175.                 return 1;
  176.             }
  177.             strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
  178.             Encrypt(tmppass);
  179.             OnPlayerRegister(playerid,tmppass);
  180.         }
  181.         return 1;
  182.     }
  183.     if (strcmp(cmd, "/stats", true) == 0)
  184.     {
  185.         if(IsPlayerConnected(playerid))
  186.         {
  187.             if (gPlayerLogged[playerid] != 0)
  188.             {
  189.                 ShowStats(playerid,playerid);
  190.             }
  191.             else
  192.             {
  193.                 SendClientMessage(playerid, COLOR_GRAD1, "   You are not Logged in !");
  194.             }
  195.         }
  196.         return 1;
  197.     }
  198. //=================[Bank System]================================================================
  199.     if(strcmp(cmd, "/bank", true) == 0 || strcmp(cmd, "/deposit", true) == 0)
  200.     {
  201.         if(IsPlayerConnected(playerid))
  202.         {
  203.             if(!PlayerToPoint(20.0,playerid,2026.4064,1017.9352,10.8203))
  204.             {
  205.                 SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
  206.                 return 1;
  207.             }
  208.             tmp = strtok(cmdtext, idx);
  209.             if(!strlen(tmp))
  210.             {
  211.                 SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /bank [amount]");
  212.                 format(string, sizeof(string), "  You Have $%d in your account.", PlayerInfo[playerid][pBank]);
  213.                 SendClientMessage(playerid, COLOR_GRAD3, string);
  214.                 return 1;
  215.             }
  216.             new cashdeposit = strval(tmp);
  217.             if(!strlen(tmp))
  218.             {
  219.                 SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /bank [amount]");
  220.                 format(string, sizeof(string), "  You Have $%d in your account.", PlayerInfo[playerid][pBank]);
  221.                 SendClientMessage(playerid, COLOR_GRAD3, string);
  222.                 return 1;
  223.             }
  224.             if (cashdeposit > GetPlayerMoney(playerid) || cashdeposit < 1)
  225.             {
  226.                 SendClientMessage(playerid, COLOR_GRAD2, "   You dont have that much");
  227.                 return 1;
  228.             }
  229.             GivePlayerMoney(playerid,-cashdeposit);
  230.             new curfunds = PlayerInfo[playerid][pBank];
  231.             PlayerInfo[playerid][pBank]=cashdeposit+PlayerInfo[playerid][pBank];
  232.             SendClientMessage(playerid, COLOR_WHITE, "|___ BANK STATMENT ___|");
  233.             format(string, sizeof(string), "  Old Balance: $%d", curfunds);
  234.             SendClientMessage(playerid, COLOR_GRAD2, string);
  235.             format(string, sizeof(string), "  Deposit: $%d",cashdeposit);
  236.             SendClientMessage(playerid, COLOR_GRAD4, string);
  237.             SendClientMessage(playerid, COLOR_GRAD6, "|-----------------------------------------|");
  238.             format(string, sizeof(string), "  New Balance: $%d", PlayerInfo[playerid][pBank]);
  239.             SendClientMessage(playerid, COLOR_WHITE, string);
  240.             return 1;
  241.         }
  242.         return 1;
  243.     }
  244.     if(strcmp(cmd, "/withdraw", true) == 0)
  245.     {
  246.         if(IsPlayerConnected(playerid))
  247.         {
  248.             if(!PlayerToPoint(20.0,playerid,2026.4064,1017.9352,10.8203))
  249.             {
  250.                 SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
  251.                 return 1;
  252.             }
  253.             tmp = strtok(cmdtext, idx);
  254.             if(!strlen(tmp))
  255.             {
  256.                 SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /withdraw [amount]");
  257.                 format(string, sizeof(string), "  You Have $%d in your account.", PlayerInfo[playerid][pBank]);
  258.                 SendClientMessage(playerid, COLOR_GRAD3, string);
  259.                 return 1;
  260.             }
  261.             new cashdeposit = strval(tmp);
  262.             if(!strlen(tmp))
  263.             {
  264.                 SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /withdraw [amount]");
  265.                 format(string, sizeof(string), "  You Have $%d in your account.", PlayerInfo[playerid][pBank]);
  266.                 SendClientMessage(playerid, COLOR_GRAD3, string);
  267.                 return 1;
  268.             }
  269.             if (cashdeposit > PlayerInfo[playerid][pBank] || cashdeposit < 1)
  270.             {
  271.                 SendClientMessage(playerid, COLOR_GRAD2, "   You dont have that much !");
  272.                 return 1;
  273.             }
  274.             ConsumingMoney[playerid] = 1;
  275.             GivePlayerMoney(playerid,cashdeposit);
  276.             PlayerInfo[playerid][pBank]=PlayerInfo[playerid][pBank]-cashdeposit;
  277.             format(string, sizeof(string), "  You Have Withdrawn $%d from your account Total: $%d ", cashdeposit,PlayerInfo[playerid][pBank]);
  278.             SendClientMessage(playerid, COLOR_YELLOW, string);
  279.             return 1;
  280.         }
  281.         return 1;
  282.     }
  283.     if(strcmp(cmd, "/balance", true) == 0)
  284.     {
  285.         if(IsPlayerConnected(playerid))
  286.         {
  287.             if(!PlayerToPoint(20.0,playerid,2026.4064,1017.9352,10.8203))
  288.             {
  289.                 SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
  290.                 return 1;
  291.             }
  292.             format(string, sizeof(string), "  You Have $%d in your account.",PlayerInfo[playerid][pBank]);
  293.             SendClientMessage(playerid, COLOR_YELLOW, string);
  294.         }
  295.         return 1;
  296.     }
  297.     if(strcmp(cmd, "/transfer", true) == 0 || strcmp(cmd, "/wiretransfer", true) == 0)
  298.     {
  299.         if(IsPlayerConnected(playerid))
  300.         {
  301.             if(!PlayerToPoint(20.0,playerid,2305.688964,-16.088100,26.749599))
  302.             {
  303.                 SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
  304.                 return 1;
  305.             }
  306.             tmp = strtok(cmdtext, idx);
  307.             if(!strlen(tmp))
  308.             {
  309.                 SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /transfer [playerid/PartOfName] [amount]");
  310.                 return 1;
  311.             }
  312.             giveplayerid = ReturnUser(tmp);
  313.             tmp = strtok(cmdtext, idx);
  314.             if(!strlen(tmp))
  315.             {
  316.                 SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /transfer [playerid/PartOfName] [amount]");
  317.                 return 1;
  318.             }
  319.             moneys = strval(tmp);
  320.             if (IsPlayerConnected(giveplayerid))
  321.             {
  322.                 if(giveplayerid != INVALID_PLAYER_ID)
  323.                 {
  324.                     GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  325.                     GetPlayerName(playerid, sendername, sizeof(sendername));
  326.                     playermoney = PlayerInfo[playerid][pBank] ;
  327.                     if (moneys > 0 && playermoney >= moneys)
  328.                     {
  329.                         PlayerInfo[playerid][pBank] -= moneys;
  330.                         PlayerInfo[giveplayerid][pBank] += moneys;
  331.                         format(string, sizeof(string), "   You have transferd $%d to %s's account", moneys, giveplayer,giveplayerid);
  332.                         PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  333.                         SendClientMessage(playerid, COLOR_GRAD1, string);
  334.                         format(string, sizeof(string), "   You have recieved $%d to into your account from %s", moneys, sendername, playerid);
  335.                         SendClientMessage(giveplayerid, COLOR_GRAD1, string);
  336.                         format(string, sizeof(string), "%s transferd $%d to %s", sendername, moneys, giveplayer);
  337.                         if(moneys >= 500000)
  338.                         {
  339.                             ABroadCast(COLOR_YELLOW,string,1);
  340.                         }
  341.                         printf("%s", string);
  342.                         PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
  343.                     }
  344.                     else
  345.                     {
  346.                         SendClientMessage(playerid, COLOR_GRAD1, "   Invalid transaction amount.");
  347.                     }
  348.                 }
  349.             }
  350.             else
  351.             {
  352.                 format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
  353.                 SendClientMessage(playerid, COLOR_GRAD1, string);
  354.             }
  355.         }
  356.         return 1;
  357.     }
  358. //==========================[Enter and Exit]==========================================================================================================
  359.     if(strcmp(cmd, "/enter", true) == 0)
  360.     {
  361.             if (PlayerToPoint(3.0, playerid,2026.4064,1017.9352,10.8203))// Bank
  362.             {
  363.                 SetPlayerPos(playerid,2305.688964,-16.088100,26.749599);
  364.                 GameTextForPlayer(playerid, "~w~Welcome to the City Bank!~n~~w~Type /exit to get out", 5000, 1);
  365.                 SetPlayerInterior(playerid, 0);
  366.             }
  367.             return 1;
  368.     }
  369.     if(strcmp(cmdtext, "/exit", true) == 0)
  370.     {
  371.            if (PlayerToPoint(3.0, playerid,2305.688964,-16.088100,26.749599))// Bank
  372.             {
  373.                 SetPlayerPos(playerid,2026.4064,1017.9352,10.8203);
  374.                 SetPlayerInterior(playerid, 0);
  375.             }
  376.            return 1;
  377.     }
  378.     return 0;
  379. }
  380.  
  381. public Encrypt(string[])
  382. {
  383.     for(new x=0; x < strlen(string); x++)
  384.       {
  385.           string[x] += (3^x) * (x % 15);
  386.           if(string[x] > (0xff))
  387.           {
  388.               string[x] -= 64;
  389.           }
  390.       }
  391.     return 1;
  392. }
  393.  
  394.  
  395. public OnPlayerLogin(playerid,password[])
  396. {
  397.     new pname2[MAX_PLAYER_NAME];
  398.     new pname3[MAX_PLAYER_NAME];
  399.     new string2[64];
  400.     new string3[128];
  401.     GetPlayerName(playerid, pname2, sizeof(pname2));
  402.     format(string2, sizeof(string2), "%s.cer", pname2);
  403.     new File: UserFile = fopen(string2, io_read);
  404.     if (UserFile)
  405.     {
  406.         new valtmp[128];
  407.         fread(UserFile, valtmp);strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
  408.         new PassData[256];
  409.         new keytmp[256];
  410.         fread( UserFile , PassData , sizeof( PassData ) );
  411.         keytmp = ini_GetKey( PassData );
  412.         if( strcmp( keytmp , "Password" , true ) == 0 )
  413.         {
  414.             valtmp = ini_GetValue( PassData );
  415.             strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
  416.         }
  417.         if(strcmp(PlayerInfo[playerid][pPassword],password, true ) == 0)
  418.         {
  419.             new key[128],val[128];
  420.             new Data[128];
  421.             while(fread(UserFile,Data,sizeof(Data)))
  422.             {
  423.                 key = ini_GetKey(Data);
  424.                 if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
  425.                 if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
  426.                 if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
  427.                 if( strcmp( key , "Bank" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pBank] = strval( val ); }
  428.                 GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
  429.             }
  430.             fclose(UserFile);
  431.             gPlayerLogged[playerid] = 1;
  432.             gPlayerAccount[playerid] = 1;
  433.             new kills = PlayerInfo[playerid][pKills];
  434.             SetPlayerScore(playerid, kills);
  435.             GetPlayerName(playerid, pname3, sizeof(pname3));
  436.             format(string3, sizeof(string3), "Welcome %s, you have been succesfully logged in!", pname3);
  437.             SendClientMessage(playerid, COLOR_WHITE,string3);
  438.         }
  439.         else
  440.         {
  441.             SendClientMessage(playerid, COLOR_GREY, "   Password does not match your name");
  442.             fclose(UserFile);
  443.         }
  444.     }
  445.     return 1;
  446. }
  447.  
  448. public OnPlayerUpdate(playerid)
  449. {
  450.     if(IsPlayerConnected(playerid))
  451.     {
  452.         if(gPlayerLogged[playerid])
  453.         {
  454.             new string3[32];
  455.             new pname3[MAX_PLAYER_NAME];
  456.             GetPlayerName(playerid, pname3, sizeof(pname3));
  457.             format(string3, sizeof(string3), "%s.cer", pname3);
  458.             new File: pFile = fopen(string3, io_write);
  459.             if (pFile)
  460.             {
  461.                 new var[32];
  462.                 format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(pFile, var);
  463.                 fclose(pFile);
  464.                 new File: hFile = fopen(string3, io_append);
  465.                 PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
  466.                 format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
  467.                 format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
  468.                 format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
  469.                 format(var, 32, "Bank=%d\n",PlayerInfo[playerid][pBank]);fwrite(hFile, var);
  470.                 fclose(hFile);
  471.             }
  472.         }
  473.     }
  474.     return 1;
  475. }
  476.  
  477. stock ini_GetKey( line[] )
  478. {
  479.     new keyRes[128];
  480.     keyRes[0] = 0;
  481.     if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  482.     strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  483.     return keyRes;
  484. }
  485.  
  486. stock ini_GetValue( line[] )
  487. {
  488.     new valRes[128];
  489.     valRes[0]=0;
  490.     if ( strfind( line , "=" , true ) == -1 ) return valRes;
  491.     strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  492.     return valRes;
  493. }
  494.  
  495.  
  496. strtok(const string[], &index)
  497. {
  498.     new length = strlen(string);
  499.     while ((index < length) && (string[index] <= ' '))
  500.     {
  501.         index++;
  502.     }
  503.  
  504.     new offset = index;
  505.     new result[20];
  506.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  507.     {
  508.         result[index - offset] = string[index];
  509.         index++;
  510.     }
  511.     result[index - offset] = EOS;
  512.     return result;
  513. }
  514.  
  515. public ShowStats(playerid,targetid)
  516. {
  517.     if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
  518.     {
  519.         new cash =  GetPlayerMoney(targetid);
  520.         new deaths = PlayerInfo[targetid][pDeaths];
  521.         new kills = PlayerInfo[targetid][pKills];
  522.         new name[MAX_PLAYER_NAME];
  523.         GetPlayerName(targetid, name, sizeof(name));
  524.         new Float:px,Float:py,Float:pz;
  525.         GetPlayerPos(targetid, px, py, pz);
  526.         new coordsstring[256];
  527.         new bank = PlayerInfo[targetid][pBank];
  528.         SendClientMessage(playerid, COLOR_GREEN,"________________________________________________");
  529.         format(coordsstring, sizeof(coordsstring),"*** %s ***",name);
  530.         SendClientMessage(playerid, COLOR_WHITE,coordsstring);
  531.         format(coordsstring, sizeof(coordsstring), "Kills:[%d] Deaths:[%d] Cash:[$%d] Bank:[$%d]",kills,deaths,cash,bank);
  532.         SendClientMessage(playerid, COLOR_GRAD5,coordsstring);
  533.         SendClientMessage(playerid, COLOR_GREEN,"________________________________________________");
  534.     }
  535. }
  536.  
  537. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  538. {
  539.     if(IsPlayerConnected(playerid))
  540.     {
  541.         new Float:oldposx, Float:oldposy, Float:oldposz;
  542.         new Float:tempposx, Float:tempposy, Float:tempposz;
  543.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  544.         tempposx = (oldposx -x);
  545.         tempposy = (oldposy -y);
  546.         tempposz = (oldposz -z);
  547.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  548.         {
  549.             return 1;
  550.         }
  551.     }
  552.     return 0;
  553. }
  554.  
  555. public ABroadCast(color,const string[],level)
  556. {
  557.     for(new i = 0; i < MAX_PLAYERS; i++)
  558.     {
  559.         if(IsPlayerConnected(i))
  560.         {
  561.                 SendClientMessage(i, color, string);
  562.                 printf("%s", string);
  563.         }
  564.     }
  565.     return 1;
  566. }
  567.  
  568. public CustomPickups()
  569. {
  570.     for(new i = 0; i < MAX_PLAYERS; i++)
  571.     {
  572.     if (PlayerToPoint(3, i,2026.4064,1017.9352,10.8203)) // Bank
  573.     {
  574.     GameTextForPlayer(i, "~y~Welcome to The ~y~City Bank~n~~w~Type /enter to go in", 5000, 5);
  575.     }
  576.     }
  577.     return 1;
  578. }
  579.  
  580. public OnPlayerRegister(playerid, password[])
  581. {
  582.     if(IsPlayerConnected(playerid))
  583.     {
  584.             new string3[32];
  585.             new playername3[MAX_PLAYER_NAME];
  586.             GetPlayerName(playerid, playername3, sizeof(playername3));
  587.             format(string3, sizeof(string3), "%s.ini", playername3);
  588.             new File: hFile = fopen(string3, io_write);
  589.             if (hFile)
  590.             {
  591.                 strmid(PlayerInfo[playerid][pPassword], password, 0, strlen(password), 255);
  592.                 new var[32];
  593.                 format(var, 32, "Password=%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
  594.                 PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
  595.                 format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
  596.                 format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
  597.                 format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
  598.                 format(var, 32, "Bank=%d\n",PlayerInfo[playerid][pBank]);fwrite(hFile, var);
  599.                 fclose(hFile);
  600.                 SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you can login now (/login [password]).");
  601.             }
  602.     }
  603.     return 1;
  604. }
  605.  
  606. public OnPlayerLogin(playerid,password[])
  607. {
  608.     new tmp2[256];
  609.     new string2[64];
  610.     new playername2[MAX_PLAYER_NAME];
  611.     GetPlayerName(playerid, playername2, sizeof(playername2));
  612.     format(string2, sizeof(string2), "%s.cer", playername2);
  613.     new File: UserFile = fopen(string2, io_read);
  614.     if ( UserFile )
  615.     {
  616.         new PassData[256];
  617.         new keytmp[256], valtmp[256];
  618.         fread( UserFile , PassData , sizeof( PassData ) );
  619.         keytmp = ini_GetKey( PassData );
  620.         if( strcmp( keytmp , "Key" , true ) == 0 )
  621.         {
  622.             valtmp = ini_GetValue( PassData );
  623.             strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
  624.         }
  625.         if(strcmp(PlayerInfo[playerid][pPassword],password, true ) == 0 )
  626.         {
  627.                 new key[ 256 ] , val[ 256 ];
  628.                 new Data[ 256 ];
  629.                 while ( fread( UserFile , Data , sizeof( Data ) ) )
  630.                 {
  631.                 key = ini_GetKey( Data );
  632.                 if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
  633.                 if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
  634.                 if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
  635.                 if( strcmp( key , "Bank" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pBank] = strval( val ); }
  636.                 GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
  637.                 }//end while
  638.                 fclose(UserFile);//close the file after everything has been read in the while
  639.         }
  640.         else
  641.         {
  642.             SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password does not match your name.");
  643.             fclose(UserFile);
  644.             gPlayerLogTries[playerid] += 1;
  645.             if(gPlayerLogTries[playerid] == 4) { Ban(playerid); }
  646.             return 1;
  647.         }
  648.         ConsumingMoney[playerid] = 1;
  649.         format(string2, sizeof(string2), "SERVER: Welcome %s",playername2);
  650.         SendClientMessage(playerid, COLOR_WHITE,string2);
  651.         printf("%s has logged in.",playername2);
  652.         gPlayerLogged[playerid] = 1;
  653.         format(tmp2, sizeof(tmp2), "~w~Welcome ~n~~y~   %s", playername2);
  654.         GameTextForPlayer(playerid, tmp2, 5000, 1);
  655.         gPlayerLogged[playerid] = 1;
  656.         gPlayerAccount[playerid] = 1;
  657.         new kills = PlayerInfo[playerid][pKills];
  658.         SetPlayerScore(playerid, kills);
  659.     }
  660.     return 1;
  661. }
  662.  
  663.  
  664. #endif
  665.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement