pomoc boljih skriptera

Započeo | MARKO |, Jun 26, 2010, 22:42:44 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

prijavim s nickname manjim od 12 slova, onda je ok. cim s vise od 12 slova onda nije. kako mogu to napraviti da mogu imati nickname veci od 12 slova?! recimo 20. hvala.

pokusao sam kod "public onplayerregister" staviti "new loginname[64];" umjesto broja 64 na broj 128 i tako isto kod "public onplayerlogin" pa pa opet neuspjesno.

Correlli

Kod funkcije za registraciju (ili gdje već provjeravaš) će morati potražiti funkciju strlen koja provjerava dužinu imena/lozinke/stringa/bla bla.

uspio sam srediti to s duzinom nicka. jos mi sad samo recite kako bi mogao napravit da kad se ides regat na server, i upises lozinku ispod 8 znakova, da ti server ne prihvati registraciju, i da ispise sastrane u chat da lozinka mora biti duza od 8 znakova. kotistim dialog register i login. hvala
Poslednja Izmena: Jun 27, 2010, 00:58:50 PRE PODNE od filip_pnv

Opet koristis funkciju strlen, eto primjera:

if(strlen(inputtext) < 8)
{
    SendClientMessage(playerid, NEKA_BOJA, "Vasa lozinka mora biti iznad 8 znakova.");
    return 1;
}



public OnPlayerRegister(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
new string3[64];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "users/%s.ini", playername3);
new File: hFile = fopen(string3, io_write);
if (hFile)
{
    strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
    new var[64];
format(var, 64, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
format(var, 64, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
format(var, 64, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
format(var, 64, "DonateRank=%d\n",PlayerInfo[playerid][pDonateRank]);fwrite(hFile, var);

.....

a evo i dialogresponse

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new sendername[MAX_PLAYER_NAME];
new string[128];
if(response)
{
if(dialogid == 12346 || dialogid == 12347)
{
    if(strlen(inputtext))
    {
new tmppass[128];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
//Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
}
else
{
new loginstring[128];
new loginname[128];
GetPlayerName(playerid,loginname,sizeof(loginname));
format(loginstring,sizeof(loginstring),"POGRESNA LOZINKA\nMolimo unesite tocnu lozinku:",loginname);
ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Prijava",loginstring,"Prijava","Izlaz");
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 5) { Ban(playerid); }
}
}
if(dialogid == 12345)
{
    if(strlen(inputtext))
    {
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "users/%s.ini", sendername);
new File: hFile = fopen(string, io_read);
if (hFile)
{
SendClientMessage(playerid, COLOR_YELLOW, "To korisnicko ime je vec zauzeto, molimo odaberite neko drugo.");
fclose(hFile);
return 1;
}
new tmppass[128];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
//Encrypt(tmppass);
OnPlayerRegister(playerid,tmppass);
}
else
{
new regstring[128];
new regname[128];
GetPlayerName(playerid,regname,sizeof(regname));
format(regstring,sizeof(regstring),"Dobrodosli, %s\nNemate account.\nMolimo registrirajte se:",regname);
ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Registracija",regstring,"Registracija","Izlaz");
}
}
}
else
{
Kick(playerid);
}
return 1;
}


i sad gdje da to ubacim?!

hvala
Poslednja Izmena: Jun 27, 2010, 13:31:25 POSLE PODNE od ExtremePower

nastoe

strlen = Broj upisanih znakova
srtval = Provjera upisanih znakova

npr. ako koristis strlen na deposit dialog komandu i upises 2000 u PAWNCC ce provesti broj 4 jer je samo zbrojio znakove, a ako koristis strval onda ce ti pisati 2000 znaci to ti je ta razlika eto tek toliko da znas

Citat: Luka P. poslato Jun 27, 2010, 13:11:58 POSLE PODNE
public OnPlayerRegister(playerid, password[])
{
  if(IsPlayerConnected(playerid))
  {
        if(strlen(password) < 3) return SendClientMessage(playerid, neka_boja, "lozinka mora bit minimalno 3 znaka");
        new string3[64];
        new playername3[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername3, sizeof(playername3));
        format(string3, sizeof(string3), "users/%s.ini", playername3);
        new File: hFile = fopen(string3, io_write);
        if (hFile)
        {
            strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
            new var[64];
           format(var, 64, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
           PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
           format(var, 64, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
           format(var, 64, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
           format(var, 64, "DonateRank=%d\n",PlayerInfo[playerid][pDonateRank]);fwrite(hFile, var);

.....




ok to sad radi. al kako sad kad napisem pass ispod 3 znaka, i on bi ispise da mora biti minimalno 3 znaka, kad sad napravit da mi ponovno izbaci dialog za registraciju?! hvala


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   new sendername[MAX_PLAYER_NAME];
   new string[128];
   if(response)
   {
      if(dialogid == 12346 || dialogid == 12347)
      {
      if(strlen(inputtext))
          {
            new tmppass[128];
            strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
            //Encrypt(tmppass);
            OnPlayerLogin(playerid,tmppass);
         }
         else
         {
            new loginstring[128];
            new loginname[128];
            GetPlayerName(playerid,loginname,sizeof(loginname));
            format(loginstring,sizeof(loginstring),"POGRESNA LOZINKA\nMolimo unesite tocnu lozinku:",loginname);
            ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Prijava",loginstring,"Prijava","Izlaz");
            gPlayerLogTries[playerid] += 1;
            if(gPlayerLogTries[playerid] == 5) { Ban(playerid); }
         }
      }
      if(dialogid == 12345)
      {
      if(strlen(inputtext))
          {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "users/%s.ini", sendername);
            new File: hFile = fopen(string, io_read);
            if (hFile)
            {
               SendClientMessage(playerid, COLOR_YELLOW, "To korisnicko ime je vec zauzeto, molimo odaberite neko drugo.");
               fclose(hFile);
               return 1;
            }
            new tmppass[128];
            strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
            //Encrypt(tmppass);
            OnPlayerRegister(playerid,tmppass);
         }
         else
         {
            new regstring[128];
            new regname[128];
            GetPlayerName(playerid,regname,sizeof(regname));
            format(regstring,sizeof(regstring),"Dobrodosli, %s\nNemate account.\nMolimo registrirajte se:",regname);
            ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Registracija",regstring,"Registracija","Izlaz");
         }
      }
   }
   else
   {
      Kick(playerid);
   }
   return 1;
}



gdje se tu nalazi taj callback??

za ovo

if ( strlen ( inputtext ) < 8 ) return ShowPlayerDialog( ... );