Player name is not saving properly + vehiclehealth
#1

Hello, i'm using dini 1.6
and im working for a vehicle system for my script..
so i want to save the playername into a file and get the vehiclehealth and write it down to the file too..

but..

thats what happening:

when saving playername the playername is turning to be "14" wth?.... (numbers and not letters)
then.. when saving vehiclehealth it's turning to be from "650" to "1" (always.. no matter what number you save..)

pawn Код:
public ChangeCarOwner(vehicleid,owner)
{
    new string[128];
    format(string,sizeof(string),"vehicle/%i.ini",CarSystem[vehicleid][cFileID]);
    if(dini_Exists(string))
    {
        CarSystem[CarSystem[vehicleid][cFileID]][cVehicleOwner] = owner;
        SaveCarVehicle(vehicleid);
    }
    return true;
}

pawn Код:
public ChangeCarHealth(vehicleid,health)
{
    new string[128];
    format(string,sizeof(string),"vehicle/%i.ini",CarSystem[vehicleid][cFileID]);
    if(dini_Exists(string))
    {
        CarSystem[CarSystem[vehicleid][cFileID]][cVehicleHealth] = health;
        SaveCarVehicle(vehicleid);
        SetVehicleToRespawn(vehicleid);
    }
    return true;
}

>>>>> Public CarVehicleLoad <<<<
pawn Код:
CarSystem[vehicleid][cVehicleOwner] = dini_Int(string, "VehicleOwner");
pawn Код:
CarSystem[vehicleid][cVehicleHealth] = dini_Int(string, "VehicleHealth");
and on >>>> Public SaveCarVehicle <<<<
pawn Код:
dini_IntSet(string, "VehicleOwner", CarSystem[vehicleid][cVehicleOwner]);
pawn Код:
dini_IntSet(string, "VehicleHealth", CarSystem[vehicleid][cVehicleHealth]);

thank you...
Reply
#2

If I can see everything correctly, you need to save the player's name as a string, not an integer (%s, not %i). Make sure CarSystem[vehicleid][cVehicleOwner] is a string. Setting a string, you would use dini_Set, not dini_IntSet (and dini_Get to get the string value).

Just to clarify, each vehicle has a file, titled with the vehicleID?
Reply
#3

"Just to clarify, each vehicle has a file, titled with the vehicleID? " yes.


and do i need to change something here?:

pawn Код:
public ChangeCarOwner(vehicleid,owner)
{
    new string[128];
    format(string,sizeof(string),"vehicle/%i.ini",CarSystem[vehicleid][cFileID]);
    if(dini_Exists(string))
    {
        CarSystem[CarSystem[vehicleid][cFileID]][cVehicleOwner] = owner;
        SaveCarVehicle(vehicleid);
    }
    return true;
}
thank you.
Reply
#4

someone? please..?
Reply
#5

Add another slash '/' before vehicle in the format line.

If you'd put that together with the complete directory address, it would look like this:

Win7: "C:\address_to_wherever_your_samp-server.exe_is_locatedvehicle\carsystemstring.ini"

But if you add / (which turns into \) it would be correct, like so: "C:\address_to_wherever_your_samp-server.exe_is_located\vehicle\carsystemstring.ini"
Reply
#6

pawn Код:
dini_IntSet(string, "VehicleOwner", CarSystem[vehicleid][cVehicleOwner]);
CarSystem[vehicleid][cVehicleOwner] = dini_Int(string, "VehicleOwner");
Maybe because you're using dini_IntSet rather than dini_Set?

EDIT:

Vehicle health is a float, use dini_FloatSet / dini_Float
Reply
#7

waa......
i'm getting so much errors.. i've been trying to change all the intset to set (where needed)
and still...
maybe you can check my script?...

ERRORS:
pawn Код:
D:\SERVER\gamemodes\gf.pwn(43218) : error 035: argument type mismatch (argument 3)
D:\SERVER\gamemodes\gf.pwn(43637) : warning 202: number of arguments does not match definition
D:\SERVER\gamemodes\gf.pwn(43643) : warning 213: tag mismatch
D:\SERVER\gamemodes\gf.pwn(43707) : warning 202: number of arguments does not match definition
D:\SERVER\gamemodes\gf.pwn(43713) : warning 213: tag mismatch
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
pawn Код:
public LoadCarSystem()
{
    new string[128];
    for(new i = 1; i < MAX_DVEHICLES; i++)
    {
        format(string,sizeof(string),"Vehicles/%i.ini",i);
        if(dini_Exists(string))
        {
            CarSystem[i][cModel] = dini_Int(string, "Model");
            CarSystem[i][cX] = dini_Float(string, "X");
            CarSystem[i][cY] = dini_Float(string, "Y");
            CarSystem[i][cZ] = dini_Float(string, "Z");
            CarSystem[i][cAngle] = dini_Float(string, "Angle");
            CarSystem[i][cColor1] = dini_Int(string, "Color1");
            CarSystem[i][cColor2] = dini_Int(string, "Color2");
            CarSystem[i][cDelay] = dini_Int(string, "Delay");
            CarSystem[i][cObjective] = dini_Int(string, "Objective");
            CarSystem[i][cDoorsLocked] = dini_Int(string, "DoorsLocked");
            [b]CarSystem[i][cVehicleOwner] = dini_Set(string, "VehicleOwner");[/b]
            CarSystem[i][cVehicleMaterials] = dini_Int(string, "VehicleMaterials");
            CarSystem[i][cVehicleCrack] = dini_Int(string, "VehicleCrack");
            CarSystem[i][cVehiclePot] = dini_Int(string, "VehiclePot");
            CarSystem[i][cLoad] = dini_Int(string, "VehicleLoad");
            CarSystem[i][cCapasity] = dini_Int(string, "VehicleCapasity");
            [b]CarSystem[i][cVehicleHealth] = dini_Float(string, "VehicleHealth");[/b]
            CarSystem[i][cVehicleAlarm] = dini_Int(string, "VehicleAlarm");
            CarSystem[i][cVehicleOwned] = dini_Int(string, "VehicleOwned");
            CarSystem[i][cNitro] = dini_Int(string, "Nitro");
            CarSystem[i][cPaintJob] = dini_Int(string, "PaintJob");
            CarSystem[i][cHydro] = dini_Int(string, "Hydro");
            CarSystem[i][cPimped] = dini_Int(string, "Pimped");
            CarSystem[i][cPerma] = dini_Int(string, "Perma");
            CarSystem[i][cRank] = dini_Int(string, "Rank");
            CarSystem[i][cPrice] = dini_Int(string, "Price");
            CarSystem[i][cFileID] = i;
            CarSystem[i][cVehicleID] = AddStaticVehicleEx(CarSystem[i][cModel],CarSystem[i][cX],CarSystem[i][cY],CarSystem[i][cZ],CarSystem[i][cAngle],CarSystem[i][cColor1],CarSystem[i][cColor2], CarSystem[i][cDelay]);
            SetVehicleHealth(CarSystem[i][cVehicleID],CarSystem[i][cVehicleHealth]);
            //ChangeVehicleColor(CarSystem[i][cVehicleID], CarSystem[i][cColor1], CarSystem[i][cColor2]);
            //ChangeVehiclePaintjob(CarSystem[i][cVehicleID], CarSystem[i][cPaintJob]);
            CarCount ++;
            if(CarSystem[i][cPimped] == 1)
            {
                if(CarSystem[i][cModel] == 560)
                {
                    AddVehicleComponent(i, 1026);
                    AddVehicleComponent(i, 1027);
                    AddVehicleComponent(i, 1028);
                    AddVehicleComponent(i, 1026);
                    AddVehicleComponent(i, 1032);
                    AddVehicleComponent(i, 1041);
                }
                if(CarSystem[i][cModel] == 562)
                {
                    AddVehicleComponent(i, 1034);
                    AddVehicleComponent(i, 1036);
                    AddVehicleComponent(i, 1038);
                    AddVehicleComponent(i, 1040);
                }
            }
            if(CarSystem[i][cNitro] == 1)
            {
                AddVehicleComponent(i, 1010);
            }
            if(CarSystem[i][cHydro] == 1)
            {
                AddVehicleComponent(i, 1087);
            }
        }
    }
    return true;
}

public LoadCarVehicle(vehicleid)
{
    new string[128];
    format(string,sizeof(string),"Vehicles/%i.ini",vehicleid);
    if(dini_Exists(string))
    {
        CarSystem[vehicleid][cModel] = dini_Int(string, "Model");
        CarSystem[vehicleid][cX] = dini_Float(string, "X");
        CarSystem[vehicleid][cY] = dini_Float(string, "Y");
        CarSystem[vehicleid][cZ] = dini_Float(string, "Z");
        CarSystem[vehicleid][cAngle] = dini_Float(string, "Angle");
        CarSystem[vehicleid][cColor1] = dini_Int(string, "Color1");
        CarSystem[vehicleid][cColor2] = dini_Int(string, "Color2");
        CarSystem[vehicleid][cDelay] = dini_Int(string, "Delay");
        CarSystem[vehicleid][cObjective] = dini_Int(string, "Objective");
        CarSystem[vehicleid][cDoorsLocked] = dini_Int(string, "DoorsLocked");
        [b]CarSystem[vehicleid][cVehicleOwner] = dini_Set(string, "VehicleOwner");[/b]
        CarSystem[vehicleid][cVehicleMaterials] = dini_Int(string, "VehicleMaterials");
        CarSystem[vehicleid][cVehicleCrack] = dini_Int(string, "VehicleCrack");
        CarSystem[vehicleid][cVehiclePot] = dini_Int(string, "VehiclePot");
        CarSystem[vehicleid][cLoad] = dini_Int(string, "VehicleLoad");
        CarSystem[vehicleid][cCapasity] = dini_Int(string, "VehicleCapasity");
        [b]CarSystem[vehicleid][cVehicleHealth] = dini_Float(string, "VehicleHealth");[/b]
        CarSystem[vehicleid][cVehicleAlarm] = dini_Int(string, "VehicleAlarm");
        CarSystem[vehicleid][cVehicleOwned] = dini_Int(string, "VehicleOwned");
        CarSystem[vehicleid][cNitro] = dini_Int(string, "Nitro");
        CarSystem[vehicleid][cPaintJob] = dini_Int(string, "PaintJob");
        CarSystem[vehicleid][cHydro] = dini_Int(string, "Hydro");
        CarSystem[vehicleid][cPimped] = dini_Int(string, "Pimped");
        CarSystem[vehicleid][cPerma] = dini_Int(string, "Perma");
        CarSystem[vehicleid][cRank] = dini_Int(string, "Rank");
        CarSystem[vehicleid][cPrice] = dini_Int(string, "Price");
        CarSystem[vehicleid][cFileID] = vehicleid;
        CarSystem[vehicleid][cVehicleID] = AddStaticVehicleEx(CarSystem[vehicleid][cModel],CarSystem[vehicleid][cX],CarSystem[vehicleid][cY],CarSystem[vehicleid][cZ],CarSystem[vehicleid][cAngle],CarSystem[vehicleid][cColor1],CarSystem[vehicleid][cColor2], CarSystem[vehicleid][cDelay]);
        SetVehicleHealth(CarSystem[vehicleid][cVehicleID],CarSystem[vehicleid][cVehicleHealth]);
        //ChangeVehicleColor(CarSystem[vehicleid][cVehicleID], CarSystem[vehicleid][cColor1], CarSystem[vehicleid][cColor2]);
        //ChangeVehiclePaintjob(CarSystem[vehicleid][cVehicleID], CarSystem[vehicleid][cPaintJob]);
        if(CarSystem[vehicleid][cPimped] == 1)
        {
            if(CarSystem[vehicleid][cModel] == 560)
            {
                AddVehicleComponent(vehicleid, 1026);
                AddVehicleComponent(vehicleid, 1027);
                AddVehicleComponent(vehicleid, 1028);
                AddVehicleComponent(vehicleid, 1026);
                AddVehicleComponent(vehicleid, 1032);
                AddVehicleComponent(vehicleid, 1041);
            }
            if(CarSystem[vehicleid][cModel] == 562)
            {
                AddVehicleComponent(vehicleid, 1034);
                AddVehicleComponent(vehicleid, 1036);
                AddVehicleComponent(vehicleid, 1038);
                AddVehicleComponent(vehicleid, 1040);
            }
        }
        if(CarSystem[vehicleid][cNitro] == 1)
        {
            AddVehicleComponent(vehicleid, 1010);
        }
        if(CarSystem[vehicleid][cHydro] == 1)
        {
            AddVehicleComponent(vehicleid, 1087);
        }
    }
    return true;
}

public SaveCarSystem()
{
    new string[128];
    for(new i = 1; i < MAX_DVEHICLES; i++)
    {
        format(string,sizeof(string),"Vehicles/%i.ini",i);
        if(dini_Exists(string))
        {
            dini_IntSet(string, "Model", CarSystem[i][cModel]);
            dini_FloatSet(string, "X", CarSystem[i][cX]);
            dini_FloatSet(string, "Y", CarSystem[i][cY]);
            dini_FloatSet(string, "Z", CarSystem[i][cZ]);
            dini_FloatSet(string, "Angle", CarSystem[i][cAngle]);
            dini_IntSet(string, "Color1", CarSystem[i][cColor1]);
            dini_IntSet(string, "Color2", CarSystem[i][cColor2]);
            dini_IntSet(string, "Delay", CarSystem[i][cDelay]);
            dini_IntSet(string, "Objective", CarSystem[i][cObjective]);
            dini_IntSet(string, "DoorsLocked", CarSystem[i][cDoorsLocked]);
            dini_Set(string, "VehicleOwner", CarSystem[i][cVehicleOwner]);
            dini_IntSet(string, "VehicleMaterials", CarSystem[i][cVehicleMaterials]);
            dini_IntSet(string, "VehicleCrack", CarSystem[i][cVehicleCrack]);
            dini_IntSet(string, "VehiclePot", CarSystem[i][cVehiclePot]);
            dini_IntSet(string, "VehicleLoad", CarSystem[i][cLoad]);
            dini_IntSet(string, "VehicleCapasity", CarSystem[i][cCapasity]);
            dini_FloatSet(string, "VehicleHealth", CarSystem[i][cVehicleHealth]);
            dini_IntSet(string, "VehicleAlarm", CarSystem[i][cVehicleAlarm]);
            dini_IntSet(string, "VehicleOwned", CarSystem[i][cVehicleOwned]);
            dini_IntSet(string, "Nitro", CarSystem[i][cNitro]);
            dini_IntSet(string, "PaintJob", CarSystem[i][cPaintJob]);
            dini_IntSet(string, "Hydro", CarSystem[i][cHydro]);
            dini_IntSet(string, "Pimped", CarSystem[i][cPimped]);
            dini_IntSet(string, "Perma", CarSystem[i][cPerma]);
            dini_IntSet(string, "Rank", CarSystem[i][cRank]);
            dini_IntSet(string, "Price", CarSystem[i][cPrice]);
        }
    }
    return true;
}

public SaveCarVehicle(vehicleid)
{
    new string[128];
    format(string,sizeof(string),"Vehicles/%i.ini",vehicleid);
    if(dini_Exists(string))
    {
        dini_IntSet(string, "Model", CarSystem[vehicleid][cModel]);
        dini_FloatSet(string, "X", CarSystem[vehicleid][cX]);
        dini_FloatSet(string, "Y", CarSystem[vehicleid][cY]);
        dini_FloatSet(string, "Z", CarSystem[vehicleid][cZ]);
        dini_FloatSet(string, "Angle", CarSystem[vehicleid][cAngle]);
        dini_IntSet(string, "Color1", CarSystem[vehicleid][cColor1]);
        dini_IntSet(string, "Color2", CarSystem[vehicleid][cColor2]);
        dini_IntSet(string, "Delay", CarSystem[vehicleid][cDelay]);
        dini_IntSet(string, "Objective", CarSystem[vehicleid][cObjective]);
        dini_IntSet(string, "DoorsLocked", CarSystem[vehicleid][cDoorsLocked]);
        dini_Set(string, "VehicleOwner", CarSystem[vehicleid][cVehicleOwner]);
        dini_IntSet(string, "VehicleMaterials", CarSystem[vehicleid][cVehicleMaterials]);
        dini_IntSet(string, "VehicleCrack", CarSystem[vehicleid][cVehicleCrack]);
        dini_IntSet(string, "VehiclePot", CarSystem[vehicleid][cVehiclePot]);
        dini_IntSet(string, "VehicleLoad", CarSystem[vehicleid][cLoad]);
        dini_IntSet(string, "VehicleCapasity", CarSystem[vehicleid][cCapasity]);
        dini_FloatSet(string, "VehicleHealth", CarSystem[vehicleid][cVehicleHealth]);
        dini_IntSet(string, "VehicleAlarm", CarSystem[vehicleid][cVehicleAlarm]);
        dini_IntSet(string, "VehicleOwned", CarSystem[vehicleid][cVehicleOwned]);
        dini_IntSet(string, "Nitro", CarSystem[vehicleid][cNitro]);
        dini_IntSet(string, "PaintJob", CarSystem[vehicleid][cPaintJob]);
        dini_IntSet(string, "Hydro", CarSystem[vehicleid][cHydro]);
        dini_IntSet(string, "Pimped", CarSystem[vehicleid][cPimped]);
        dini_IntSet(string, "Perma", CarSystem[vehicleid][cPerma]);
        dini_IntSet(string, "Rank", CarSystem[vehicleid][cRank]);
        dini_IntSet(string, "Price", CarSystem[vehicleid][cPrice]);
    }
    return 1;
}

pawn Код:
public ChangeCarOwner(vehicleid,owner)
{
    new string[128];
    format(string,sizeof(string),"Vehicles/%i.ini",CarSystem[vehicleid][cFileID]);
    if(dini_Exists(string))
    {
        CarSystem[CarSystem[vehicleid][cFileID]][cVehicleOwner] = owner;
        SaveCarVehicle(vehicleid);
    }
    return true;
}
pawn Код:
public ChangeCarHealth(vehicleid,health)
{
    new string[128];
    format(string,sizeof(string),"Vehicles/%i.ini",CarSystem[vehicleid][cFileID]);
    if(dini_Exists(string))
    {
        CarSystem[CarSystem[vehicleid][cFileID]][cVehicleHealth] = health;
        SaveCarVehicle(vehicleid);
    }
    return true;
}
pawn Код:
public AddCar(carmodel,Float:x,Float:y,Float:z,Float:angle,color1,color2,delay,objective,doorslocked,vehicleowner,materials,crack,pot,load,capasity,health,alarm,owned,nitro,paintjob,hydro,pimped,perma,rank,price)
{
    new FoundID = 0;
    new ID;
    new string[256];
    if(carmodel > 399 && carmodel < 612)
    {
        for ( new i = 1; FoundID <= 0 ; i++)
        {
            format(string,sizeof(string),"Vehicles/%i.ini",i);
            if(!dini_Exists(string))
            {
                ID = i;
                FoundID = 1;
            }
            if( i > MAX_DVEHICLES )
            {
                return true;
            }
        }
        format(string,sizeof(string),"Vehicles/%i.ini",ID);
        dini_Create(string);
        dini_IntSet(string, "Model", carmodel);
        dini_FloatSet(string, "X", x);
        dini_FloatSet(string, "Y", y);
        dini_FloatSet(string, "Z", z);
        dini_FloatSet(string, "Angle", angle);
        dini_IntSet(string, "Color1", color1);
        dini_IntSet(string, "Color2", color2);
        dini_IntSet(string, "Delay", delay);
        dini_IntSet(string, "Objective", objective);
        dini_IntSet(string, "DoorsLocked", doorslocked);
        [b]dini_Set(string, "VehicleOwner", vehicleowner);[/b]
        dini_IntSet(string, "VehicleMaterials", materials);
        dini_IntSet(string, "VehicleCrack", crack);
        dini_IntSet(string, "VehiclePot", pot);
        dini_IntSet(string, "VehicleLoad", load);
        dini_IntSet(string, "VehicleCapasity", capasity);
        dini_FloatSet(string, "VehicleHealth", health);
        dini_IntSet(string, "VehicleAlarm", alarm);
        dini_IntSet(string, "VehicleOwned", owned);
        dini_IntSet(string, "Nitro", nitro);
        dini_IntSet(string, "PaintJob", paintjob);
        dini_IntSet(string, "Hydro", hydro);
        dini_IntSet(string, "Pimped", pimped);
        dini_IntSet(string, "Perma", perma);
        dini_IntSet(string, "Rank", rank);
        CarSystem[ID][cModel] = dini_Int(string, "model");
        CarSystem[ID][cX] = x;
        CarSystem[ID][cY] = y;
        CarSystem[ID][cZ] = z;
        CarSystem[ID][cAngle] = angle;
        CarSystem[ID][cColor1] = color1;
        CarSystem[ID][cColor2] = color2;
        CarSystem[ID][cDelay] = delay;
        CarSystem[ID][cObjective] = objective;
        CarSystem[ID][cDoorsLocked] = doorslocked;
        CarSystem[ID][cVehicleOwner] = vehicleowner;
        CarSystem[ID][cVehicleMaterials] = materials;
        CarSystem[ID][cVehicleCrack] = crack;
        CarSystem[ID][cVehiclePot] = pot;
        CarSystem[ID][cLoad] = load;
        CarSystem[ID][cCapasity] = capasity;
        CarSystem[ID][cVehicleHealth] = health;
        CarSystem[ID][cVehicleAlarm] = alarm;
        CarSystem[ID][cVehicleOwned] = owned;
        CarSystem[ID][cNitro] = nitro;
        CarSystem[ID][cPaintJob] = paintjob;
        CarSystem[ID][cHydro] = hydro;
        CarSystem[ID][cPimped] = pimped;
        CarSystem[ID][cPerma] = perma;
        CarSystem[ID][cRank] = rank;
        CarSystem[ID][cPrice] = price;
        CarSystem[ID][cFileID] = ID;
        CarSystem[ID][cVehicleID] = AddStaticVehicleEx(CarSystem[ID][cModel],CarSystem[ID][cX],CarSystem[ID][cY],CarSystem[ID][cZ],CarSystem[ID][cAngle],CarSystem[ID][cColor1],CarSystem[ID][cColor2], CarSystem[ID][cDelay]);
        CarCount ++;
    }
    else
    {//Invalid Model
        return true;
    }
    return ID;

}
thank you..., and sorry for the bother..
Reply
#8

Can you mark the line numbers that have the errors?
Reply
#9

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
Can you mark the line numbers that have the errors?
EDITED: the error lines ware marked as [b] thank you for your help..
Reply
#10

Somethings:

When you load the cars, to get a string its dini_Get, not dini_Set like you have for CarSystem[vehicleid][cVehicleOwner] when you load items.

Also, I don't know if you did this or not, but you need to change the health to a Float value and the owner to a string in your enum. Like:
pawn Код:
enum Car Info //or whatever
{
     Float:cVehicleHealth;
     cVehicleOwner[MAX_PLAYER_NAME]; // 24 by default I believe, if that's easier
}
Try those and repost errors and update the pasted code with the new lines and we'll see.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)