[YINI] How would I load this...
#1

How would I load this using Y INI, its saves but Im unable to load it:
pawn Код:
for(new v = 0; v < MAX_PLAYERVEHICLES; v++) // Doesnt load
    {
        new var[1240];
        format(var, 32, "v%dPosX", v);
        INI_Float(var,PlayerVehicleInfo[playerid][v][vPosX]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vPosX] = strval(value); } // Tried to see if that would work.. But it doesnt.
        format(var, 32, "v%dPosY", v);
        INI_Float(var,PlayerVehicleInfo[playerid][v][vPosY]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vPosY] = strval(value); }
        format(var, 32, "v%dPosZ", v);
        INI_Float(var,PlayerVehicleInfo[playerid][v][vPosZ]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vPosZ] = strval(value); }
        format(var, 32, "v%dPosAngle", v);
        INI_Float(var,PlayerVehicleInfo[playerid][v][vPosAngle]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vPosAngle] = strval(value); }
        format(var, 32, "v%dModelId", v);
        INI_Int(var,PlayerVehicleInfo[playerid][v][vModelId]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vModelId] = strval(value); }
        format(var, 32, "v%dLock", v);
        INI_Int(var,PlayerVehicleInfo[playerid][v][vLock]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vLock] = strval(value); }
    }
    return 1;
}
Tried everything I could think off.
Reply
#2

pawn Код:
for(new v = 0; v < MAX_PLAYERVEHICLES; v++) // Doesnt load
MAX_PLAYERVEHICLES? Never saw it,maybe MAX_VEHICLES.
Reply
#3

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
pawn Код:
for(new v = 0; v < MAX_PLAYERVEHICLES; v++) // Doesnt load
MAX_PLAYERVEHICLES? Never saw it,maybe MAX_VEHICLES.
No offence but if you see that in somones code doesnt that call out to you, #define MAX_PLAYERVEHICLES ?? I think thats from NG-RP to be honest...

Anyhow at the OP: Why are you formatting Vars? Show us how your saving it and any errors/wanrings you get
Reply
#4

MAX_PLAYERVEHICLES is the loop for the maximum vehicles a player can own, which is currently 3, so think of it as:
pawn Код:
for(new v = 0; v < 3; v++)
It doesn't matter if someone else uses it in their script, its only to loop how many vehicles a player can have so its only going to load 3 vehicles in this case...

Anyway, I'm formatting the vars because its saves and loads like "v%dPosY" "%d" is the number of the vehicle (So it will look like this: v0PosY, v1PosY, v2PosY..) thats why I'm looping it.

The problem I'm having is its saves correctly, no errors or warnings, but doesn't load, I have no idea why. This results in the cars getting deleted due to it not loading.
Reply
#5

Its not a problem with loading, other things load, just the vehicles don't which are under the user stats that load, anyway the parse file code is OnPlayerConnect:
pawn Код:
if(fexist(UserPath(playerid)))
    {
        new string[156];
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        format(string,sizeof(string), "Welcome to Legendary Generation Roleplay, %s.\n\nIP: %s\n\nThe account you are using is registered, please enter your password to login.", GetPlayerRPName(playerid), plrIP);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{0049FF}Legendary Generation Roleplay Login", string,"Login","Quit");
    }
    else
    {
        new string[156];
        format(string,sizeof(string), "Welcome to Legendary Generation Roleplay, %s.\n\nIP:%s\n\nThe account you are using is unregistered, please enter a password to register.", GetPlayerRPName(playerid), plrIP);
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"{0049FF}Legendary Generation Roleplay Register",string,"Register","Quit");
    }
Reply
#6

All load code(Didn't think you would need it..):
pawn Код:
function LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Deposit",PlayerInfo[playerid][pDeposit]);
    INI_Int("PayDay",PlayerInfo[playerid][pPayDay]);
    INI_Int("PayCheck",PlayerInfo[playerid][pPayCheck]);
    INI_Int("ConnectTime",PlayerInfo[playerid][pConnectTime]);
    INI_Int("WRestricted",PlayerInfo[playerid][pWRestricted]);
    INI_Int("Age",PlayerInfo[playerid][pAge]);
    INI_Int("Sex",PlayerInfo[playerid][pSex]);
    INI_Int("Level",PlayerInfo[playerid][pLevel]);
    INI_Int("Number",PlayerInfo[playerid][pNumber]);
    INI_Int("SpeakerPhone",PlayerInfo[playerid][pSpeakerPhone]);
    INI_Int("PB",PlayerInfo[playerid][pPB]);
    INI_Int("PhonePrivacy",PlayerInfo[playerid][pPhonePrivacy]);
    INI_Int("JobID",PlayerInfo[playerid][pJobID]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Team",PlayerInfo[playerid][pTeam]);
    INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Helper",PlayerInfo[playerid][pHelper]);
    INI_Int("DutyHours",PlayerInfo[playerid][pDutyHours]);
    INI_Int("AcceptedHelp",PlayerInfo[playerid][pAcceptedHelp]);
    INI_Int("Spectate",PlayerInfo[playerid][pSpectate]);
    INI_Int("Banned",PlayerInfo[playerid][pBanned]);
    INI_Int("Muted",PlayerInfo[playerid][pMuted]);
    INI_Int("ReportMuted",PlayerInfo[playerid][pReportMuted]);
    INI_Int("Exp",PlayerInfo[playerid][pExp]);
    INI_Int("Vip",PlayerInfo[playerid][pVip]);
    INI_Int("VMuted",PlayerInfo[playerid][pVMuted]);
    INI_Int("Jailed",PlayerInfo[playerid][pJailed]);
    INI_Int("JailTime",PlayerInfo[playerid][pJailTime]);
    INI_String("PrisonReason",PlayerInfo[playerid][pPrisonReason], 128);
    INI_String("Prisonedby",PlayerInfo[playerid][pPrisonedby], 32);
    INI_Int("ToggedVIPChat",PlayerInfo[playerid][pToggedVIPChat]);
    INI_Int("Warns",PlayerInfo[playerid][pWarns]);
    INI_Int("GangWarn",PlayerInfo[playerid][pGangWarn]);
    INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_Float("Pos_a",PlayerInfo[playerid][pPos_a]);
    INI_Float("Health",PlayerInfo[playerid][pHealth]);
    INI_Float("Armor",PlayerInfo[playerid][pArmor]);
    INI_Int("Materials",PlayerInfo[playerid][pMaterials]);
    INI_Int("Cocaine",PlayerInfo[playerid][pCocaine]);
    INI_Int("Packages",PlayerInfo[playerid][pPackages]);
    INI_Int("INT",PlayerInfo[playerid][pINT]);
    INI_Int("VW",PlayerInfo[playerid][pVW]);
    INI_Int("Dice",PlayerInfo[playerid][pDice]);
    INI_Int("Weapon1",PlayerInfo[playerid][pWeapon][1]);
    INI_Int("Weapon1a",PlayerInfo[playerid][pWeapona][1]);
    INI_Int("Weapon2",PlayerInfo[playerid][pWeapon][2]);
    INI_Int("Weapon2a",PlayerInfo[playerid][pWeapona][2]);
    INI_Int("Weapon3",PlayerInfo[playerid][pWeapon][3]);
    INI_Int("Weapon3a",PlayerInfo[playerid][pWeapona][3]);
    INI_Int("Weapon4",PlayerInfo[playerid][pWeapon][4]);
    INI_Int("Weapon4a",PlayerInfo[playerid][pWeapona][4]);
    INI_Int("Weapon5",PlayerInfo[playerid][pWeapon][5]);
    INI_Int("Weapon5a",PlayerInfo[playerid][pWeapona][5]);
    INI_Int("Weapon6",PlayerInfo[playerid][pWeapon][6]);
    INI_Int("Weapon6a",PlayerInfo[playerid][pWeapona][6]);
    INI_Int("Weapon7",PlayerInfo[playerid][pWeapon][7]);
    INI_Int("Weapon7a",PlayerInfo[playerid][pWeapona][7]);
    INI_Int("Weapon8",PlayerInfo[playerid][pWeapon][8]);
    INI_Int("Weapon8a",PlayerInfo[playerid][pWeapona][8]);
    INI_Int("Weapon9",PlayerInfo[playerid][pWeapon][9]);
    INI_Int("Weapon9a",PlayerInfo[playerid][pWeapona][9]);
    INI_Int("Weapon10",PlayerInfo[playerid][pWeapon][10]);
    INI_Int("Weapon10a",PlayerInfo[playerid][pWeapona][10]);
    INI_Int("Weapon11",PlayerInfo[playerid][pWeapon][11]);
    INI_Int("Weapon11a",PlayerInfo[playerid][pWeapona][11]);
    INI_String("KillLog0",PlayerInfo[playerid][pKillLog0], 256);
    INI_String("KillLog1",PlayerInfo[playerid][pKillLog1], 256);
    INI_String("KillLog2",PlayerInfo[playerid][pKillLog2], 256);
    INI_String("KillLog3",PlayerInfo[playerid][pKillLog3], 256);
    INI_String("KillLog4",PlayerInfo[playerid][pKillLog4], 256);
    INI_String("KillLog5",PlayerInfo[playerid][pKillLog5], 256);
    INI_String("KillLog6",PlayerInfo[playerid][pKillLog6], 256);
    INI_String("KillLog7",PlayerInfo[playerid][pKillLog7], 256);
    INI_String("KillLog8",PlayerInfo[playerid][pKillLog8], 256);
    INI_String("KillLog9",PlayerInfo[playerid][pKillLog9], 256);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Faction",PlayerInfo[playerid][pFaction]);
    INI_Int("FMember",PlayerInfo[playerid][pFMember]);
    INI_Int("Rank",PlayerInfo[playerid][pRank]);
    INI_Int("Leader",PlayerInfo[playerid][pLeader]);
    INI_Int("Married",PlayerInfo[playerid][pMarried]);
    INI_String("MarriedTo",PlayerInfo[playerid][pMarriedTo], 128);
    INI_Int("Duty",PlayerInfo[playerid][pDuty]);
    INI_Int("JobDuty",PlayerInfo[playerid][pJobDuty]);
    INI_Int("Crimes",PlayerInfo[playerid][pCrimes]);
    INI_Int("WantedLevel",PlayerInfo[playerid][pWantedLevel]);
    INI_Int("Radio",PlayerInfo[playerid][pRadio]);
    INI_Int("RadioFreq",PlayerInfo[playerid][pRadioFreq]);
    INI_Int("Spam",PlayerInfo[playerid][pSpam]);
    INI_Int("Dashboard",PlayerInfo[playerid][pDashboard]);
    INI_Int("RobHouse",PlayerInfo[playerid][pRobHouse]);
    INI_Int("HSpawn",PlayerInfo[playerid][pHSpawn]);
    INI_Float("HSpawnX",PlayerInfo[playerid][pHSpawnX]);
    INI_Float("HSpawnY",PlayerInfo[playerid][pHSpawnY]);
    INI_Float("HSpawnZ",PlayerInfo[playerid][pHSpawnZ]);
    INI_Int("HSpawnInt",PlayerInfo[playerid][pHSpawnInt]);
    INI_Int("HSpawnVW",PlayerInfo[playerid][pHSpawnVW]);
    INI_Int("RequestingBackup",PlayerInfo[playerid][pRequestingBackup]);
    INI_Int("AttendingBackupCall",PlayerInfo[playerid][pAttendingBackupCall]);
    INI_Int("Bugged",PlayerInfo[playerid][pBugged]);
    INI_Int("HeadValue",PlayerInfo[playerid][pHeadValue]);
    INI_String("ContractBy",PlayerInfo[playerid][pContractBy], 32);
    INI_String("ContractDetail",PlayerInfo[playerid][pContractDetail], 64);
    INI_Int("C4Used",PlayerInfo[playerid][pC4Used]);
    INI_Int("C4",PlayerInfo[playerid][pC4]);
    INI_Int("Bombs",PlayerInfo[playerid][pBombs]);
    INI_Int("CHits",PlayerInfo[playerid][pCHits]);
    INI_Int("FHits",PlayerInfo[playerid][pFHits]);
    INI_Int("AcceptReport",PlayerInfo[playerid][pAcceptReport]);
    INI_Int("TrashReport",PlayerInfo[playerid][pTrashReport]);
    INI_Int("Spraycan",PlayerInfo[playerid][pSpraycan]);
    INI_Int("Boombox",PlayerInfo[playerid][pBoombox]);
    INI_Int("Lock",PlayerInfo[playerid][pLock]);
    INI_Int("LockCar",PlayerInfo[playerid][pLockCar]);
    INI_Int("Sprunk",PlayerInfo[playerid][pSprunk]);
    INI_Int("Cigar",PlayerInfo[playerid][pCigar]);
    INI_Int("Insurance",PlayerInfo[playerid][pInsurance]);
    INI_Int("NMute",PlayerInfo[playerid][pNMute]);
    INI_Int("NMuteTotal",PlayerInfo[playerid][pNMuteTotal]);
    INI_Int("ADMute",PlayerInfo[playerid][pADMute]);
    INI_Int("ADMuteTotal",PlayerInfo[playerid][pADMuteTotal]);
    INI_String("Tempname",PlayerInfo[playerid][pTempname], 64);
    INI_String("Flag",PlayerInfo[playerid][pFlag], 128);
    INI_String("IP",PlayerInfo[playerid][pIP], 32);

    for(new v = 0; v < MAX_PLAYERVEHICLES; v++) // Doesnt load
    {
        new var[1240];
        format(var, 32, "v%dPosX", v);
        INI_Float(var,PlayerVehicleInfo[playerid][v][vPosX]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vPosX] = strval(value); } // Tried to see if that would work.. But it doesnt.
        format(var, 32, "v%dPosY", v);
        INI_Float(var,PlayerVehicleInfo[playerid][v][vPosY]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vPosY] = strval(value); }
        format(var, 32, "v%dPosZ", v);
        INI_Float(var,PlayerVehicleInfo[playerid][v][vPosZ]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vPosZ] = strval(value); }
        format(var, 32, "v%dPosAngle", v);
        INI_Float(var,PlayerVehicleInfo[playerid][v][vPosAngle]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vPosAngle] = strval(value); }
        format(var, 32, "v%dModelId", v);
        INI_Int(var,PlayerVehicleInfo[playerid][v][vModelId]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vModelId] = strval(value); }
        format(var, 32, "v%dLock", v);
        INI_Int(var,PlayerVehicleInfo[playerid][v][vLock]);
        if(!strcmp(name, var)) { PlayerVehicleInfo[playerid][v][vLock] = strval(value); }
    }
    return 1;
}
Also what do you mean by where do I set the tags? I only use:
pawn Код:
INI_SetTag(File,"vehicles");
On the saving function.. Does that mean I need it for loading as well?
Reply
#7

So how do I read the tag?

EDIT: Doesn't matter, found out (me being stupid)..

Thanks for your help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)