02.10.2009, 22:53
hello, what can i use to save my kills+deaths+score ? i have my own /stats but i want to save my score but i dont need to save money only kills deaths and score
Originally Posted by CJ101
an admin filterscript would work. search.
|
Originally Posted by Jonny Calone
Quote:
|
Originally Posted by Battleskull
Quote:
|
Originally Posted by Jonny Calone
Quote:
|
Originally Posted by Battleskull
Quote:
|
Originally Posted by Battleskull
do you have a login system? You need a login system otherwise you will have people with same names take each others scores. If you have a login system I might need to see it to help.
|
new string[128];
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
format(string,sizeof(string),"Stats/%s.ini",Name);
new File: statsfile = fopen(string,io_read);
if(!statsfile)
{
fcreate(string);
}
format(string,sizeof(string),"Kills=%d\r\n",PlayerInfo[playerid][pKills]);fwrite(statsfile,string);
format(string,sizeof(string),"Deaths=%d\r\n",PlayerInfo[playerid][pDeaths]);fwrite(statsfile,string);
format(string,sizeof(string),"Score=%d\r\n",GetPlayerScore(playerid));fwrite(statsfile,string);
fclose(statsfile);
}
Login(playerid);
forward Login(playerid);
public Login(playerid)
{
new string[128];
format(string,sizeof(string),"Stats/%s.ini",PlayerName(playerid));
new File: statsfile = fopen(string,io_read);
new key[256],val[256];
new Data[256];
while(fread(file,Data,sizeof(Data)))
{
key = ini_GetKey(Data);
if(strcmp(key,"Kills",true) == 0){val = ini_GetValue(Data);PlayerInfo[playerid][pKills] = strval(val);}
if(strcmp(key,"Deaths",true) == 0){val = ini_GetValue(Data);PlayerInfo[playerid][pDeaths] = strval(val);}
if(strcmp(key,"Score",true) == 0){val = ini_GetValue(Data);SetPlayerScore(playerid,strval(val));}
}
return 1;
}
stock ini_GetKey(line[])
{
new keyRes[128];
keyRes[0] = 0;
if(strfind(line, "=", true) == -1) return keyRes;
strmid(keyRes, line, 0, strfind(line, "=", true), sizeof(keyRes));
return keyRes;
}
stock ini_GetValue(line[])
{
new valRes[128];
valRes[0] = 0;
if(strfind(line, "=", true) == -1) return valRes;
strmid(valRes, line, strfind(line, "=", true)+1, strlen(line), sizeof(valRes));
return valRes;
}
stock PlayerName(playerid) {
new name[255];
GetPlayerName(playerid, name, 255);
return name;
}
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;