!!Save Kills and Deaths!!
#1

hi all,

ive got this register/login system: (only money and score is saved)

pawn Код:
#include <dini>
#define DIALOG_LOGIN 3
#define DIALOG_REG 4
enum spieler_daten
{
eingeloggt
}
new Spieler[MAX_PLAYERS][spieler_daten];

public OnPlayerConnect(playerid)
{
new pname[MAX_PLAYERS],accFormat[128];
GetPlayerName(playerid,pname,sizeof pname);
format(accFormat,sizeof accFormat,"%s.datei",pname);
if(fexist(accFormat))
    {
        ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please login!","Next","Cancel");
    }
    else
    {
        ShowPlayerDialog(playerid,DIALOG_REG,1,"Register","Please register!","Next","Cancel");
    }
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{

 

    new pname[MAX_PLAYERS],accFormat[128];
    GetPlayerName(playerid,pname,sizeof pname);
    format(accFormat,sizeof accFormat,"%s.datei",pname);
    if(fexist(accFormat) && Spieler[playerid][eingeloggt])
    {
       

  dini_IntSet(accFormat,"Geld",GetPlayerMoney(playerid));
  dini_IntSet(accFormat,"Score",GetPlayerScore(playerid));
    }
    Spieler[playerid][eingeloggt] = 0;

    return 1;
}

public OnPlayerSpawn(playerid)
{

    new pname[MAX_PLAYERS],accFormat[128];
    GetPlayerName(playerid,pname,sizeof pname);
    format(accFormat,sizeof accFormat,"%s.datei",pname);




    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

    new pname[MAX_PLAYERS],accFormat[128];
    GetPlayerName(playerid,pname,sizeof pname);
    format(accFormat,sizeof accFormat,"%s.datei",pname);
    if(response)
    {
        switch(dialogid) // dialogid auswдhlen
        {
            case DIALOG_LOGIN: // ID Login
            {
                if(!strlen(inputtext))
                {
                    ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please login!","Next","Cancel");
                    return SendClientMessage(playerid,0xFFFFFFFF,"No password entered!");
                }
                if(strcmp(inputtext,dini_Get(accFormat,"Passwort")) == 0) // Passwort Direkt aus der Datei Laden
                {
                   
                    GivePlayerMoney(playerid,dini_Int(accFormat,"Geld"));
                    SetPlayerScore(playerid,dini_Int(accFormat,"Score"));
                   
                    Spieler[playerid][eingeloggt] = 1; // Spieler ist nun erfolgreich eingeloggt
                    SendClientMessage(playerid,0xFFFFFFFF,"You has been loged in successfully.");
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please login!","Next","Cancel");
                    SendClientMessage(playerid,0xFFFFFFFF,"The password you entered is invalid!");
                }
            }
            case DIALOG_REG: // ID Registrieren
            {
                if(!strlen(inputtext)) // Text darf nicht = Null sein Null im Sinne von nichts
                {
                        ShowPlayerDialog(playerid,DIALOG_REG,1,"Register","Please register!","Next","Cancel");
                        return SendClientMessage(playerid,0xFFFFFFFF,"The password is too short!");
                }
                dini_Create(accFormat);
                dini_Set(accFormat,"Passwort",inputtext);
                Spieler[playerid][eingeloggt] = 1;
                SendClientMessage(playerid,0xFFFFFFFF,"Account has been created successfully, you're loged in now.");
            }
        }
    }
    else
    {
        switch(dialogid)
        {
            case DIALOG_LOGIN:ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please login!","Next","Cancel");
            case DIALOG_REG:ShowPlayerDialog(playerid,DIALOG_REG,1,"Register","Please register!","Next","Cancel");
        }
    }
    return 1;
}
This is my system and it also shows me the Deaths and Kills(tode) when i type in /stats
but it doesnt save them.

pawn Код:
new tode[MAX_PLAYERS], kills[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{

     tode[playerid]++;
     if(killerid!=INVALID_PLAYER_ID) {
     kills[killerid]++; }


     return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext,"/stats",true)==0) {
new s[50];
format(s,sizeof(s),"Kills: %d | Deaths: %d | Ratio: ",kills[playerid],tode[playerid]);
//format(s,sizeof(s),"Time : %d | Score : %d | Money: %d$",kills[playerid],score[playerid],GetPlayerMoney(playerid));
SendClientMessage(playerid,0xFFFF00AA,s);
}
return 0;
}
Money, Score and Times doesnt work yet in the playercommandtext.
But its important that kills and deaths are saved, what i have to do and to add to save this??

I just cant figure it out please help me.

Regards. Please ask if u dont understand sth.
Reply
#2

Please can someone tell me how to save kills and deaths??
Or give me a link if u know where to find some information about it.
Please help!!
Reply
#3

du savest nur score auf onplayerdisconnect, wegen das hier:"
Код:
 if(fexist(accFormat) && Spieler[playerid][eingeloggt])   
{          
dini_IntSet(accFormat,"Geld",GetPlayerMoney(playerid));  
dini_IntSet(accFormat,"Score",GetPlayerScore(playerid));    
}"
add da einfach,
dini_IntSet(accFormat,"Kills",kills[playerid]));
dini_IntSet(accFormat,"Deaths",tode[playerid]))

und dann auch hier:

Код:
 if(strcmp(inputtext,dini_Get(accFormat,"Passwort")) == 0) // Passwort Direkt aus der Datei Laden                
{                                        
GivePlayerMoney(playerid,dini_Int(accFormat,"Geld"));                    
SetPlayerScore(playerid,dini_Int(accFormat,"Score"));       
Kills[playerid]=(playerid,dini_Int(accFormat,"Kills"));                
tode[playerid]=(playerid,dini_Int(accFormat,"Tode"));                                           
Spieler[playerid][eingeloggt] = 1; // Spieler ist nun erfolgreich eingeloggt                    
SendClientMessage(playerid,0xFFFFFFFF,"You has been loged in successfully.");                
}
bin mir nicht sicher ob das funkt aber versuch es mal
oh btw, sry fьr mein Deutsch, ist ja schlecht aber ich glaube kannst mich verstehen
Reply
#4

So

pawn Код:
kills[playerid] = (dini_Int(accFormat,"Kills"));
tode[playerid] = (dini_Int(accFormat,"Tode"));
Reply
#5

Hi,
thank u all.
Im so happy to read some answers, cause i simply cant solve this problem by myself
Im gonna try it out as soon as ive got time cause right now i have to study
Thank u so much.

Ach ja, ich bin ьbrigens auch der deutschen Sprache mдchtig.
Vielen Dank!!

best regards.
Reply
#6

hi,
there are no errors but the kills and deaths just are not saved!!

Pls @ u pro scripters help me with this problem.

or tell me where the error in this previous posts is.


Please !!!!
Reply
#7

ahh,
now the kills are saved but how to save also the deaths??
I did it like lutsen told me.
Pls answer!!
Reply
#8

Than you are doing something wrong, like he said, you need to add next to

Quote:
Originally Posted by Lutsen
Посмотреть сообщение
pawn Код:
if(fexist(accFormat) && Spieler[playerid][eingeloggt])  
{          
dini_IntSet(accFormat,"Geld",GetPlayerMoney(playerid));  
dini_IntSet(accFormat,"Score",GetPlayerScore(playerid));    
}
That
Quote:
Originally Posted by Lutsen
Посмотреть сообщение
pawn Код:
dini_IntSet(accFormat,"Kills",kills[playerid]));
dini_IntSet(accFormat,"Deaths",tode[playerid]))
Reply
#9

thx

its like u said, i did sth. wrong

i wanna thank u all for ur patience with noobs like me

mhh...
is there a possibility to save the time a player has played on the server and then displays it with e.g. /stats?
I also add a ratio calculation funktion and it displays the score, money, deaths, kills and the ratio.
That time thing would be pretty cool.
Or to save the rounds a player has already played.

regards. and thx again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)