SA-MP Forums Archive
Businesses - 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: Businesses (/showthread.php?tid=573428)



Businesses - NoDi522 - 07.05.2015

Hey guys. I made similar thread 2-3 weeks ago and nobody give a reply. I can't find it to do some 'bump' so I made this "similar" post again.

My problem is saving businesses.

Here is my enum:

PHP код:
enum bInfo
{
    
Name[128],
    
Owner[MAX_PLAYER_NAME],
    
FloatPozicija[3],
    
FloatInterijer[10],
    
Zakljucan,
    
Cijena,
    
PickupID,
    
Text3DLabelID
};
new 
BiznisInfo[MAX_BIZNISA][bInfo]; 
@OnPlayerDisconnect (saving problem):

PHP код:
    // Informacije - Spremanje BIZNIS podataka
    
new INI:bFile INI_Open(BiznisPath(playerid));
    
INI_SetTag(bFile,"data");
    for(new 
0!= MAX_BIZNISAi++)
    
INI_WriteString(bFile,"Ime",BiznisInfo[i][Name]);
    
INI_WriteString(bFile,"Owner",BiznisInfo[i][Owner]);
    
INI_WriteInt(bFile,"Pozicija",BiznisInfo[i][Pozicija]);
    
INI_WriteInt(bFile,"Interijer",BiznisInfo[i][Interijer]);
    
INI_WriteString(bFile,"Zakljucan",BiznisInfo[i][Zakljucan]);
     
INI_WriteInt(bFile,"Cijena",BiznisInfo[i][Cijena]);
     
INI_WriteInt(bFile,"PickupID",BiznisInfo[i][PickupID]);
     
INI_WriteInt(bFile,"LabelID",BiznisInfo[i][LabelID]); 
@Errors:

PHP код:
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1694) : error 017undefined symbol "i"
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1695) : error 017undefined symbol "i"
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1696) : error 017undefined symbol "i"
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1697) : error 017undefined symbol "i"
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1698) : error 017undefined symbol "i"
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1699) : error 017undefined symbol "i"
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1700) : error 017undefined symbol "i" 
++ Here is my @LoadBusinesses stock. If you could take a view if i am doing something wrong.

PHP код:
stock LoadBiznis_data(playerid,name[],value[])
{
    for(new 
0!= MAX_BIZNISAi++)
    
INI_Int("Ime",BiznisInfo[i][Name]);
    
INI_Int("Owner",BiznisInfo[i][Owner]);
    
INI_Int("Pozicija",BiznisInfo[i][Pozicija]);
    
INI_Int("Interijer",BiznisInfo[i][Interijer]);
    
INI_Int("Zakljucan",BiznisInfo[i][Zakljucan]);
     
INI_Int("Cijena",BiznisInfo[i][Cijena]);
     
INI_Int("PickupID",BiznisInfo[i][PickupID]);
     
INI_Int("LabelID",BiznisInfo[i][LabelID]);
     return 
1;

Thanks for your support!


Re: Businesses - ]Rafaellos[ - 07.05.2015

Why don't you put all the code in brackets? With the way you are doing it, compiler thinks that you do

pawn Код:
for(new i = 0; i != MAX_BIZNISA; i++)
    INI_WriteString(bFile, "Ime", BiznisInfo[i][Name]);
So

pawn Код:
new
    INI:bFile = INI_Open(BiznisPath(playerid))
;

INI_SetTag(bFile,"data");

for(new i = 0; i != MAX_BIZNISA; i++)
{
    INI_WriteString(bFile, "Ime", BiznisInfo[i][Name]);
    INI_WriteString(bFile, "Owner", BiznisInfo[i][Owner]);
    INI_WriteInt(bFile, "Pozicija", BiznisInfo[i][Pozicija]);
    INI_WriteInt(bFile, "Interijer", BiznisInfo[i][Interijer]);
    INI_WriteString(bFile, "Zakljucan", BiznisInfo[i][Zakljucan]);
    INI_WriteInt(bFile, "Cijena", BiznisInfo[i][Cijena]);
    INI_WriteInt(bFile, "PickupID", BiznisInfo[i][PickupID]);
    INI_WriteInt(bFile, "LabelID", BiznisInfo[i][LabelID]);
}



Re: Businesses - NoDi522 - 07.05.2015

Ok but...

PHP код:
C:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1692) : warning 213tag mismatch
C
:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1693) : warning 213tag mismatch
C
:\Users\Dino Covic\Desktop\SAMP Server\gamemodes\Server_Skripta.pwn(1697) : warning 213tag mismatch 
1692:

PHP код:
INI_WriteInt(bFile"Pozicija"BiznisInfo[i][Pozicija]); 
1693:

PHP код:
INI_WriteInt(bFile"Interijer"BiznisInfo[i][Interijer]); 
1697:

PHP код:
INI_WriteInt(bFile"LabelID"BiznisInfo[i][LabelID]); 



Re: Businesses - ]Rafaellos[ - 07.05.2015

For the first 2, use INI_WriteFloat instead. For the 3rd, you can't write a label into a file.


Re: Businesses - Konstantinos - 07.05.2015

- Pozicija and Interijer arrays are floats, not integers (INI_WriteFloat).
- They're also arrays so you have to save each index separate (for example):
pawn Код:
INI_WriteFloat(bFile, "Pozicija_X", BiznisInfo[i][Pozicija][0]);
INI_WriteFloat(bFile, "Pozicija_Y", BiznisInfo[i][Pozicija][1]);
INI_WriteFloat(bFile, "Pozicija_Z", BiznisInfo[i][Pozicija][2]);
- There is absolutely no reason to save label IDs.
- Why do you save them under OnPlayerDisconnect instead of OnGameModeExit (as it should be)?


Re: Businesses - NoDi522 - 07.05.2015

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
- Pozicija and Interijer arrays are floats, not integers (INI_WriteFloat).
- They're also arrays so you have to save each index separate (for example):
pawn Код:
INI_WriteFloat(bFile, "Pozicija_X", BiznisInfo[i][Pozicija][0]);
INI_WriteFloat(bFile, "Pozicija_Y", BiznisInfo[i][Pozicija][1]);
INI_WriteFloat(bFile, "Pozicija_Z", BiznisInfo[i][Pozicija][2]);
- There is absolutely no reason to save label IDs.
- Why do you save them under OnPlayerDisconnect instead of OnGameModeExit (as it should be)?
Ok. IDK why am I saving it under OnPlayerDisconnect. I mean every other system like: Job system,register system in my script have been saved under onplayerdisconnect.


Re: Businesses - rappy93 - 07.05.2015

You should make a timer that saves all of your information once every 10 minutes ( Just an example ) and also make a function to save everything when the server closes. Like Konstantinos said.


Re: Businesses - NoDi522 - 07.05.2015

Thank you guys for your support it worked

@Rappy93

I am not good enough to do that