System Car Personal
#1

looks .. the car don't save after server restart !!! why lookk

pawn Код:
//===========================Section: Includes==================================
#include <a_samp>
#include <utils>
//===========================Section: Definations===============================
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD6 0xF0F0F0FF
#define COLOR_GREEN 0x33AA33AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_YELLOW2 0xF5DEB3AA
#define COLOR_BLUE 0x2641FEAA
#define COLOR_RED 0xAA3333AA
#define COLOR_PURPLE 0xC2A2DAAA

#pragma tabsize 0
//===========================Section: Forwards==================================
forward LoadCar();
forward SaveCarCoords();
forward OnPropUpdate();
forward IsAnOwnableCar(vehicleid);
forward CarKeys(playerid);
forward SavePlayerData(playerid);
forward ini_GetKey( line[] );
forward ini_GetValue( line[] );
forward OnPlayerKeyStateChange(playerid, newkeys, oldkeys);

new carsonserver = 293;


new vehName[][] = {
    "Landstalker",
    "Bravura",
    "Buffalo",
    "Linerunner",
    "Perrenial",
    "Sentinel",
    "Dumper",
    "Firetruck",
    "Trashmaster",
    "Stretch",
    "Manana",
    "Infernus",
    "Voodoo",
    "Pony",
    "Mule",
    "Cheetah",
    "Ambulance",
    "Leviathan",
    "Moonbeam",
    "Esperanto",
    "Taxi",
    "Washington",
    "Bobcat",
    "Whoopee",
    "BF Injection",
    "Hunter",
    "Premier",
    "Enforcer",
    "Securicar",
    "Banshee",
    "Predator",
    "Bus",
    "Rhino",
    "Barracks",
    "Hotknife",
    "Trailer",
    "Previon",
    "Coach",
    "Cabbie",
    "Stallion",
    "Rumpo",
    "RC Bandit",
    "Romero",
    "Packer",
    "Monster",
    "Admiral",
    "Squalo",
    "Seasparrow",
    "Pizzaboy",
    "Tram",
    "Trailer",
    "Turismo",
    "Speeder",
    "Reefer",
    "Tropic",
    "Flatbed",
    "Yankee",
    "Caddy",
    "Solair",
    "Berkley's RC Van",
    "Skimmer",
    "PCJ-600",
    "Faggio",
    "Freeway",
    "RC Baron",
    "RC Raider",
    "Glendale",
    "Oceanic",
    "Sanchez",
    "Sparrow",
    "Patriot",
    "ATV",
    "Coastguard",
    "Dinghy",
    "Hermes",
    "Sabre",
    "Rustler",
    "ZR-350",
    "Walton",
    "Regina",
    "Comet",
    "BMX",
    "Burrito",
    "Camper",
    "Marquis",
    "Baggage",
    "Dozer",
    "Maverick",
    "News Chopper",
    "Rancher",
    "FBI Rancher",
    "Virgo",
    "Greenwood",
    "Jetmax",
    "Hotring",
    "Sandking",
    "Blista Compact",
    "Police Maverick",
    "Boxvillde",
    "Benson",
    "Mesa",
    "RC Goblin",
    "Hotring Racer A",
    "Hotring Racer B",
    "Bloodring Banger",
    "Rancher",
    "Super GT",
    "Elegant",
    "Journey",
    "Bike",
    "Mountain Bike",
    "Beagle",
    "Cropduster",
    "Stunt",
    "Tanker",
    "Roadtrain",
    "Nebula",
    "Majestic",
    "Buccaneer",
    "Shamal",
    "Hydra",
    "FCR-900",
    "NRG-500",
    "HPV1000",
    "Cement Truck",
    "Tow Truck",
    "Fortune",
    "Cadrona",
    "FBI Truck",
    "Willard",
    "Forklift",
    "Tractor",
    "Combine",
    "Feltzer",
    "Remington",
    "Slamvan",
    "Blade",
    "Freight",
    "Streak",
    "Vortex",
    "Vincent",
    "Bullet",
    "Clover",
    "Sadler",
    "Firetruck",
    "Hustler",
    "Intruder",
    "Primo",
    "Cargobob",
    "Tampa",
    "Sunrise",
    "Merit",
    "Utility",
    "Nevada",
    "Jeep",
    "Windsor",
    "Monster",
    "Monster",
    "Uranus",
    "Jester",
    "Sultan",
    "Stratum",
    "Elegy",
    "Raindance",
    "RC Tiger",
    "Flash",
    "Tahoma",
    "Savanna",
    "Bandito",
    "Freight Flat",
    "Streak Carriage",
    "Kart",
    "Mower",
    "Dune",
    "Sweeper",
    "Broadway",
    "Tornado",
    "AT-400",
    "DFT-30",
    "Huntley",
    "Stafford",
    "BF-400",
    "News Van",
    "Tug",
    "Trailer",
    "Emperor",
    "Wayfarer",
    "Euros",
    "Hotdog",
    "Club",
    "Freight Box",
    "Trailer",
    "Andromada",
    "Dodo",
    "RC Cam",
    "Launch",
    "Police Car LSPD",
    "Police Car SFPD",
    "Police Car LVPD",
    "Police Ranger",
    "Picador",
    "S.W.A.T",
    "Alpha",
    "Phoenix",
    "Glendale",
    "Sadler",
    "Luggage",
    "Luggage",
    "Stairs",
    "Boxville",
    "Tiller",
    "Utility Trailer"
};
//===========================Section: Variables=================================

enum pInfo
{
    pPcarkey,
    pPcarkey2,
    pPcarkey3,
}
new PlayerInfo[256][pInfo];

enum cInfo
{
    cModel,
    Float:cLocationx,
    Float:cLocationy,
    Float:cLocationz,
    Float:cAngle,
    cColorOne,
    cColorTwo,
    cOwner[MAX_PLAYER_NAME],
    cDescription[12],
    cRegistration,
    cOwned,
    cLock,
    paintjob,
};

new CarInfo[1000][cInfo];

//===========================Section: strtok ============================
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;
}

//===========================Section: Callbacks & Functions=====================
public OnFilterScriptInit()
{
    printf("Filterscript carownership.amx Initiated\n");
    LoadCar();

    for(new h = carsonserver; h < sizeof(CarInfo); h++)
    {
        AddStaticVehicleEx(CarInfo[h][cModel],CarInfo[h][cLocationx],CarInfo[h][cLocationy],CarInfo[h][cLocationz]+1.0,CarInfo[h][cAngle],CarInfo[h][cColorOne],CarInfo[h][cColorTwo],60000);
    }
    return 1;
}

public OnFilterScriptExit() { return 1; }

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new carid = GetPlayerVehicleID(playerid);
    if ((newkeys & KEY_SECONDARY_ATTACK))
    {
        if(IsAnOwnableCar(carid) && CarInfo[carid][cOwned] == 0)
        {
            TogglePlayerControllable(playerid, 1);
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}

public SavePlayerData(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new string3[32];
        new playername3[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername3, sizeof(playername3));
        format(string3, sizeof(string3), "carkeys/%s.ini", playername3);
        new File: hFile = fopen(string3, io_write);
        if (hFile)
        {
            new var[32];
            format(var, 32, "CarKey=%d\n",PlayerInfo[playerid][pPcarkey]);fwrite(hFile, var);
            format(var, 32, "CarKey2=%d\n",PlayerInfo[playerid][pPcarkey2]);fwrite(hFile, var);
            format(var, 32, "CarKey3=%d\n",PlayerInfo[playerid][pPcarkey3]);fwrite(hFile, var);
            fclose(hFile);
        }
    }
    return 1;
}


public CarKeys(playerid)
{
    new string2[64];
    new playername2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername2, sizeof(playername2));
    format(string2, sizeof(string2), "carkeys/%s.ini", playername2);
    new File: UserFile = fopen(string2, io_read);
    if ( UserFile )
    {
        new key[ 256 ] , val[ 256 ];
        new Data[ 256 ];
        while ( fread( UserFile , Data , sizeof( Data ) ) )
        {
            key = ini_GetKey( Data );
            if( strcmp( key , "CarKey" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPcarkey] = strval( val ); }
            if( strcmp( key , "CarKey2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPcarkey2] = strval( val ); }
            if( strcmp( key , "CarKey3" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pPcarkey3] = strval( val ); }
        }
        fclose(UserFile);
        SendClientMessage(playerid, COLOR_RED,"Car Keys Loaded by Team BestLife!!!");
    }
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    if(IsPlayerInVehicle(playerid, vehicleid))
    {
        if(GetVehicleModel(vehicleid) == 483)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
            }
        }
        if(GetVehicleModel(vehicleid) == 534)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 535)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 536)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 558)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 559)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 560)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 561)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 562)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 565)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 567)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
        if(GetVehicleModel(vehicleid) == 575)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
            }
        }
        if(GetVehicleModel(vehicleid) == 576)
        {
            switch(paintjobid)
            {
                case 0: CarInfo[vehicleid][paintjob] = 0;
                case 1: CarInfo[vehicleid][paintjob] = 1;
                case 2: CarInfo[vehicleid][paintjob] = 2;
            }
        }
    }
    return 1;
}

public OnPropUpdate()
{
    new idx;
    new File: file2;
    idx = carsonserver;
    while (idx < sizeof(CarInfo))
    {
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d\n",
        CarInfo[idx][cModel],
        CarInfo[idx][cLocationx],
        CarInfo[idx][cLocationy],
        CarInfo[idx][cLocationz],
        CarInfo[idx][cAngle],
        CarInfo[idx][cColorOne],
        CarInfo[idx][cColorTwo],
        CarInfo[idx][cOwner],
        CarInfo[idx][cDescription],
        CarInfo[idx][cOwned],
        CarInfo[idx][cLock],
        CarInfo[idx][paintjob]);
        if(idx == carsonserver)
        {
            file2 = fopen("masini.cfg", io_write);
        }
        else
        {
            file2 = fopen("masini.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}

public IsAnOwnableCar(vehicleid)
{
    if(vehicleid >= carsonserver && vehicleid <= 1000) { return 1; }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsAnOwnableCar(vehicleid) && CarInfo[vehicleid][cLock] == 1 && CarInfo[vehicleid][cOwned] == 1)
    {
        if(IsPlayerAdmin(playerid)) { }
        else
        {
            new Float:cx, Float:cy, Float:cz;
            GetPlayerPos(playerid, cx, cy, cz);
            SetPlayerPos(playerid, cx, cy, cz);
        }
    }
    return 1;
}
public OnPlayerSpawn(playerid)
{
    CarKeys(playerid);
    return 1;
}

public OnPlayerConnect(playerid)
{
    for(new h = carsonserver; h < sizeof(CarInfo); h++)
    {
        SetVehicleParamsForPlayer(h,playerid,0,CarInfo[h][cLock]);
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new idx;
    new string[256];
    new cmd[256];
    new tmp[256];
    new sendername[MAX_PLAYER_NAME];
    new playername[MAX_PLAYER_NAME];
    new giveplayerid;
    new idcar = GetPlayerVehicleID(playerid);
    cmd = strtok(cmdtext, idx);
    new vehid;
    vehid = GetPlayerVehicleID(playerid);

    if (strcmp(cmd, "/mycars", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new carkey = PlayerInfo[playerid][pPcarkey];
            new carkey2 = PlayerInfo[playerid][pPcarkey2];
            new carkey3 = PlayerInfo[playerid][pPcarkey3];
            if (PlayerInfo[playerid][pPcarkey] != -1)
            {
                format(string, sizeof(string), "1| VehModel:[%s] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey][cDescription], CarInfo[carkey][cColorOne], CarInfo[carkey][cColorTwo], CarInfo[carkey][cLock]);
                SendClientMessage(playerid, COLOR_GRAD5,string);
            }
            if (PlayerInfo[playerid][pPcarkey2] != -1)
            {
                format(string, sizeof(string), "2| VehModel:[%s] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey2][cDescription], CarInfo[carkey2][cColorOne], CarInfo[carkey2][cColorTwo], CarInfo[carkey2][cLock]);
                SendClientMessage(playerid, COLOR_GRAD5,string);
            }
            if (PlayerInfo[playerid][pPcarkey3] != -1)
            {
                format(string, sizeof(string), "3| VehModel:[%s] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey3][cDescription], CarInfo[carkey3][cColorOne], CarInfo[carkey3][cColorTwo], CarInfo[carkey3][cLock]);
                SendClientMessage(playerid, COLOR_GRAD5,string);
            }
        }
        return 1;
    }

    if(strcmp(cmd, "/apark", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new Float:x,Float:y,Float:z;
            new Float:a;
            new carid;
            carid = GetPlayerVehicleID(playerid);
            GetPlayerName(playerid, playername, sizeof(playername));
            GetVehiclePos(carid, x, y, z);
            GetVehicleZAngle(carid, a);
            if(IsPlayerAdmin(playerid))
            {
                CarInfo[carid][cLocationx] = x;
                CarInfo[carid][cLocationy] = y;
                CarInfo[carid][cLocationz] = z;
                CarInfo[carid][cAngle] = a;
                format(string, sizeof(string), "~n~ You have parked your car in this location. ~n~");
                GameTextForPlayer(playerid, "You have parked this car in this position. It will respawn here.", 10000, 3);
                OnPropUpdate(); SavePlayerData(playerid);
                DestroyVehicle(carid);
                CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_BLUE, "Nu esti autorizat sa folosesti aceasta comanda!!!");
                return 1;
            }
        }
        return 1;
    }

    if(strcmp(cmd, "/adeletecar", true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            CarInfo[idcar][cOwned] = 0; CarInfo[idcar][cModel] = 0; CarInfo[idcar][cColorOne] = 0; CarInfo[idcar][cColorTwo] = 0;
            CarInfo[idcar][cLocationx] = 0; CarInfo[idcar][cLocationy] = 0; CarInfo[idcar][cLocationz] = 0; CarInfo[idcar][cAngle] = 0;
            CarInfo[idcar][cLock] = 0; CarInfo[idcar][paintjob] = -1;
            strmid(CarInfo[idcar][cOwner], "Dealership", 0, strlen("Dealership"), 999);
            format(CarInfo[idcar][cDescription], 32, "0");
            DestroyVehicle(idcar);
            OnPropUpdate(); SavePlayerData(playerid);
        }
    }
    if(strcmp(cmd, "/acarkeys", true) == 0)
    {
        if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
        {
            SendClientMessage(playerid, COLOR_GREY, "Nu Esti Owneru Acestei Masini");
            return 1;
        }
        else
        {
           CarKeys(playerid);
        }
    }

    if(strcmp(cmd, "/acreateveh", true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "FOLOSESTE: /acreateveh [carid] [color1] [color2]");
                return 1;
            }
            new car;
            car = strval(tmp);
            if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_WHITE, " Id vehiculului nu poate sa fie mai mic de 400 si mai mare de 611 !"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "FOLOSESTE: /acreateveh [carid] [color1] [color2]");
                return 1;
            }
            new color1;
            color1 = strval(tmp);
            if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Id culori este de la 0 la 126 !"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "FOLOSESTE: /acreateveh [carid] [color1] [color2]");
                return 1;
            }
            new color2;
            color2 = strval(tmp);
            if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Id culori este de la 0 la 126 !"); return 1; }
            new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z);
            new thiscar = CreateVehicle(car,X,Y,Z,1,color1,color2,99999999);
            CarInfo[thiscar][cOwned] = 0; CarInfo[thiscar][cModel] = car; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2;
            CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1;
            CarInfo[thiscar][cLock] = 0; CarInfo[thiscar][paintjob] = -1;
            PutPlayerInVehicle(playerid,thiscar,0);
            strmid(CarInfo[vehid][cOwner], "Dealership", 0, strlen("Dealership"), 999);
            format(CarInfo[thiscar][cDescription], 32, "%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
            format(string, sizeof(string), " Masina %d a fost creata cu succes!.", thiscar);
            SendClientMessage(playerid, COLOR_BLUE, string);
        }
        else
        {
            SendClientMessage(playerid, COLOR_GRAD1, " Nu esti autorizat sa folosesti aceasta comanda!!!");
            return 1;
        }
    }
    if(strcmp(cmd, "/asetkey", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD1, "FOLOSESTE: /asetkey [playerid/PartOfName] [carkey] [amount]");
                SendClientMessage(playerid, COLOR_GRAD4, "|1 CarKey |2 CarKey2 |3 CarKey3");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerAdmin(playerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "FOLOSESTE: /asetkey [playerid/PartOfName] [carkey] [amount]");
                        SendClientMessage(playerid, COLOR_GRAD4, "|1 CarKey |2 CarKey2 |3 CarKey3");
                        return 1;
                    }
                    new stat;
                    stat = strval(tmp);
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "FOLOSESTE: /asetkey [playerid/PartOfName] [carkey] [amount]");
                        SendClientMessage(playerid, COLOR_GRAD4, "|1 CarKey |2 CarKey2 |3 CarKey3");
                        return 1;
                    }
                    new amount;
                    amount = strval(tmp);
                    switch (stat)
                    {
                        case 1:
                        {
                                PlayerInfo[giveplayerid][pPcarkey] = amount;
                                format(string, sizeof(string), "   The Player Car Key Was Set To %d", amount);
                                SavePlayerData(playerid);
                        }
                        case 2:
                        {
                                PlayerInfo[giveplayerid][pPcarkey2] = amount;
                                format(string, sizeof(string), "   The Player Car Key 2 Was Set To %d", amount);
                                SavePlayerData(playerid);
                        }
                        case 3:
                        {
                                PlayerInfo[giveplayerid][pPcarkey3] = amount;
                                format(string, sizeof(string), "   The Player Car Key 3 Was Set To %d", amount);
                                SavePlayerData(playerid);
                        }
                        default:
                        {
                                format(string, sizeof(string), "   Codul Cheii Nu Este Valid", amount);
                        }
                    }
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   Doar adminii pot folosi aceasta comanda!");
                return 1;
            }
        }
        return 1;
    }
    if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new x_nr[64];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_RED, "HINT: (/v)ehicle [name]");
                SendClientMessage(playerid, COLOR_RED, "Available names: park, lock(1-3), color, locate(1-3), tow(1-3)");
                SendClientMessage(playerid, COLOR_BLUE, "Available commands:/mycars Comenzi Admin->(/acreatecar,/adeletecar,/apark,/asetkey,/asellcar,/acarkeys)");
                return 1;
            }
            if(strcmp(x_nr,"buy",true) == 0)
            {
                if(IsAnOwnableCar(idcar))
                {
                    if(PlayerInfo[playerid][pPcarkey] == 0) { }
                    else if(PlayerInfo[playerid][pPcarkey2] == 0) { }
                    else if(PlayerInfo[playerid][pPcarkey3] == 0) { }
                    else { SendClientMessage(playerid, COLOR_BLUE, "   Ai deja 3 masini!!"); return 1; }
                    if(CarInfo[idcar][cOwned]==1)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "Aceata Masina Este Deja Cumparata");
                        return 1;
                    }
                    if(GetPlayerMoney(playerid))
                    {
                        if(PlayerInfo[playerid][pPcarkey] == 0) { PlayerInfo[playerid][pPcarkey] = idcar; }
                        else if(PlayerInfo[playerid][pPcarkey2] == 0) { PlayerInfo[playerid][pPcarkey2] = idcar; }
                        else if(PlayerInfo[playerid][pPcarkey3] == 0) { PlayerInfo[playerid][pPcarkey3] = idcar; }
                        else { return 1; }
                        CarInfo[idcar][cOwned] = 1;
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                        GameTextForPlayer(playerid, "Bravo,ti-ai cumparat o masina NOUA , foloseste /v", 5000, 3);
                        TogglePlayerControllable(playerid, 1);
                        OnPropUpdate(); SavePlayerData(playerid);
                        return 1;
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, " Nu ai bani pentru a cumpara o masina ! ");
                        return 1;
                    }
                }
            }
            else if(strcmp(x_nr,"park",true) == 0)
            {
                new Float:x,Float:y,Float:z;
                new Float:a;
                new carid;
                new getcarid;
                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { carid = PlayerInfo[playerid][pPcarkey3]; }
                else { return 1; }
                getcarid = GetPlayerVehicleID(playerid);
                GetPlayerName(playerid, playername, sizeof(playername));
                GetVehiclePos(carid, x, y, z);
                GetVehicleZAngle(carid, a);
                if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
                {
                    if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "Tu Nu Esti Owneru Acestei Masini.");
                        return 1;
                    }
                    if(getcarid == carid)
                    {
                        new Float:CarHP, Float:OldCarHP; new panels,doors,lights,tires;
                        CarInfo[carid][cLocationx] = x;
                        CarInfo[carid][cLocationy] = y;
                        CarInfo[carid][cLocationz] = z;
                        CarInfo[carid][cAngle] = a;
                        GetVehicleDamageStatus(carid,panels,doors,lights,tires);
                        GetVehicleHealth(carid, CarHP); OldCarHP = CarHP;
                        format(string, sizeof(string), " You have parked your vehicle in this location.");
                        GameTextForPlayer(playerid, "You have parked your vehicle in this position. It will respawn here.", 10000, 3);
                        OnPropUpdate(); SavePlayerData(playerid);  DestroyVehicle(carid);
                        CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
                        PutPlayerInVehicle(playerid,carid,0); SetVehicleHealth(carid, OldCarHP);
                        UpdateVehicleDamageStatus(carid,panels,doors,lights,tires);
                        TogglePlayerControllable(playerid, 1);
                        return 1;
                    }
                }
            }

            else if(strcmp(x_nr,"lock1",true) == 0)
            {
                new keycar = PlayerInfo[playerid][pPcarkey];
                if(keycar != -1)
                {
                    new locked[256];
                    locked = strtok(cmdtext, idx);
                    if(CarInfo[keycar][cLock] == 1)
                    {
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if (IsPlayerConnected(i))
                            {
                                SetVehicleParamsForPlayer(keycar,i,0,0);
                            }
                        }
                        format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
                        GameTextForPlayer(playerid, string, 4000, 3);
                        CarInfo[keycar][cLock] = 0;
                        OnPropUpdate(); SavePlayerData(playerid);
                        return 1;
                    }
                    else if(CarInfo[keycar][cLock] == 0)
                    {
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if (IsPlayerConnected(i))
                            {
                                SetVehicleParamsForPlayer(keycar,i,0,1);
                            }
                        }
                        format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
                        GameTextForPlayer(playerid, string, 4000, 3);
                        CarInfo[keycar][cLock] = 1;
                        OnPropUpdate(); SavePlayerData(playerid);
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "  Nu Ai Nici O Masina La Slot 1");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"lock2",true) == 0)
            {
                new keycar = PlayerInfo[playerid][pPcarkey2];
                if(keycar != -1)
                {
                    new locked[256];
                    locked = strtok(cmdtext, idx);
                    if(CarInfo[keycar][cLock] == 1)
                    {
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if (IsPlayerConnected(i))
                            {
                                SetVehicleParamsForPlayer(keycar,i,0,0);
                            }
                        }
                        format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
                        GameTextForPlayer(playerid, string, 4000, 3);
                        CarInfo[keycar][cLock] = 0;
                        OnPropUpdate(); SavePlayerData(playerid);
                        return 1;
                    }
                    else if(CarInfo[keycar][cLock] == 0)
                    {
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if (IsPlayerConnected(i))
                            {
                                SetVehicleParamsForPlayer(keycar,i,0,1);
                            }
                        }
                        format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
                        GameTextForPlayer(playerid, string, 4000, 3);
                        CarInfo[keycar][cLock] = 1;
                        OnPropUpdate(); SavePlayerData(playerid);
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "  Nu Ai Nici O Masina La Slot 2");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"lock3",true) == 0)
            {
                new keycar = PlayerInfo[playerid][pPcarkey3];
                if(keycar != -1)
                {
                    new locked[256];
                    locked = strtok(cmdtext, idx);
                    if(CarInfo[keycar][cLock] == 1)
                    {
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if (IsPlayerConnected(i))
                            {
                                SetVehicleParamsForPlayer(keycar,i,0,0);
                            }
                        }
                        format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
                        GameTextForPlayer(playerid, string, 4000, 3);
                        CarInfo[keycar][cLock] = 0;
                        OnPropUpdate(); SavePlayerData(playerid);
                        return 1;
                    }
                    else if(CarInfo[keycar][cLock] == 0)
                    {
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if (IsPlayerConnected(i))
                            {
                                SetVehicleParamsForPlayer(keycar,i,0,1);
                            }
                        }
                        format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
                        GameTextForPlayer(playerid, string, 4000, 3);
                        CarInfo[keycar][cLock] = 1;
                        OnPropUpdate(); SavePlayerData(playerid);
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "  Nu Ai Nici O Masina La Slot 3");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"color",true) == 0)
            {
                if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
                {
                    SendClientMessage(playerid, COLOR_GREY,"   Nu ai o masina pentru a o picta .");
                    return 1;
                }
                if(GetPlayerMoney(playerid) < 1000)
                {
                    SendClientMessage(playerid, COLOR_GREY,"   Nu ai bani pentru a picta masina.");
                    return 1;
                }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "FOLOSESTE: /v color [ColorOneID] [ColorTwoID]");
                    return 1;
                }
                new color1;
                color1 = strval(tmp);
                if(color1 < 0 && color1 > 126)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   Wrong color id!");
                    return 1;
                }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "FOLOSESTE: /v color [ColorOneID] [ColorTwoID]");
                    return 1;
                }
                new color2;
                color2 = strval(tmp);
                if(color2 < 0 && color2 > 126)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   Wrong color id!");
                    return 1;
                }

                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { vehid = PlayerInfo[playerid][pPcarkey]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { vehid = PlayerInfo[playerid][pPcarkey2]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { vehid = PlayerInfo[playerid][pPcarkey3]; }
                else { return 1; }

                if(IsPlayerInVehicle(playerid, vehid))
                {
                    CarInfo[vehid][cColorOne] = color1;
                    CarInfo[vehid][cColorTwo] = color2;
                    GivePlayerMoney(playerid, -1000);
                    GameTextForPlayer(playerid, "~w~Bill for a Paint Respray~n~~r~-$1000", 5000, 1);
                    ChangeVehicleColor(vehid, color1, color2);
                    OnPropUpdate(); SavePlayerData(playerid);
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY,"   Nu te afli in masina personala.");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"locate1",true) == 0)
            {
                if(!IsPlayerConnected(playerid)) { return 1; }
                new Float:x,Float:y,Float:z;
                new car = PlayerInfo[playerid][pPcarkey];
                if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
                SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
                GetVehiclePos(car, x, y, z);
                SetPlayerCheckpoint(playerid, x, y, z, 6);
                return 1;
            }
            else if(strcmp(x_nr,"locate2",true) == 0)
            {
                if(!IsPlayerConnected(playerid)) { return 1; }
                new Float:x,Float:y,Float:z;
                new car = PlayerInfo[playerid][pPcarkey2];
                if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
                SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
                GetVehiclePos(car, x, y, z);
                SetPlayerCheckpoint(playerid, x, y, z, 6);
                return 1;
            }
            else if(strcmp(x_nr,"locate3",true) == 0)
            {
                if(!IsPlayerConnected(playerid)) { return 1; }
                new Float:x,Float:y,Float:z;
                new car = PlayerInfo[playerid][pPcarkey3];
                if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
                SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
                GetVehiclePos(car, x, y, z);
                SetPlayerCheckpoint(playerid, x, y, z, 6);
                return 1;
            }
            else if(strcmp(x_nr,"tow1",true) == 0)
            {
               if(IsPlayerConnected(playerid))
                {
                    new car = PlayerInfo[playerid][pPcarkey];
                    GetPlayerName(playerid, playername, sizeof(playername));
                    if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
                    {
                        GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
                        GivePlayerMoney(playerid,-1500);
                        SetVehicleToRespawn(car);
                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                    }
                    else
                    {
                        GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
                    }
                }
            }
            else if(strcmp(x_nr,"tow2",true) == 0)
            {
               if(IsPlayerConnected(playerid))
                {
                    new car = PlayerInfo[playerid][pPcarkey2];
                    GetPlayerName(playerid, playername, sizeof(playername));
                    if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
                    {
                        GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
                        GivePlayerMoney(playerid,-1500);
                        SetVehicleToRespawn(car);
                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                    }
                    else
                    {
                        GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
                    }
                }
            }
            else if(strcmp(x_nr,"tow3",true) == 0)
            {
               if(IsPlayerConnected(playerid))
                {
                    new car = PlayerInfo[playerid][pPcarkey3];
                    GetPlayerName(playerid, playername, sizeof(playername));
                    if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey3]][cOwner], true) == 0)
                    {
                        GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
                        GivePlayerMoney(playerid,-1500);
                        SetVehicleToRespawn(car);
                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                    }
                    else
                    {
                        GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: park, lock(1-3), color, locate(1-3), tow(1-3)");
                return 1;
            }
        }
        return 1;
    }
    return 0;
}

public OnPlayerEnterCheckpoint(playerid)
{
    DisablePlayerCheckpoint(playerid);
    return 1;
}
/*----------Car Save Functions----------*/
public SaveCarCoords()
{
    new idx;
    new File: file2 = fopen("cars.cfg", io_write);
    while (idx < sizeof(CarInfo))
    {
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%d\n",
        CarInfo[idx][cModel],
        CarInfo[idx][cLocationx],
        CarInfo[idx][cLocationy],
        CarInfo[idx][cLocationz],
        CarInfo[idx][cAngle],
        CarInfo[idx][cColorOne],
        CarInfo[idx][cColorTwo],
        CarInfo[idx][paintjob]);
        if(idx == carsonserver)
        {
            file2 = fopen("cars.cfg", io_write);
        }
        else
        {
            file2 = fopen("cars.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}

public LoadCar()
{
    new arrCoords[31][64];
    new strFromFile2[256];
    new File: file = fopen("cars.cfg", io_read);
    if (file)
    {
        new idx = carsonserver;
        while (idx < sizeof(CarInfo))
        {
            fread(file, strFromFile2);
            CarInfo[idx][cModel] = strval(arrCoords[0]);
            CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
            CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
            CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
            CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
            CarInfo[idx][cColorOne] = strval(arrCoords[5]);
            CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
            strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            CarInfo[idx][cOwned] = strval(arrCoords[11]);
            CarInfo[idx][cLock] = strval(arrCoords[12]);
            CarInfo[idx][paintjob] = strval(arrCoords[30]);
            idx++;
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new string[128];
    new vehicle = GetPlayerVehicleID(playerid);
    new newcar = GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(IsAnOwnableCar(newcar))
        {
            if(CarInfo[newcar][cOwned]==0)
            {
                TogglePlayerControllable(playerid, 0);
                format(string,sizeof(string),"%s %d /v buy pentru a cumpara masina",CarInfo[newcar][cDescription]);
                SendClientMessage(playerid, COLOR_BLUE, string);
                SendClientMessage(playerid, COLOR_BLUE, "sau apasa enter pentru a iesi din masina");
            }
            if(CarInfo[newcar][cOwned]==1)
            {
                format(string,sizeof(string),"Vehiculul tau %s",CarInfo[newcar][cOwner]);
                SendClientMessage(playerid, COLOR_BLUE, string);
                if(PlayerInfo[playerid][pPcarkey] == vehicle) { }
                else if(PlayerInfo[playerid][pPcarkey2] == vehicle) { }
                else if(PlayerInfo[playerid][pPcarkey3] == vehicle) { }
                else
                {
                    if(IsPlayerAdmin(playerid))
                    {
                        SendClientMessage(playerid, COLOR_GREY, "Poti conduce Aceasta masina pentru ca esti admin!");
                    }
                    else
                    {
                        RemovePlayerFromVehicle(playerid);
                        SendClientMessage(playerid, COLOR_GREY, "Tu nu esti %s");
                    }
                }
            }
        }
    }
    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;
}
Reply
#2

HELP?
Reply
#3

UPPPPPPPP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)