Kills and Death
#1

Okay so im in the process of making my TDM server. So, i need to save kills and save deaths when the player disconnects. I need someone to help me with doing this. This is a stand alone gamemode so im going to need to create the enum. How would i do this?
Reply
#2

For Dini (recommended for beginners):

OnPlayerDeath:
pawn Код:
dini_IntSet(PlayerName(playerid), "Deaths", dini_Int(PlayerName(playerid), "Deaths")+1);
dini_IntSet(PlayerName(killerid), "Kills", dini_Int(PlayerName(killerid), "Kills")+1);
Somewhere else:
pawn Код:
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
Edit it to ur likenings. Made this fast on ipod
Reply
#3

Quote:
Originally Posted by RobinOwnz
Посмотреть сообщение
For Dini (recommended for beginners):

OnPlayerDeath:
pawn Код:
dini_IntSet(PlayerName(playerid), "Deaths", dini_Int(PlayerName(playerid), "Deaths")+1);
dini_IntSet(PlayerName(killerid), "Kills", dini_Int(PlayerName(killerid), "Kills")+1);
Somewhere else:
pawn Код:
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
Edit it to ur likenings. Made this fast on ipod
Compiled good, where does it save to?

Also, could i use this for /stats? to show deaths and kills? if so how?
Reply
#4

Quote:
Originally Posted by Shockey HD
Посмотреть сообщение
Compiled good, where does it save to?

Also, could i use this for /stats? to show deaths and kills? if so how?
To scriptfiles.

Yes, using dini_Int.

(give reputation+ for me please xD)
Reply
#5

Here's something I wrote that might be helpful. (Using dini)

At the top, with other variables:
pawn Код:
new Kills[MAX_PLAYERS];
new Deaths[MAX_PLAYERS];
Now:
pawn Код:
public OnPlayerConnect(playerid)
{
    Kills[playerid]=0;
    Deaths[playerid]=0;
    new file[128];
    format(file, sizeof(file), "%s.ini", GetName(playerid));
    if(!fexist(file)
    {
        dini_Create(file)
        dini_IntSet(file, "Kills", 0);
        dini_IntSet(file, "Deaths", 0);
        Kills[playerid] = dini_Int(file, "Kills");
        Deaths[playerid] = dini_Int(file, "Deaths");
    }
    else
    {
        Kills[playerid] = dini_Int(file, "Kills");
        Deaths[playerid] = dini_Int(file, "Deaths");
    }
    return 1;
}
Saving stats when player disconnects;
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[128];
    format(file, sizeof(file), "%s.ini", GetName(playerid));
    dini_IntSet(file, "Kills", Kills[playerid]);
    dini_IntSet(file, "Deaths", Deaths[playerid]);
    return 1;
}

_______
Please reputation +, if this helped

-Kane
Reply
#6

Quote:
Originally Posted by RobinOwnz
Посмотреть сообщение
To scriptfiles.

Yes, using dini_Int.

(give reputation+ for me please xD)
Someone seems to beg... And dini? Really? Switch over to Y_INI or MySQL.

Quote:
Originally Posted by Shockey HD
Посмотреть сообщение
Also, could i use this for /stats? to show deaths and kills? if so how?
pawn Код:
CMD:stats(playerid, params[])
{
    new kills = PlayerInfo[playerid][pKills];
    new deaths = PlayerInfo[playerid][pDeaths];

    new name[MAX_PLAYER_NAME];
    new string[128];
    SendClientMessage(playerid, COLOR_GREEN, "==========================================================================");
    format(string, sizeof(string), "%s - || Kills: %d || Deaths: %d", name, kills, deaths);
    SendClientMessage(playerid, COLOR_GRAD2,string);
    SendClientMessage(playerid, COLOR_GREEN, "==========================================================================");
    return 1;
}
As an example...
Reply
#7

Quote:
Originally Posted by Kush
Посмотреть сообщение
Someone seems to beg... And dini? Really? Switch over to Y_INI or MySQL.



pawn Код:
CMD:stats(playerid, params[])
{
    new kills = PlayerInfo[playerid][pKills];
    new deaths = PlayerInfo[playerid][pDeaths];

    new name[MAX_PLAYER_NAME];
    new string[128];
    SendClientMessage(playerid, COLOR_GREEN, "==========================================================================");
    format(string, sizeof(string), "%s - || Kills: %d || Deaths: %d", name, kills, deaths);
    SendClientMessage(playerid, COLOR_GRAD2,string);
    SendClientMessage(playerid, COLOR_GREEN, "==========================================================================");
    return 1;
}
As an example...
This is what i currently have for Stats. (Based off my TDM Server)

pawn Код:
CMD:stats(playerid,params[])
{
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"|____Your Stats____|");
    new rank[128];
    if(pRank[playerid] == 6) {
        rank = "Lieutenent";
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Rank: Lieutenent");
        new Float:pX, Float:pY, Float:pZ;
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else if(pRank[playerid] == 5) {
        rank = "Captain";
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Rank: Captain");
        new Float:pX, Float:pY, Float:pZ;
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else if(pRank[playerid] == 4) {
        rank = "Major";
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Rank: Major");
        new Float:pX, Float:pY, Float:pZ;
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else if(pRank[playerid] == 3) {
        rank = "Colonel";
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Rank: Colonel");
        new Float:pX, Float:pY, Float:pZ;
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else if(pRank[playerid] == 2) {
        rank = "General";
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Rank: General");
        new Float:pX, Float:pY, Float:pZ;
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else if(pRank[playerid] == 1) {
        rank = "Special Ops";
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Rank: Special Ops");
        new Float:pX, Float:pY, Float:pZ;
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else if(pRank[playerid] == 0) {
        rank = "Soldier";
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"Rank: Soldier");
        new Float:pX, Float:pY, Float:pZ;
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
        }
    return 1;
}
Woulld it be much different?
Reply
#8

Quote:
Originally Posted by Kush
Посмотреть сообщение
Someone seems to beg... And dini? Really? Switch over to Y_INI or MySQL.


If you even READED what I first said:
"For Dini (recommended for beginners)"
then you know why I said dini -.-

I use MySQL, but the guy who made the topic, doesn't seem so good at it right now, so dini is the easiest solution for him atm.
Reply
#9

Why not just use SQLite, with BUD(Blazing User Database). It's amazing, with how much easier it is to use SQLite than a whole mess of files.
Reply
#10

Quote:
Originally Posted by Steven82
Посмотреть сообщение
Why not just use SQLite, with BUD(Blazing User Database). It's amazing, with how much easier it is to use SQLite than a whole mess of files.
I perfer no includes while using SQLite, I mean pointless its dead easy!

Still though are you seriously going to think a new scripter will jump into hard things for them already?

(Not disrespecting)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)