SA-MP Forums Archive
how can i make it - 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: how can i make it (/showthread.php?tid=615804)



how can i make it - BrianS123 - 27.08.2016

hi
i'm trying to make a dynamic locker system, but i don't know how can i make the lockers load and save..
i'm using Y/INI
Код:
enum DLocker
{
	Text[128],
	Float:lockerz,
	Float:lockery,
	Float:lockerx,
	lTeam,
};
how can i make a load function...
like
Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Level",PlayerInfo[playerid][pLevel]);



Re: how can i make it - WhiteGhost - 27.08.2016

Not really sure about Y_INI but..
Код:
enum DLocker
{
	Text[128],
	Float:lockerz,
	Float:lockery,
	Float:lockerx,
	lTeam,
};



Re: how can i make it - BrianS123 - 27.08.2016

Quote:
Originally Posted by WhiteGhost
Посмотреть сообщение
Not really sure about Y_INI but..
Код:
enum DLocker
{
	Text[128],
	Float:lockerz,
	Float:lockery,
	Float:lockerx,
	lTeam,
};
what you mean with that? ^^


Re: how can i make it - oMa37 - 27.08.2016

@WhiteGhost, this will cause errors while compiling, It's wrong.

@Brian, Save the string with Int_String, the float Int_Float and 1Team with integer or however you use it.

EDIT:
My bad, Remove the comma that WhiteGhost told you about.


Re: how can i make it - BrianS123 - 27.08.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
@WhiteGhost, this will cause errors while compiling, It's wrong.

@Brian, Save the string with Int_String, the float Int_Float and 1Team with integer or however you use it.
Can you give me an example?


Re: how can i make it - BrianS123 - 28.08.2016

I just wanna know what to type here
Код:
forward loadlocker(here??, name[], value[])
In the player things i'll type "playerid", but for the lockers?, "lockerid?"


Re: how can i make it - Tass007 - 28.08.2016

PHP код:
#define MAX_LOCKERS 3
forward LoadLocker(lockeridname[], value[]);
enum DLocker
{
    
Name[128],
    
Float:lockerz,
    
Float:lockery,
    
Float:lockerx,
    
lTeam,
};
new 
LockerInfo[MAX_LOCKERS][DLocker];
public 
LoadLocker(lockeridname[], value[])
{
    
INI_String("Text"LockerInfo[lockerid][Name], 128);
    
INI_Float("LockerZ"LockerInfo[lockerid][lockerz]);
    
INI_Float("LockerY"LockerInfo[lockerid][lockery]);
    
INI_Float("LockerX"LockerInfo[lockerid][lockerx]);
    
INI_Int("LTeam"LockerInfo[lockerid][lTeam]);

Hope that helps.

Also here is a save data.
PHP код:
forward SaveLocker(lockerid);
public 
SaveLocker(lockerid)
{
    new 
INI:File INI_Open(LockerPath(lockerid));
    
INI_SetTag(File"Locker Data");
    
INI_WriteString(File"Text",LockerInfo[lockerid][Name]);
    
INI_WriteFloat(File"LockerZ",LockerInfo[lockerid][lockerz]);
    
INI_WriteFloat(File"LockerY",LockerInfo[lockerid][lockery]);
    
INI_WriteFloat(File"LockerX",LockerInfo[lockerid][lockerx]);
    
INI_WriteInt(File"lTeam",LockerInfo[lockerid][lTeam]);
    
INI_Close(File);
    return 
1;




Re: how can i make it - BrianS123 - 28.08.2016

Thanks a lot i'll test it,
So i can type anything instead of "lockerid?" i choose what to call it?


Re: how can i make it - BrianS123 - 28.08.2016

Код:
(199) : error 047: array sizes do not match, or destination array is too small
(209) : error 001: expected token: "-string end-", but found "-identifier-"
(209) : warning 215: expression has no effect
(209) : error 001: expected token: ";", but found ")"
(209) : error 029: invalid expression, assumed zero
(209) : fatal error 107: too many error messages on one line
---------------------------------------------------------------------------------------------------------
#define LockerPath "/Lockers/%i.ini"
Код:
 199 - INI_String("Text", LockerInfo[lockerid][Name], 128);
______________________________________________________________________________
209 - new INI:File = INI_Open(LockerPath(lockerid));



Re: how can i make it - Tass007 - 28.08.2016

Quote:
Originally Posted by BrianS123
Посмотреть сообщение
Thanks a lot i'll test it,
So i can type anything instead of "lockerid?" i choose what to call it?
Yeah. But it's best to have variables that make sense.
It could be like forward LoadLockers(LID, name[], value[]);

or it could be LoadLockers(reallylongunneededname,name[], value[]);
with doing it this way when you make the load callback it's going to be really long.

PHP код:
public LoadLocker(reallylongunneedednamename[], value[])
{
    
INI_String("Text"LockerInfo[reallylongunneededname][Name], 128);
    
INI_Float("LockerZ"LockerInfo[reallylongunneededname][lockerz]);
    
INI_Float("LockerY"LockerInfo[reallylongunneededname][lockery]);
    
INI_Float("LockerX"LockerInfo[reallylongunneededname][lockerx]);
    
INI_Int("LTeam"LockerInfo[reallylongunneededname][lTeam]);

And it doesn't look as professional and it looks messy. Best to keep it a sensible name.