what to use to save my kills+deaths+score
#1

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
Reply
#2

an admin filterscript would work. search.
Reply
#3

Quote:
Originally Posted by CJ101
an admin filterscript would work. search.
i use LAdmin i aint changing
Reply
#4

Quote:
Originally Posted by Jonny Calone
Quote:
Originally Posted by CJ101
an admin filterscript would work. search.
i use LAdmin i aint changing
so you want you /stat to display kills deaths and score?
Reply
#5

Quote:
Originally Posted by Battleskull
Quote:
Originally Posted by Jonny Calone
Quote:
Originally Posted by CJ101
an admin filterscript would work. search.
i use LAdmin i aint changing
so you want you /stat to display kills deaths and score?
im saying that i want to save my score+kills+deaths autosave those
Reply
#6

Quote:
Originally Posted by Jonny Calone
Quote:
Originally Posted by Battleskull
Quote:
Originally Posted by Jonny Calone
Quote:
Originally Posted by CJ101
an admin filterscript would work. search.
i use LAdmin i aint changing
so you want you /stat to display kills deaths and score?
im saying that i want to save my score+kills+deaths autosave those
save to what? a file when then log in? save to a command?
Reply
#7

Quote:
Originally Posted by Battleskull
Quote:
Originally Posted by Jonny Calone
Quote:
Originally Posted by Battleskull
Quote:
Originally Posted by Jonny Calone
Quote:
Originally Posted by CJ101
an admin filterscript would work. search.
i use LAdmin i aint changing
so you want you /stat to display kills deaths and score?
im saying that i want to save my score+kills+deaths autosave those
save to what? a file when then log in? save to a command?
bro to save the stats man when a user login back again teh server he have the same stats as last time
Reply
#8

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

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.
i have a login and register system but i only need to save my kills+death+score
Reply
#10

Top of script:

[pawn]enum pInfo
{
pKills,
pDeaths,
};
new PlayerInfo[256][pInfo];


OnPlayerDisconnect:

pawn Код:
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);
}
OnPlayerConnect [FUNCTION BELOW]:

pawn Код:
Login(playerid);
FUNCTIONS:

pawn Код:
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;
}
OnPlayerDeath:

pawn Код:
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
Sorry i did this in the forum so theres no identation.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)