Saving And Loading
#1

So, When i make a business it saves in the script files like this
PHP код:
[Data]
bOwned 0
bPrice 
1000000
bOwner 

bType 1
bLocked 
0
bMoney 
0
bEntranceX 
2026.305908
bEntranceY 
1343.175903
bEntranceZ 
10.820312
bEntranceA 
271.030029
bExitX 
286.148986
bExitY 
= -40.644397
bExitZ 
1001.515625
bExitA 
0.000000
bInt 
0
bWorld 
0
bInsideInt 
1
bInsideWorld 
2
bInsideIcon 
402
bOutSideIcon 
401
bName 
=  
And when i create another one it remove this info and the file change its data

Soi can't save more than one file because it rmove the info of the olf one and replave in with the other.
Please Help !
Reply
#2

When using ini-files, you have 2 options:
- either use different keys when you want to store them all in one file (like your [Data] key), as ini-processors use those to differentiate between 2 or more copies of the same structure in one file
- either use different files (for each business, use Business%i.ini, where %i is your BusinessID)
Reply
#3

Ok, I know but i am not good in ini so how to make a specific file fo each business ?
Reply
#4

Bump !
Reply
#5

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
- either use different files (for each business, use Business%i.ini, where %i is your BusinessID)
He just told you^^, read before you post.
Reply
#6

Ok, now it save a file for each business but it load only one
Any help ?!
Reply
#7

Show the code of the loop (that "stock LoadBiz" function)
Reply
#8

PHP код:
public loadbiz_data(idxname[], value[])
{
    
INI_Int("bOwned",BusinessInfo[idx][bOwned]);
    
INI_String("bOwner",BusinessInfo[idx][bOwner],24);
    
INI_Int("bPrice",BusinessInfo[idx][bPrice]);
    
INI_Int("bType",BusinessInfo[idx][bType]);
    
INI_Int("bLocked",BusinessInfo[idx][bLocked]);
    
INI_Int("bMoney",BusinessInfo[idx][bMoney]);
    
INI_Float("bEntranceX",BusinessInfo[idx][bEntranceX]);
    
INI_Float("bEntranceY",BusinessInfo[idx][bEntranceY]);
    
INI_Float("bEntranceZ",BusinessInfo[idx][bEntranceZ]);
    
INI_Float("bEntranceA",BusinessInfo[idx][bEntranceA]);
    
INI_Float("bExitX",BusinessInfo[idx][bExitX]);
    
INI_Float("bExitY",BusinessInfo[idx][bExitY]);
    
INI_Float("bExitZ",BusinessInfo[idx][bExitZ]);
    
INI_Float("bExitA",BusinessInfo[idx][bExitA]);
    
INI_Int("bInt",BusinessInfo[idx][bInt]);
    
INI_Int("bWorld",BusinessInfo[idx][bWorld]);
    
INI_Int("bInsideInt",BusinessInfo[idx][bInsideInt]);
    
INI_Int("bInsideInt",BusinessInfo[idx][bInsideInt]);
    
INI_Int("bInsideWorld",BusinessInfo[idx][bInsideWorld]);
    
INI_Int("bInsideIcon",BusinessInfo[idx][bInsideIcon]);
    
INI_Int("bOutSideIcon",BusinessInfo[idx][bOutSideIcon]);
    
INI_String("bName",BusinessInfo[idx][bName],128);
    return 
1;

Reply
#9

No idea if you are calling that function under a loop or what but easy way to do so is just making a stock function like this.

Код:
stock loadbiz_data()
{
    OPEN THE INI FILE HERE (i've no idea how you use this include)
    for(new idx=1; idx<THE MAX BIZ AMOUNT; idx++)
    {
    INI_Int("bOwned",BusinessInfo[idx][bOwned]); 
    INI_String("bOwner",BusinessInfo[idx][bOwner],24); 
    INI_Int("bPrice",BusinessInfo[idx][bPrice]); 
    INI_Int("bType",BusinessInfo[idx][bType]); 
    INI_Int("bLocked",BusinessInfo[idx][bLocked]); 
    INI_Int("bMoney",BusinessInfo[idx][bMoney]); 
    INI_Float("bEntranceX",BusinessInfo[idx][bEntranceX]); 
    INI_Float("bEntranceY",BusinessInfo[idx][bEntranceY]); 
    INI_Float("bEntranceZ",BusinessInfo[idx][bEntranceZ]); 
    INI_Float("bEntranceA",BusinessInfo[idx][bEntranceA]); 
    INI_Float("bExitX",BusinessInfo[idx][bExitX]); 
    INI_Float("bExitY",BusinessInfo[idx][bExitY]); 
    INI_Float("bExitZ",BusinessInfo[idx][bExitZ]); 
    INI_Float("bExitA",BusinessInfo[idx][bExitA]); 
    INI_Int("bInt",BusinessInfo[idx][bInt]); 
    INI_Int("bWorld",BusinessInfo[idx][bWorld]); 
    INI_Int("bInsideInt",BusinessInfo[idx][bInsideInt]); 
    INI_Int("bInsideInt",BusinessInfo[idx][bInsideInt]); 
    INI_Int("bInsideWorld",BusinessInfo[idx][bInsideWorld]); 
    INI_Int("bInsideIcon",BusinessInfo[idx][bInsideIcon]); 
    INI_Int("bOutSideIcon",BusinessInfo[idx][bOutSideIcon]); 
    INI_String("bName",BusinessInfo[idx][bName],128);
    }
    CLOSE THE INI FILE HERE.
}
And then putting loadbiz_data() under GameModeInit()

P.S: It's best to use the SAMP binary file read/write instead of these includes.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)