YSI/y_ini function
#1

Hi everyone, im trying to make a save function for the custom car system i'm making but this crashes? I'm not too sure why Anyone knows how to solve it out?
Код:
function SaveAccountStats(playerid)
{
	new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Veh1model",PlayerInfo[playerid][pVeh1model]);
    INI_WriteInt(File,"Veh1id",PlayerInfo[playerid][pVeh1id]);
    INI_WriteInt(File,"Veh1colour1",PlayerInfo[playerid][pVeh1colour1]);
    INI_WriteInt(File,"Veh1colour2",PlayerInfo[playerid][pVeh1colour2]);
    INI_WriteFloat(File,"Veh1_x",PlayerInfo[playerid][pVeh1_x]);
    INI_WriteFloat(File,"Veh1_y",PlayerInfo[playerid][pVeh1_y]);
    INI_WriteFloat(File,"Veh1_z",PlayerInfo[playerid][pVeh1_z]);
    INI_WriteInt(File,"VehOwned",PlayerInfo[playerid][pVehOwned]);
	INI_Close(File);
    return 1;
}
Reply
#2

do it makes the compiler to crash or do it give errors and if so what are the errors mind posting them here
Reply
#3

pawn Код:
function SaveAccountStats(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Veh1model",PlayerInfo[playerid][pVeh1model]);
    INI_WriteInt(File,"Veh1id",PlayerInfo[playerid][pVeh1id]);
    INI_WriteInt(File,"Veh1colour1",PlayerInfo[playerid][pVeh1colour1]);
    INI_WriteInt(File,"Veh1colour2",PlayerInfo[playerid][pVeh1colour2]);
    INI_WriteFloat(File,"Veh1_x",PlayerInfo[playerid][pVeh1_x]);
    INI_WriteFloat(File,"Veh1_y",PlayerInfo[playerid][pVeh1_y]);
    INI_WriteFloat(File,"Veh1_z",PlayerInfo[playerid][pVeh1_z]);
    INI_WriteString(File,"VehOwned",PlayerInfo[playerid][pVehOwned],128); // change this to the value that in the enum ok
    INI_Close(File);
    return 1;
}
Reply
#4

Thats the problem it crashes the compiler :/ And its 100% this because i don't even get warnings without that
Reply
#5

Код:
enum pInfo
{
	   pVeh1model,
	   pVeh1id,
	   pVeh1colour1,
	   pVeh1colour2,
   	   Float:pVeh1_x,
	   Float:pVeh1_y,
	   Float:pVeh1_z,
	   pVehOwned[128]
	   
}
thats my enum colum and still crashes
Reply
#6

pawn Код:
enum pInfo
{
       pVeh1model,
       pVeh1id,
       pVeh1colour1,
       pVeh1colour2,
       Float:pVeh1_x,
       Float:pVeh1_y,
       Float:pVeh1_z,
       pVehOwned[128],
       
}
I'm not a 100 percent sure, but maybe a more advanced scripter can confirm but shouldn't it be a Stock not a function?
Reply
#7

pawn Код:
forward SaveAccountStats(playerid);
// that on top of your gm
public SaveAccountStats(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Veh1model",PlayerInfo[playerid][pVeh1model]);
    INI_WriteInt(File,"Veh1id",PlayerInfo[playerid][pVeh1id]);
    INI_WriteInt(File,"Veh1colour1",PlayerInfo[playerid][pVeh1colour1]);
    INI_WriteInt(File,"Veh1colour2",PlayerInfo[playerid][pVeh1colour2]);
    INI_WriteFloat(File,"Veh1_x",PlayerInfo[playerid][pVeh1_x]);
    INI_WriteFloat(File,"Veh1_y",PlayerInfo[playerid][pVeh1_y]);
    INI_WriteFloat(File,"Veh1_z",PlayerInfo[playerid][pVeh1_z]);
    INI_WriteString(File,"VehOwned",PlayerInfo[playerid][pVehOwned],128); // change this to the value that in the enum ok
    INI_Close(File);
    return 1;
}
Reply
#8

Nope my collum is correct you don't put a comma on the last one. I'm really not sure, but i think i should be a function really confused now
Reply
#9

It should be a stock or a public not a function.
Reply
#10

@Gangster-rocks Genius! But now some crappy errors?
Код:
C:\Users\Matt and Amy\Documents\pawno\pawno\Carsystem.pwn(251) : error 017: undefined symbol "PlayerInfo"
C:\Users\Matt and Amy\Documents\pawno\pawno\Carsystem.pwn(251) : warning 215: expression has no effect
C:\Users\Matt and Amy\Documents\pawno\pawno\Carsystem.pwn(251) : error 001: expected token: ";", but found "]"
C:\Users\Matt and Amy\Documents\pawno\pawno\Carsystem.pwn(251) : error 029: invalid expression, assumed zero
C:\Users\Matt and Amy\Documents\pawno\pawno\Carsystem.pwn(251) : fatal error 107: too many error messages on one line
that line :
INI_WriteInt(File,"Veh1model",PlayerInfo[playerid][pVeh1model]);

@Lido Im pretty sure it will work as a function


@ Edit
Silly me - new PlayerInfo[MAX_PLAYERS][pInfo];


@ Edit Okay, everything is ok now - Close the post please

Btw ill +rep people who helped Thanks again!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)