Save highest Killstreak?
#1

hi,

im using dini system to save my stats to a file.
Its not a problem to save files but now its a bit different.
Ive scripted a kind of Killstreak system.
After 3 kills without dieing there is a game text displayed: "Player name" Killing spree
After 4 kills another text and so on.
Now my question is how would i save the highest killstreak ever done in a round?
After every death and round change i reset the Killstreak counter.
Now i dont know how to save the killstreak before resetting and also i dont know how to check if the killstreak that is saved is higher or lower than the new one (if the new one is higher id like to overwrite the old one).

I hope some scripters are ready to help me
regards...

pawn Код:
new Killstreak[MAX_PLAYERS];

//OnPlayerDeath

Killstreak[playerid]=0;
Killstreak[killerid]++;
Reply
#2

anyone?
Reply
#3

cmon guys

just use ur brain
Reply
#4

You can use yours to by going to wiki.sa-mp.com and create one yourself

You can use like KillingSpree++;
And when it reaches KillingSpree = 3;
You can send a message to other players. Just an example
Reply
#5

mhh,

u didnt understand me at all.
pls read my first post.
Im asking how to save the highest killstreak and not how to display it after a certain amount of kills, thats just not the problem.
Reply
#6

Open another file that contains the top 5 (example) and does a linear comparison with the highest kill-streak of that round.

Make your own interpreter to tell it where to save it at in the file, and how it reads it. If you need me to be a bit more elaborate, feel free to say so.
Reply
#7

hi,
thx for ur answer.
Yeah, id be happy if u could explain some more

But just to be sure that youve understood me:

I want to do that for every player.
So if a player views his stats highest killstreak: 10 (e.g.)

But if this player now kills 11 people without dieing this 10 will be overwritten with 11 kills.
If his next killstreak is 8 then the 11 wont be overwritten cause its smaller....

i hope u can understand
Reply
#8

Oh, that's even easier than what I thought you were saying.

Basically you could have a separate array holding the streaks for the players of that round. Once done, compare it to the streak you loaded from the file. If it's larger (>) than the one in the file, open the file & save it.

I haven't used dini lately so I can't give you an example in dini.

End of round
for each player
compare their new killing streak to the one in the file if(mydata[playerid][streak] > roundstreak[playerid])
IF it's higher than the one in the file overwrite it and save it to the file
ELSE move on to the next player

If you still need help I'll make a quick example.
Reply
#9

if u have some time left i would not be unhappy about an example

iuse dini like this:

pawn Код:
//OnPlayerDisconnect
    new pname[MAX_PLAYERS],accFormat[128];
    GetPlayerName(playerid,pname,sizeof pname);
    format(accFormat,sizeof accFormat,"%s.file",pname);
    if(fexist(accFormat) && Player[playerid][loggedIn])
    {

  dini_IntSet(accFormat,"Kills",kills[playerid]);
  dini_IntSet(accFormat,"Deaths",deaths[playerid]);

 }
    Player[playerid][loggedIn] = 0;

//OnDialogResponse
    new pname[MAX_PLAYERS],accFormat[128];
    GetPlayerName(playerid,pname,sizeof pname);
    format(accFormat,sizeof accFormat,"%s.file",pname);
    if(response)
    {
        switch(dialogid)
        {
            case DIALOG_LOGIN:
            {
                if(!strlen(inputtext))
                {
                    ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please login!","Next","Cancel");
                    return SendClientMessage(playerid,0xFFFFFFFF,"No {B0171F}password entered!"), Kick(playerid);
                }
                if(strcmp(inputtext,dini_Get(accFormat,"Password")) == 0)
                {
                    kills[playerid]=(playerid,dini_Int(accFormat,"Kills"));
                    deaths[playerid]=(playerid,dini_Int(accFormat,"Deaths"));

                    Player[playerid][loggedIn] = 1;
                    SendClientMessage(playerid,0xFFFFFFFF,"You has been loged in {009900}successfully.");
                }
                else
                {
                                 //.....
                                }
Reply
#10

You can do it with two variables

pawn Код:
new SavedKillstreak[MAX_PLAYERS];
new TempKillstreak[MAX_PLAYERS];

And when the player kills some one, add 1 to his temporary kill streak. And when he eventually dies just compare his saved (old) kill streak to his temporary (new) kill streak.

pawn Код:
//OnPlayerDeath
TempKillstreak[killerid]++; // add 1 for the killer
if(TempKillstreak[playerid] > SavedKillstreak[playerid])
{
    SavedKillstreak[playerid] = TempKillstreak[playerid]; // set his saved killstreak to his new, higher streak
}
TempKillstreak[playerid] = 0; // Reset his temp kill streak

Now your left with his best kill streak and it can be saved with the SavedKillstreak variable.

Just an example for you to work on.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)