[help]
#1

could someone help me bind these to scripts together so thwn i go /login it logs in both of them. thx for ur time



Код:
//> Includes <//
#include <a_samp>
//> Pragmas <//
//#pragma unused dmvcp
//> Defines <//
#define GREEN 0x21DD00FF
#define RED 0xE60000FF
#define YELLOW 0xFFFF00FF
#define ORANGE 0xF97804FF
#define GRAY 0xCECECEFF
#define LIGHTBLUE 0x00C2ECFF
//#define CHECKPOINT_DMV 0
#define DrivingTestCash 5000 // Edit this if needed. 5000 = the cash that you'll pay to take the driving test
#define TooSlow 120 // 120 = if the time is 110 or more, you are driving too slow. You may edit this if needed.
#define TooFast 105 // 105 = if the time is less than 105, you are driving too fast. You may edit this if needed.
#define MINVEHHP 900 // 900 = the minimum vehicle health the vehicle can have to pass the test. You may edit this if needed.
//> Variables <//
new Menu:dmvoption[MAX_PLAYERS];
new Float:DrivingSchoolCP[31][3] =
{
  {-2047.318237, -78.493286, 35.043674}, // Starting of the first test's checkpoints
    {-2020.431396, -72.462600, 35.046836},
    {-2004.230468, -63.067325, 35.043403},
    {-2004.557861, 92.230476, 27.414079},
    {-2001.461181, 306.811828, 34.771896},
    {-2016.024169, 322.754547, 34.890529},
    {-2134.363769, 321.980102, 35.024250},
    {-2238.925292, 322.899688, 35.046855},
    {-2249.107177, 327.225555, 35.046890},
    {-2298.212402, 411.341003, 34.885196},
    {-2321.346435, 410.600982, 34.890609},
    {-2423.162597, 55.284839, 34.890628},
    {-2485.413818, 42.110366, 26.862459},
    {-2590.423339, 41.848583, 4.056760},
    {-2606.167480, 32.018920, 4.118466},
    {-2606.167480, -57.042472, 4.054659},
    {-2597.467041, -72.002243, 4.125582},
    {-2514.526123, -72.963630, 24.342817},
    {-2386.916503, -71.996078, 35.038841},
    {-2273.539550, -72.938049, 35.039089},
    {-2261.753173, -83.578163, 35.046840},
    {-2260.035400, -177.289489, 35.046775},
    {-2245.059814, -192.252777, 35.046882},
    {-2164.877441, -82.917831, 35.046836},
    {-2154.212402, -72.622978, 35.046878},
    {-2052.066894, -72.116477, 35.042152},
    {-2047.616333, -88.755950, 35.038990},
    {-2025.749145, -97.650115, 35.039009},
    {-2044.890747, -139.023742, 35.188522}, // Starting of the second test's checkpoints
    {-2056.534667, -222.281845, 35.198474},
    {-2062.643554, -118.802627, 35.325977}
};
new DMVCP[MAX_PLAYERS];
new dmvcar,dmvcar2;
new DrivingLicense[MAX_PLAYERS];
new DMVTest[MAX_PLAYERS];
new DMVCount[MAX_PLAYERS];
new DrivingTestTime[MAX_PLAYERS];
new DMVT,DMVT2;
new barrier;

new
    Password[MAX_PLAYERS],
    IP[MAX_PLAYERS],
    IsLogged[MAX_PLAYERS];
//> Forwards <//
forward DrivingTestCount(playerid);
forward DrivingTestCount2(playerid);
forward DMVTest2Barrels(playerid);

forward OnPlayerRegister(playerid,password[]);
forward OnPlayerLogin(playerid,password[]);
forward OnPlayerUpdate(playerid);
forward Encrypt(string[]);
//> Callbacks <//
main() return 1;
stock ini_GetKey( line[] )
{
    new keyRes[256];
    keyRes[0] = 0;
  if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  return keyRes;
}

stock ini_GetValue( line[] )
{
    new valRes[256];
    valRes[0]=0;
    if ( strfind( line , "=" , true ) == -1 ) return valRes;
    strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
    return valRes;
}

stock strtok(const string[], &index,seperator=' ')
{
    new length = strlen(string);
    new offset = index;
    new result[128];
    while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }

    result[index - offset] = EOS;
    if ((index < length) && (string[index] == seperator))
    {
        index++;
    }
    return result;
}

public Encrypt(string[])
{
    for(new x=0; x < strlen(string); x++)
     {
         string[x] += (3^x) * (x % 15);
         if(string[x] > (0xff))
         {
             string[x] -= 256;
         }
     }
    return 1;
}

public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
            new player[24];
        GetPlayerName(playerid, player, 50);
            new string3[128];
            new playername3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            format(string3, sizeof(string3), "[DMV]%s.ini", playername3);
            new ip[20];
            GetPlayerIp(playerid,ip,sizeof(ip));
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
              strmid(Password[playerid], password, 0, strlen(password), 255);
                new var[128];
                format(var, 128, "Password=%s\n", Password[playerid]);fwrite(hFile, var);
                format(var, 128, "CarLicense=%d\n", DrivingLicense[playerid]);fwrite(hFile, var);
                format(var, 128, "IP=%s\n",IP[playerid]);fwrite(hFile, var);
                fclose(hFile);
                SendClientMessage(playerid, GREEN, "» You have successfully registered an account. You may now /login");
            }
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(IsLogged[playerid])
        {
            new string3[128];
            new playername3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            format(string3, sizeof(string3), "[DMV]%s.ini", playername3);
            new ip[20];
            GetPlayerIp(playerid,ip,sizeof(ip));
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
                new var[128];
                format(var, 128, "Password=%s\n", Password[playerid]);fwrite(hFile, var);
                format(var, 128, "CarLicense=%d\n", DrivingLicense[playerid]);fwrite(hFile, var);
                format(var, 128, "IP=%s\n",IP[playerid]);fwrite(hFile, var);
                fclose(hFile);
            }
        }
    }
    return 1;
}

public OnPlayerLogin(playerid,password[])
{
//   new tmp2[256];
  new string2[128];
    new playername2[MAX_PLAYER_NAME];
  GetPlayerName(playerid, playername2, sizeof(playername2));
    format(string2, sizeof(string2), "[DMV]%s.ini", playername2);
    new File: UserFile = fopen(string2, io_read);
    if ( UserFile )
    {
      new PassData[256];
      new keytmp[256], valtmp[256];
      fread( UserFile , PassData , sizeof( PassData ) );
      keytmp = ini_GetKey( PassData );
      if( strcmp( keytmp , "Password" , true ) == 0 )
        {
            valtmp = ini_GetValue( PassData );
            strmid(Password[playerid], valtmp, 0, strlen(valtmp)-1, 255);
        }
        if(strcmp(Password[playerid],password, true ) == 0 )
        {
              new key[256] , val[256];
              new Data[256];
              while ( fread( UserFile , Data , sizeof( Data ) ) )
                {
                    key = ini_GetKey( Data );
                    if( strcmp( key , "DrivingLicense" , true ) == 0 )
                    {
                        val = ini_GetValue( Data );
                        DrivingLicense[playerid] = strval( val );
                    }
                }
        fclose(UserFile);
        IsLogged[playerid] = 1;

        }
        else
        {
            SendClientMessage(playerid, RED, "Incorrect Password.");
        fclose(UserFile);
        return 1;
        }
        format(string2, sizeof(string2), "» You have logged in as %s",playername2);
        SendClientMessage(playerid, GREEN,string2);
        printf("[DMV] %s has logged in.",playername2);
    }
    return 1;
}

public OnGameModeInit()
{
    dmvcar = AddStaticVehicle(445,-2027,-94,35,92,1,1);
    dmvcar2 = AddStaticVehicle(445,-2047,-109,35,269,1,1);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new Ip[20];
    GetPlayerIp(playerid,Ip,sizeof(Ip));

    strmid(Password[playerid]," ",0,1,1);
    strmid(IP[playerid],Ip,0,1,1);
    DrivingLicense[playerid] = 0;
    IsLogged[playerid] = 0;

  dmvoption[playerid] = CreateMenu(" Driving School",0,200,100,300,500);
    SetMenuColumnHeader(dmvoption[playerid],0,"Would you like to take the test?");
    AddMenuItem(dmvoption[playerid],0,"Yes, I want to take the test");
    AddMenuItem(dmvoption[playerid],0,"No, I am not ready yet.");
    SetPlayerCheckpoint(playerid,-2037.1954,-94.4220,35.1641,2.0);
    DMVCP[playerid] = -1;
    DMVTest[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new dmvadmiral = dmvcar || dmvcar2;
    if (GetPlayerVehicleID(playerid) == dmvcar || GetPlayerVehicleID(playerid) == dmvcar2) SetVehicleToRespawn(dmvadmiral);

    OnPlayerUpdate(playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if (DMVTest[playerid] == 1)
    {
    SendClientMessage(playerid,RED,"You 'died' during a driving test. Therefore, it has been cancelled.");
        DisablePlayerCheckpoint(playerid);
        DMVCP[playerid] = -1;
        DMVTest[playerid] = 0;
        KillTimer(DMVT);
        SetPlayerCheckpoint(playerid,-2037.1954,-94.4220,35.1641,2.0);
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext,idx);
    if(strcmp(cmdtext, "/dmv", true) == 0)
    {
      SetPlayerPos(playerid,-2027.835693, -98.881484, 35.164062);
      SetPlayerFacingAngle(playerid,180);
      SetCameraBehindPlayer(playerid);
      return 1;
    }
    if(strcmp(cmdtext, "/stopdmvtest", true) == 0)
    {
      if (DMVTest[playerid] == 0)
      {
        SendClientMessage(playerid,RED,"You're not having a driving test.");
        return 1;
      }
      SendClientMessage(playerid,GREEN,"You abandoned the test.");
        DisablePlayerCheckpoint(playerid);
        DMVCP[playerid] = -1;
        DMVTest[playerid] = 0;
        SetPlayerCheckpoint(playerid,-2037.1954,-94.4220,35.1641,2.0);
      return 1;
    }
    if(strcmp(cmdtext, "/licenses", true) == 0)
    {
      SendClientMessage(playerid,LIGHTBLUE,"[-------------Licenses-------------]");
      if (DrivingLicense[playerid] == 0) SendClientMessage(playerid,GRAY,"Driving: Not Passed."); else SendClientMessage(playerid,GRAY,"Driving: Passed.");
      return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    if (vehicleid == dmvcar && DMVTest[playerid] == 0) { SetPlayerPos(playerid,X,Y,Z+3); SendClientMessage(playerid,RED,"You didn't subscribe to take the driving test, therefore you are not allowed to drive this car."); }
    if (vehicleid == dmvcar2 && DMVTest[playerid] == 0) { SetPlayerPos(playerid,X,Y,Z+3); SendClientMessage(playerid,RED,"You didn't subscribe to take the driving test, therefore you are not allowed to drive this car."); }
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    if (vehicleid == dmvcar) { SetVehicleToRespawn(dmvcar); SetVehicleParamsForPlayer(dmvcar,playerid,0,0); }
    if (vehicleid == dmvcar2) { SetVehicleToRespawn(dmvcar2); SetVehicleParamsForPlayer(dmvcar2,playerid,0,0); }
    return 1;
}
ill post 2end bit


Reply
#2

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if (oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && DMVTest[playerid] == 1 && vehicleid == dmvcar) SetVehicleParamsForPlayer(dmvcar,playerid,0,0);
    if (oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && DMVTest[playerid] == 1 && vehicleid == dmvcar2) SetVehicleParamsForPlayer(dmvcar2,playerid,0,0);
    if (oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && DrivingLicense[playerid] == 0 && DMVTest[playerid] == 0)
    {
      SendClientMessage(playerid,RED,"Warning: you might get caught for driving without a real driving license!");
      new star = GetPlayerWantedLevel(playerid);
      SetPlayerWantedLevel(playerid,star+1);
    }
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    switch(DMVCP[playerid])
    {
      case -1:
        {
          ShowMenuForPlayer(dmvoption[playerid],playerid);
        TogglePlayerControllable(playerid,0);
        }
      case 0:
        {
            if(!IsPlayerInVehicle(playerid,dmvcar))
            {
              SendClientMessage(playerid,RED,"You're not in the Admiral car!");
            }
            else
            {
              DisablePlayerCheckpoint(playerid);
              DMVCP[playerid]++;
              SetPlayerCheckpoint(playerid,DrivingSchoolCP[1][0],DrivingSchoolCP[1][1],DrivingSchoolCP[1][2],5.0);
              DMVCount[playerid] = 1;
              DMVT = SetTimerEx("DrivingTestCount",1000,0,"d",playerid);
              DMVT2 = SetTimerEx("DrivingTestCount2",1000,0,"d",playerid);
            }
        }
        case 1..26:
        {
          if(!IsPlayerInVehicle(playerid,dmvcar))
            {
              SendClientMessage(playerid,RED,"You're not in the Admiral car!");
            }
            else
            {
              DisablePlayerCheckpoint(playerid);
              SetPlayerCheckpoint(playerid,DrivingSchoolCP[DMVCP[playerid]+1][0],DrivingSchoolCP[DMVCP[playerid]+1][1],DrivingSchoolCP[DMVCP[playerid]+1][2],5.0);
              DMVCP[playerid]++;
            }
        }
        case 27:
        {
          new Float:VehHealth;
          new string[128];
          GetVehicleHealth(GetPlayerVehicleID(playerid),VehHealth);
          if (VehHealth < MINVEHHP)
            {
                SendClientMessage(playerid,RED,"You failed the test: you weren't driving safely!");
                DrivingLicense[playerid] = 0;
                DisablePlayerCheckpoint(playerid);
                DMVCP[playerid] = -1;
                format(string, sizeof(string), "Time: %d",DrivingTestTime[playerid]);
                SendClientMessage(playerid,YELLOW,string);
            DMVTest[playerid] = 0;
                KillTimer(DMVT);
                SetPlayerCheckpoint(playerid,-2037.1954,-94.4220,35.1641,2.0);
            }
            else if (DrivingTestTime[playerid] > TooSlow)
            {
                SendClientMessage(playerid,RED,"You failed the test: you were driving too slow!");
                DrivingLicense[playerid] = 0;
                DisablePlayerCheckpoint(playerid);
                DMVCP[playerid] = -1;
                format(string, sizeof(string), "Time: %d",DrivingTestTime[playerid]);
                SendClientMessage(playerid,YELLOW,string);
            DMVTest[playerid] = 0;
                KillTimer(DMVT);
                SetPlayerCheckpoint(playerid,-2037.1954,-94.4220,35.1641,2.0);
            }
            else if (DrivingTestTime[playerid] < TooFast)
            {
                SendClientMessage(playerid,RED,"You failed the test: you were driving too fast!");
                DrivingLicense[playerid] = 0;
                DisablePlayerCheckpoint(playerid);
                DMVCP[playerid] = -1;
                format(string, sizeof(string), "Time: %d",DrivingTestTime[playerid]);
                SendClientMessage(playerid,YELLOW,string);
            DMVTest[playerid] = 0;
                KillTimer(DMVT);
                SetPlayerCheckpoint(playerid,-2037.1954,-94.4220,35.1641,2.0);
            }
            else if (DrivingTestTime[playerid] > TooFast && DrivingTestTime[playerid] < TooSlow)
            {
                SendClientMessage(playerid,GREEN,"You passed the first test!");
                DMVCP[playerid] = 28;
                DMVTest2Barrels(playerid);
                DisablePlayerCheckpoint(playerid);
                SetPlayerCheckpoint(playerid,DrivingSchoolCP[28][0],DrivingSchoolCP[28][1],DrivingSchoolCP[28][2],5.0);
                SetPlayerPos(playerid,-2046.157592, -109.187286, 35.234008);
            }

        }
        case 28,29:
        {
            if(!IsPlayerInVehicle(playerid,dmvcar2))
            {
              SendClientMessage(playerid,RED,"You're not in the Admiral car!");
            }
            else
            {
              DisablePlayerCheckpoint(playerid);
              SetPlayerCheckpoint(playerid,DrivingSchoolCP[DMVCP[playerid]+1][0],DrivingSchoolCP[DMVCP[playerid]+1][1],DrivingSchoolCP[DMVCP[playerid]+1][2],5.0);
              DMVCP[playerid]++;
              SetPlayerObjectRot(playerid,barrier, 0, 270.6185, 3.4377);
            }
        }
        case 30:
        {
          if(!IsPlayerInVehicle(playerid,dmvcar2))
            {
              SendClientMessage(playerid,RED,"You're not in the Admiral car!");
            }
            else
            {
                new string[256];
              DisablePlayerCheckpoint(playerid);
              DMVCP[playerid] = -1;
              SendClientMessage(playerid,GREEN,"You passed the driving test! Here's your license. Drive safely!");
              DrivingLicense[playerid] = 1;
                SendClientMessage(playerid,LIGHTBLUE,"You earned a driving license. ( /licenses )");
                SetPlayerCheckpoint(playerid,-2037.1954,-94.4220,35.1641,2.0);
                format(string, sizeof(string), "Total Time: %d",DrivingTestTime[playerid]);
                SendClientMessage(playerid,YELLOW,string);
                DMVTest[playerid] = 0;
                KillTimer(DMVT);
            }
        }
    }
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    new Menu:Current = GetPlayerMenu(playerid);
    if (Current == dmvoption[playerid])
    {
        switch (row)
        {
          case 0:
            {
                if (GetPlayerMoney(playerid) < DrivingTestCash)
                {
                    SendClientMessage(playerid,RED,"You don't have enough cash");
                    ShowMenuForPlayer(dmvoption[playerid],playerid);
                    return 1;
                }
                if (DrivingLicense[playerid] == 1)
                {
                  SendClientMessage(playerid,RED,"You already have a license!");
                  return 1;
                }
                GivePlayerMoney(playerid,-DrivingTestCash);
                SetPlayerPos(playerid,-2027.8353, -98.8884, 35.1642);
                SetPlayerFacingAngle(playerid,355);
                SetCameraBehindPlayer(playerid);
                DisablePlayerCheckpoint(playerid);
                SetPlayerCheckpoint(playerid,DrivingSchoolCP[0][0],DrivingSchoolCP[0][1],DrivingSchoolCP[0][2],5.0);
                SendClientMessage(playerid,GREEN,"Get ready!");
                DMVCP[playerid]=0;
                SetPlayerInterior(playerid,0);
                DMVTest[playerid] = 1;
                SetVehicleParamsForPlayer(dmvcar,playerid,1,0);
            }
          case 1: {DisablePlayerCheckpoint(playerid);SendClientMessage(playerid,RED,"Alright, come back again!");SetPlayerCheckpoint(playerid,-2033.396606, -117.458976, 1035.171875,2.0);DMVCP[playerid]=-1;DMVTest[playerid] = 0;}
        }
        TogglePlayerControllable(playerid,1);
        HideMenuForPlayer(dmvoption[playerid],playerid);
    }
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
  TogglePlayerControllable(playerid,1);
  SetPlayerCheckpoint(playerid,-2037.1954,-94.4220,35.1641,2.0);
  SetPlayerPos(playerid,-2029.798217, -113.841880, 1035.171875);
    return 1;
}

public DrivingTestCount(playerid)
{
    if (DMVTest[playerid] == 0)
    {
      KillTimer(DMVT);
    }
    else
    {
        DrivingTestTime[playerid]++;
        DMVT = SetTimerEx("DrivingTestCount",1000,0,"d",playerid);
    }
    return 1;
}

public DrivingTestCount2(playerid)
{
    new string[128];
    if (DMVTest[playerid] == 0) { KillTimer(DMVT2); DrivingTestTime[playerid] = 0; }
    else
    {
    format(string, sizeof(string), "%d",DrivingTestTime[playerid]);
    GameTextForPlayer(playerid,string,1500,6);
    DMVT2 = SetTimerEx("DrivingTestCount2",1000,0,"d",playerid);
    }
    return 1;
k now ill post fs 2
Reply
#3

Код:
#include <a_samp>

#include <utils>

#define FILTERSCRIPT

#if defined FILTERSCRIPT
#define COLOR_GREY 0xBEBEBEAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD6 0xF0F0F0FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF

forward ShowStats(playerid,targetid);
forward OnPlayerUpdate(playerid);
forward Encrypt(string[]);
forward OnPlayerLogin(playerid,const string[]);
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward ABroadCast(color,const string[],level);
forward CustomPickups();

enum pInfo
{
	pPassword[128],
	pKills,
	pDeaths,
	pCash,
	pBank,
};

new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];
new gPlayerAccount[MAX_PLAYERS];
new ConsumingMoney[MAX_PLAYERS];
new sendername[MAX_PLAYER_NAME];
new playermoney;
new pickup;

public OnFilterScriptInit()
{
	print("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
	print(" Kevin433's Login/Register Filterscript");
	print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
	SetTimer("CustomPickups", 1000, 1);
	pickup = CreatePickup(1274, 2,2313.0049,-3.5899,26.7422);
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnPlayerConnect(playerid)
{
  new playrname[MAX_PLAYER_NAME];
  	new connect[128];
  GetPlayerName(playerid, playrname, sizeof(playrname));
	format(connect, sizeof(connect), "%s.cer", playrname);
	if(fexist(connect))
	{
		gPlayerAccount[playerid] = 1;
		SendClientMessage(playerid, COLOR_YELLOW, "You are registered, please login with /login password");
		return 1;
	}
	else
	{
		gPlayerAccount[playerid] = 0;
		SendClientMessage(playerid, COLOR_YELLOW, "You are new here or not registered, please register with /register password");
	}
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  OnPlayerUpdate(playerid);
  gPlayerLogged[playerid] = 0;
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
  new kills = PlayerInfo[playerid][pKills];
  SetPlayerScore(playerid, kills);
  new Float:Health;
  GetPlayerHealth(playerid, Health);
  if(Health == 0.0)
  {
  PlayerInfo[playerid][pDeaths] += 1;
  }
  GivePlayerMoney(killerid,2000);
  PlayerInfo[killerid][pKills] = PlayerInfo[killerid][pKills] + 1;
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[256];
  new idx;
  cmd = strtok(cmdtext, idx);
  	new tmp[256];
  new playername[MAX_PLAYER_NAME];
  new string[256];
  new moneys;
  new giveplayer[MAX_PLAYER_NAME];
  new giveplayerid;
  if (strcmp(cmd, "/login", true) ==0 )
	{
	  if(IsPlayerConnected(playerid))
	  {
	    new tmppass[64];
			if(gPlayerLogged[playerid] == 1)
			{
				SendClientMessage(playerid, COLOR_GREY, "	You are already logged in.");
				return 1;
			}
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GREY, "	USAGE: /login [password]");
				return 1;
			}
			strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
			Encrypt(tmppass);
			OnPlayerLogin(playerid,tmppass);
		}
		return 1;
	}
	if (strcmp(cmd, "/register", true)==0)
	{
		//new string[265];
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_GREY, "USAGE: /register [password]");
			return 1;
		}
		if (gPlayerAccount[playerid] == 1)
		{
			SendClientMessage(playerid, COLOR_GREY, "  That name is already registered");
			return 1;
		}

		strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255);
		Encrypt(PlayerInfo[playerid][pPassword]);
		GetPlayerName(playerid, playername, sizeof(playername));
		format(string, sizeof(string), "%s.cer", playername);
		new File: file = fopen(string, io_read);
		if (file)
		{
			SendClientMessage(playerid, COLOR_GREY, "  That name is already registered");
			fclose(file);
			return 1;
		}
		new File:hFile;
		hFile = fopen(string, io_append);
		new var[32];//
    format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
    format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
    format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
    PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
    format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
    format(var, 32, "Bank=%d\n",PlayerInfo[playerid][pBank]);fwrite(hFile, var);
		fclose(hFile);
		SendClientMessage(playerid, COLOR_WHITE, "Succesfully Registered!");
		SendClientMessage(playerid, COLOR_WHITE, "Next time you connect, type /login <password> to log in.");
		OnPlayerLogin(playerid,PlayerInfo[playerid][pPassword]);
		return 1;
	}
	if (strcmp(cmd, "/stats", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			if (gPlayerLogged[playerid] != 0)
			{
				ShowStats(playerid,playerid);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "  You are not Logged in !");
			}
		}
		return 1;
	}
//=================[Bank System]================================================================
  if(strcmp(cmd, "/bank", true) == 0 || strcmp(cmd, "/deposit", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    if(!PlayerToPoint(20.0,playerid,2313.0049,-3.5899,26.7422))
	    {
	      SendClientMessage(playerid, COLOR_GREY, "  You are not at the Bank !");
	      return 1;
	    }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /bank [amount]");
				format(string, sizeof(string), " You Have $%d in your account.", PlayerInfo[playerid][pBank]);
				SendClientMessage(playerid, COLOR_GRAD3, string);
				return 1;
			}
			new cashdeposit = strval(tmp);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /bank [amount]");
				format(string, sizeof(string), " You Have $%d in your account.", PlayerInfo[playerid][pBank]);
				SendClientMessage(playerid, COLOR_GRAD3, string);
				return 1;
			}
			if (cashdeposit > GetPlayerMoney(playerid) || cashdeposit < 1)
			{
				SendClientMessage(playerid, COLOR_GRAD2, "  You dont have that much");
				return 1;
			}
			GivePlayerMoney(playerid,-cashdeposit);
			new curfunds = PlayerInfo[playerid][pBank];
			PlayerInfo[playerid][pBank]=cashdeposit+PlayerInfo[playerid][pBank];
			SendClientMessage(playerid, COLOR_WHITE, "|___ BANK STATMENT ___|");
			format(string, sizeof(string), " Old Balance: $%d", curfunds);
			SendClientMessage(playerid, COLOR_GRAD2, string);
			format(string, sizeof(string), " Deposit: $%d",cashdeposit);
			SendClientMessage(playerid, COLOR_GRAD4, string);
			SendClientMessage(playerid, COLOR_GRAD6, "|-----------------------------------------|");
			format(string, sizeof(string), " New Balance: $%d", PlayerInfo[playerid][pBank]);
			SendClientMessage(playerid, COLOR_WHITE, string);
			return 1;
		}
		return 1;
	}
	if(strcmp(cmd, "/withdraw", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    if(!PlayerToPoint(20.0,playerid,2313.0049,-3.5899,26.7422))
	    {
	      SendClientMessage(playerid, COLOR_GREY, "  You are not at the Bank !");
	      return 1;
	    }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /withdraw [amount]");
				format(string, sizeof(string), " You Have $%d in your account.", PlayerInfo[playerid][pBank]);
				SendClientMessage(playerid, COLOR_GRAD3, string);
				return 1;
			}
			new cashdeposit = strval(tmp);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /withdraw [amount]");
				format(string, sizeof(string), " You Have $%d in your account.", PlayerInfo[playerid][pBank]);
				SendClientMessage(playerid, COLOR_GRAD3, string);
				return 1;
			}
			if (cashdeposit > PlayerInfo[playerid][pBank] || cashdeposit < 1)
			{
				SendClientMessage(playerid, COLOR_GRAD2, "  You dont have that much !");
				return 1;
			}
		  ConsumingMoney[playerid] = 1;
			GivePlayerMoney(playerid,cashdeposit);
			PlayerInfo[playerid][pBank]=PlayerInfo[playerid][pBank]-cashdeposit;
			format(string, sizeof(string), " You Have Withdrawn $%d from your account Total: $%d ", cashdeposit,PlayerInfo[playerid][pBank]);
			SendClientMessage(playerid, COLOR_YELLOW, string);
			return 1;
		}
		return 1;
	}
	if(strcmp(cmd, "/balance", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			if(!PlayerToPoint(20.0,playerid,2313.0049,-3.5899,26.7422))
	    {
	      SendClientMessage(playerid, COLOR_GREY, "  You are not at the Bank !");
	      return 1;
	    }
			format(string, sizeof(string), " You Have $%d in your account.",PlayerInfo[playerid][pBank]);
			SendClientMessage(playerid, COLOR_YELLOW, string);
		}
		return 1;
	}
	if(strcmp(cmd, "/transfer", true) == 0 || strcmp(cmd, "/wiretransfer", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			if(!PlayerToPoint(20.0,playerid,2313.0049,-3.5899,26.7422))
	    {
	      SendClientMessage(playerid, COLOR_GREY, "  You are not at the Bank !");
	      return 1;
	    }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /transfer [playerid/PartOfName] [amount]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /transfer [playerid/PartOfName] [amount]");
				return 1;
			}
			moneys = strval(tmp);
			if (IsPlayerConnected(giveplayerid))
			{
			  if(giveplayerid != INVALID_PLAYER_ID)
			  {
					GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					GetPlayerName(playerid, sendername, sizeof(sendername));
					playermoney = PlayerInfo[playerid][pBank] ;
					if (moneys > 0 && playermoney >= moneys)
					{
						PlayerInfo[playerid][pBank] -= moneys;
						PlayerInfo[giveplayerid][pBank] += moneys;
						format(string, sizeof(string), "  You have transferd $%d to %s's account", moneys, giveplayer,giveplayerid);
						PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
						SendClientMessage(playerid, COLOR_GRAD1, string);
						format(string, sizeof(string), "  You have recieved $%d to into your account from %s", moneys, sendername, playerid);
						SendClientMessage(giveplayerid, COLOR_GRAD1, string);
						format(string, sizeof(string), "%s transferd $%d to %s", sendername, moneys, giveplayer);
		        if(moneys >= 500000)
						{
							ABroadCast(COLOR_YELLOW,string,1);
						}
						printf("%s", string);
						PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
					}
					else
					{
						SendClientMessage(playerid, COLOR_GRAD1, "  Invalid transaction amount.");
					}
				}
			}
			else
			{
				format(string, sizeof(string), "  %d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
//==========================[Enter and Exit]==========================================================================================================
  if(strcmp(cmd, "/enter", true) == 0)
	{
			if (PlayerToPoint(3.0, playerid,1879.3861,2290.5596,10.9799))// Bank
			{
				SetPlayerInterior(playerid, 0);
	SetPlayerPos(playerid,2306.5386,-15.8507,26.7496);
	CreatePickup(1239,2,2306.5386,-15.8507,26.7496);
			}
      return 1;
	}
	if(strcmp(cmdtext, "/exit", true) == 0)
	{
	    if (PlayerToPoint(3.0, playerid,2306.5386,-15.8507,26.7496))// Bank
			{
				SetPlayerInterior(playerid, 0);
	SetPlayerPos(playerid,1879.3861,2290.5596,10.9799);
			}
      return 1;
	}
	return 0;
}

public Encrypt(string[])
{
	for(new x=0; x < strlen(string); x++)
	 {
		 string[x] += (3^x) * (x % 15);
		 if(string[x] > (0xff))
		 {
			 string[x] -= 64;
		 }
	 }
	return 1;
}


public OnPlayerLogin(playerid,const string[])
{
  new pname2[MAX_PLAYER_NAME];
	new pname3[MAX_PLAYER_NAME];
	new string2[64];
	new string3[128];
	GetPlayerName(playerid, pname2, sizeof(pname2));
	format(string2, sizeof(string2), "%s.cer", pname2);
	new File: UserFile = fopen(string2, io_read);

	if (UserFile)
	{
		new valtmp[128];
		fread(UserFile, valtmp);strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);

		if ((strcmp(PlayerInfo[playerid][pPassword], string, true, strlen(valtmp)-1) == 0))
		{
			new key[128],val[128];
 			new Data[128];
 			while(fread(UserFile,Data,sizeof(Data)))
			{
				key = ini_GetKey(Data);
        if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
        if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
        if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
        if( strcmp( key , "Bank" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pBank] = strval( val ); }
        GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
			}
			fclose(UserFile);
			gPlayerLogged[playerid] = 1;
			gPlayerAccount[playerid] = 1;
		  new kills = PlayerInfo[playerid][pKills];
      SetPlayerScore(playerid, kills);
			GetPlayerName(playerid, pname3, sizeof(pname3));
			format(string3, sizeof(string3), "Welcome %s, you have been succesfully logged in!", pname3);
			SendClientMessage(playerid, COLOR_WHITE,string3);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "	Password does not match your name");
			fclose(UserFile);
		}
	}
	return 1;
}

public OnPlayerUpdate(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		if(gPlayerLogged[playerid])
		{
			new string3[32];
			new pname3[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pname3, sizeof(pname3));
			format(string3, sizeof(string3), "%s.cer", pname3);
			new File: pFile = fopen(string3, io_write);
			if (pFile)
			{
				new var[32];
				format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(pFile, var);
				fclose(pFile);
				new File: hFile = fopen(string3, io_append);
				PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
				format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
				format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
				format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
				format(var, 32, "Bank=%d\n",PlayerInfo[playerid][pBank]);fwrite(hFile, var);
				fclose(hFile);
			}
		}
	}
	return 1;
}

stock ini_GetKey( line[] )
{
	new keyRes[128];
	keyRes[0] = 0;
  if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  return keyRes;
}

stock ini_GetValue( line[] )
{
	new valRes[128];
	valRes[0]=0;
	if ( strfind( line , "=" , true ) == -1 ) return valRes;
	strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
	return valRes;
}


strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}

public ShowStats(playerid,targetid)
{
  if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
	{
		new cash = GetPlayerMoney(targetid);
		new deaths = PlayerInfo[targetid][pDeaths];
		new kills = PlayerInfo[targetid][pKills];
		new name[MAX_PLAYER_NAME];
		GetPlayerName(targetid, name, sizeof(name));
		new Float:px,Float:py,Float:pz;
		GetPlayerPos(targetid, px, py, pz);
		new coordsstring[256];
		new bank = PlayerInfo[targetid][pBank];
		SendClientMessage(playerid, COLOR_GREEN,"________________________________________________");
		format(coordsstring, sizeof(coordsstring),"*** %s ***",name);
		SendClientMessage(playerid, COLOR_WHITE,coordsstring);
		format(coordsstring, sizeof(coordsstring), "Kills:[%d] Deaths:[%d] Cash:[$%d] Bank:[$%d]",kills,deaths,cash,bank);
		SendClientMessage(playerid, COLOR_GRAD5,coordsstring);
		SendClientMessage(playerid, COLOR_GREEN,"________________________________________________");
	}
}

public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}

public ABroadCast(color,const string[],level)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
				SendClientMessage(i, color, string);
				printf("%s", string);
		}
	}
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	if(pickupid == pickup)
	{
    SendClientMessage(playerid,0xFFFF00AA, "/bank");
    SendClientMessage(playerid,0xFFFF00AA, "/transfer");
    SendClientMessage(playerid,0xFFFF00AA, "/balance");
    SendClientMessage(playerid,0xFFFF00AA, "/withdraw");
	}
	return 1;
}



public CustomPickups()
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if (PlayerToPoint(3, i,2026.4064,1017.9352,10.8203)) // Bank
	{
  GameTextForPlayer(i, "~y~Welcome to The ~y~City Bank~n~~w~Type /enter to go in", 5000, 5);
	}
	}
	return 1;
}





#endif
Reply
#4

first don't triplepost!
and second ask here http://forum.sa-mp.com/index.php?topic=114903.0
Reply
#5

first i needed to tripl post coz it wouldent fit in 1 post

second that place dosent help peole at all so thats y im askin here
Reply
#6

Quote:
Originally Posted by sggassasin
first i needed to tripl post coz it wouldent fit in 1 post

second that place dosent help peole at all so thats y im askin here
use pastebin
Reply
#7

well but it's against the rules to post it here X_X
i told u many times now to post request stuff n shit
n did triple post only 2 posts were needed cuz post 2 and 3 were the same
Reply
#8

ok fine ill try that place and no they are not
Reply
#9

Quote:
Originally Posted by saiberfun
well but it's against the rules to post it here X_X
i told u many times now to post request stuff n shit
n did triple post only 2 posts were needed cuz post 2 and 3 were the same
he asks for help not requests a script
Reply
#10

i realy need help and it getting realy hard so like if someone could help that would be great
Reply


Forum Jump:


Users browsing this thread: 10 Guest(s)