how can i make it
#1

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]);
Reply
#2

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

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? ^^
Reply
#4

@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.
Reply
#5

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?
Reply
#6

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?"
Reply
#7

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;

Reply
#8

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

Код:
(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));
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)