SA-MP Forums Archive
Y_INI not loading/saving Owner Name[String] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Y_INI not loading/saving Owner Name[String] (/showthread.php?tid=611908)



Y_INI not loading/saving Owner Name[String] - DarkSkull - 12.07.2016

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(vehicleID, name[], 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(playerid, vehicleid, ispassenger)
{
    if(!
ispassenger) {
        new 
str[256];
        new 
vid = GetVID(vehicleid);
        new 
owned[24];
        if(
VehicleInfo[vid][isOwned]) { // testing purpose
            
format(owned, 24, "true");
        } else {
            
format(owned, 24, "false");
        }
        
format(str, sizeof(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], vehicleid, VehicleInfo[vid][vID],VehicleInfo[vid][vModel], VehicleInfo[vid][vPrice], owned, VehicleInfo[vid][vCol1], VehicleInfo[vid][vCol2], VehicleInfo[vid][vPaintjob], VehicleInfo[vid][vRespawn]);
        
        
SendClientMessage(playerid, -1, str);
    }
    return 
1;
} 
And this shows:

Any Ideas?


Re: Y_INI not loading/saving Owner Name[String] - DarkSkull - 12.07.2016

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

PHP код:
stock GetVID(vehicleID)
{
    for(new 
i = 0; i < MAX_VEHICLES; i++) 
    {
        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.


Re: Y_INI not loading/saving Owner Name[String] - Misiur - 12.07.2016

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


Re: Y_INI not loading/saving Owner Name[String] - DarkSkull - 12.07.2016

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.


Re: Y_INI not loading/saving Owner Name[String] - DarkSkull - 13.07.2016

BUMp


Re: Y_INI not loading/saving Owner Name[String] - DarkSkull - 14.07.2016

B.U.M.P again.


Re: Y_INI not loading/saving Owner Name[String] - Misiur - 14.07.2016

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?


Re: Y_INI not loading/saving Owner Name[String] - DarkSkull - 16.07.2016

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


Re: Y_INI not loading/saving Owner Name[String] - Misiur - 16.07.2016

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


Re: Y_INI not loading/saving Owner Name[String] - DarkSkull - 16.07.2016

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.