[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


Messages In This Thread
[help] - by sggassasin - 07.08.2009, 15:55
Re: [help] - by sggassasin - 07.08.2009, 15:55
Re: [help] - by sggassasin - 07.08.2009, 15:56
Re: [help] - by saiberfun - 07.08.2009, 15:57
Re: [help] - by sggassasin - 07.08.2009, 15:59
Re: [help] - by MPKaboose - 07.08.2009, 15:59
Re: [help] - by saiberfun - 07.08.2009, 16:00
Re: [help] - by sggassasin - 07.08.2009, 16:01
Re: [help] - by MPKaboose - 07.08.2009, 16:11
Re: [help] - by sggassasin - 08.08.2009, 02:35

Forum Jump:


Users browsing this thread: 7 Guest(s)