Pomoc sa LOG/REG sistemom

Započeo bogisa99, Maj 30, 2020, 13:05:23 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Problem(error/warning):Ovako,pokusavam napraviti register sistem(sifra,godine,pol drzava) sifra lepo radi ali kada sam pokusao napraviti pol ne zeli da sacuva skin i uvek se spawnam kao CJ,ako mi mozete reci gde i sta sam pogresio.Hvala svima unapred.
Dio skripte: [ pawn ] new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Pol",PlayerInfo[playerid][pPol]);
    INI_Int("Drzava",PlayerInfo[playerid][pDrzava]);
    INI_Int("Godine",PlayerInfo[playerid][pGodine]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
//////////////////////////////////////////////
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Ukucajte Vasu lozinku da se ulogujete.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Unesite zeljenu lozinku da se registrujete.","Register","Quit");
    }
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Pol",PlayerInfo[playerid][pPol]);
    INI_Close(File);
    return 1;
}

public OnPlayerSpawn(playerid)
{
   if(PlayerInfo[pInfo][pPol] == 1)
   {
      SetPlayerSkin(playerid,102);
   }
   else if(PlayerInfo[pInfo][pPol] == 2)
   {
      SetPlayerSkin(playerid,195);
   }
   return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"Uneli ste neprihvatljivu lozinku.\n"COL_WHITE"Unesite zeljenu lozinku da se regitrujete.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);
                ShowPlayerDialog(playerid, DIALOG_POL, DIALOG_STYLE_LIST,"Hvala.Sada izaberite Vas pol:","Musko \nZesnko","Potvrdi","Odustani");
         }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                   SpawnPlayer(playerid);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"Uneli ste netacnu lozinku.\n"COL_WHITE"Unesite Vasu lozinku da se ulogujete.","Login","Quit");
                }
                return 1;
            }
        }
    }
   if(dialogid == DIALOG_POL)
   {
      if(!response) return Kick(playerid);
      if(response)
      {
         switch(listitem)
         {
            case 0:
            {
               new INI:File = INI_Open(UserPath(playerid));
                   INI_WriteInt(File,"Pol",1);
                   INI_Close(File);
                    SetPlayerSkin(playerid,102);
               SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                   SpawnPlayer(playerid);
            }
            case 1:
            {
               new INI:File = INI_Open(UserPath(playerid));
               INI_WriteInt(File,"Pol",2);
                   INI_Close(File);
                    SetPlayerSkin(playerid,102);
               SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                   SpawnPlayer(playerid);
            }
         }
      }
   }
   return 1;
}
Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): /
Slika/video ingame problema(obavezno ako je ingame problem): /
Poslednja Izmena: Jun 01, 2020, 01:12:59 PRE PODNE od daddy.

nisam bas toliko upucen u INI-e, ali šta misliš da otvaraš samo jednom INI file, npr kada izabere pol, da tada kreira cijeli INI file i da piše u njega. npr.

umjesto

[pawn]            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"Uneli ste neprihvatljivu lozinku.\n"COL_WHITE"Unesite zeljenu lozinku da se regitrujete.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);
                ShowPlayerDialog(playerid, DIALOG_POL, DIALOG_STYLE_LIST,"Hvala.Sada izaberite Vas pol:","Musko \nZesnko","Potvrdi","Odustani");
         }[/pawn]

da ostaviš samo

[pawn]if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"Uneli ste neprihvatljivu lozinku.\n"COL_WHITE"Unesite zeljenu lozinku da se regitrujete.","Register","Quit");
ShowPlayerDialog(playerid, DIALOG_POL, DIALOG_STYLE_LIST,"Hvala.Sada izaberite Vas pol:","Musko \nZesnko","Potvrdi","Odustani");
[/pawn]

a kada izabere sam pol, da upisuje sve u INI file.
[pawn]
         switch(listitem)
         {
            case 0:
            {
new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Pol",1);
                INI_Close(File);
                    SetPlayerSkin(playerid,102);
               SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                   SpawnPlayer(playerid);
           }
[/pawn]


Moras brate imat enum za skin. Mislim da je tako najlakse da se napravi.


Znaš li parametre SetSpawnInfo funkcije?
My tutorials: PawnPlus MySQL, y_colours

O Boze sacuvaj nisam primetio  ??? ??? Hvala! :D