Y_INI not loading/saving Owner Name[String]
#1

I'm working on a vehicle system. I This is how I load and save the vehicle data.

PHP код:
enum vInfo {
    
vID,
    
vModel,
    
Float:xSpawn,
    
Float:ySpawn,
    
Float:zSpawn,
    
Float:angleSpawn,
    
vCol1,
    
vCol2,
    
vPaintjob,
    
vRespawn,
    
vOwner[MAX_PLAYER_NAME],
    
vPrice,
    
bool:isOwned,
    
bool:vBuyable
}
new 
VehicleInfo[MAX_VEHICLES][vInfo];
new 
bool:vCreated[MAX_VEHICLES];
public 
LoadVehicleData(vehicleIDname[], value[]) {
    
INI_Int("model"VehicleInfo[vehicleID][vModel]);
    
INI_Float("LocX"VehicleInfo[vehicleID][xSpawn]);
    
INI_Float("LocY"VehicleInfo[vehicleID][ySpawn]);
    
INI_Float("LocZ"VehicleInfo[vehicleID][zSpawn]);
    
INI_Float("LocAngle"VehicleInfo[vehicleID][angleSpawn]);
    
INI_Int("color1"VehicleInfo[vehicleID][vCol1]);
    
INI_Int("color2"VehicleInfo[vehicleID][vCol2]);
    
INI_Int("paintjob"VehicleInfo[vehicleID][vPaintjob]);
    
INI_Int("respawn"VehicleInfo[vehicleID][vRespawn]);
    
INI_String("owner"VehicleInfo[vehicleID][vOwner], MAX_PLAYER_NAME);
    
INI_Int("price"VehicleInfo[vehicleID][vPrice]);
    
INI_Bool("owned"VehicleInfo[vehicleID][isOwned]);
    
INI_Bool("buyable"VehicleInfo[vehicleID][vBuyable]);
    return 
1;
}
stock SaveVehicle(vehicleID) {
    new 
INI:dFile INI_Open(VehiclePath(vehicleID));
    
INI_WriteInt(dFile"model"VehicleInfo[vehicleID][vModel]);
    
INI_WriteFloat(dFile"LocX"VehicleInfo[vehicleID][xSpawn]);
    
INI_WriteFloat(dFile"LocY"VehicleInfo[vehicleID][ySpawn]);
    
INI_WriteFloat(dFile"LocZ"VehicleInfo[vehicleID][zSpawn]);
    
INI_WriteFloat(dFile"LocAngle"VehicleInfo[vehicleID][angleSpawn]);
    
INI_WriteInt(dFile"color1"VehicleInfo[vehicleID][vCol1]);
    
INI_WriteInt(dFile"color2"VehicleInfo[vehicleID][vCol2]);
    
INI_WriteInt(dFile"paintjob"VehicleInfo[vehicleID][vPaintjob]);
    
INI_WriteInt(dFile"respawn"VehicleInfo[vehicleID][vRespawn]);
    
INI_WriteString(dFile"owner"VehicleInfo[vehicleID][vOwner]);
    
INI_WriteInt(dFile,"price"VehicleInfo[vehicleID][vPrice]);
    
    
INI_WriteBool(dFile"owned"VehicleInfo[vehicleID][isOwned]);
    
INI_WriteBool(dFile"buyable"VehicleInfo[vehicleID][vBuyable]);
    
    
INI_Close(dFile);
    return 
1;

Everything loads and saves fine except for the Owner's name. I try this in OnPlayerEnterVehicle

PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if(!
ispassenger) {
        new 
str[256];
        new 
vid GetVID(vehicleid);
        new 
owned[24];
        if(
VehicleInfo[vid][isOwned]) { // testing purpose
            
format(owned24"true");
        } else {
            
format(owned24"false");
        }
        
format(strsizeof(str), "Owner: %s | SID: %i |ID: %i | VModel: %i | Price: %i | Owned: %s | Color 1: %i | Color 2: %i | Paintjob: %i | Respawn: %i"VehicleInfo[vid][vOwner], vehicleidVehicleInfo[vid][vID],VehicleInfo[vid][vModel], VehicleInfo[vid][vPrice], ownedVehicleInfo[vid][vCol1], VehicleInfo[vid][vCol2], VehicleInfo[vid][vPaintjob], VehicleInfo[vid][vRespawn]);
        
        
SendClientMessage(playerid, -1str);
    }
    return 
1;

And this shows:

Any Ideas?
Reply
#2

Sometimes when i just use vehicleid, It won't properly load/save.

PHP код:
stock GetVID(vehicleID)
{
    for(new 
0MAX_VEHICLESi++) 
    {
        if((
vCreated[i]) && (VehicleInfo[i][vID] == vehicleID)) return i
    }

    return -
1;

But I don't think that's the matter. Everything else loads fine except for the name. Only the name doesn't save and load properly.

I've been trying to figure this out for days.
Reply
#3

Your screenshot shows "Owned: false". What should be the player name then?
Reply
#4

That's just for testing purpose. I just wanted to see if Everything loads/saves properly. I tried changing the values manually in the file, And every thing loads except for the Name. I've gone through the code multiple times. Yet I couldn't find anything wrong. I thought you guys would be able to help me out.
Reply
#5

BUMp
Reply
#6

B.U.M.P again.
Reply
#7

https://gist.github.com/Misiur/0fe19...34d766b0960015 - save it as a new .pwn, compile and run it. You output should be:
Quote:

[17:07:05] Hello world 666
[17:07:05] Howdy 13
[17:07:05] Hello world 666

Also, are you using YSI 3 or 4?
Reply
#8

Quote:
Originally Posted by Misiur
Посмотреть сообщение
https://gist.github.com/Misiur/0fe19...34d766b0960015 - save it as a new .pwn, compile and run it. You output should be:


Also, are you using YSI 3 or 4?
Yep, I got that output



I think I'm using YSI 4.0
Reply
#9

Alright, one last debug try:
pawn Код:
public LoadVehicleData(vehicleID, name[], value[]) {
//Add this here:
printf("Read %s: %s", name, value);
Also paste the .ini file you're trying to load
Reply
#10

So Like I said, The players name doesn't save. So when I opened the file, it was like this:

PHP код:
buyable true
owned 
false
price 
160000
owner 

respawn 90000
paintjob 
0
color2 
4
color1 
6
LocAngle 
180.386306
LocZ 
9.517271
LocY 
1291.458984
LocX 
1940.956542
model 
560 
So I changed it to this:

PHP код:
buyable true
owned 
false
price 
160000
owner 
DarkSkull
respawn 
90000
paintjob 
0
color2 
4
color1 
6
LocAngle 
180.386306
LocZ 
9.517271
LocY 
1291.458984
LocX 
1940.956542
model 
560 
And I loaded the filterscript. And it printed this:



But even thought it loaded(I guess), It didn't show the name.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)