[A-System] Random code for login help.
#1

Hey guys. I made random code number for admin login, and the problem is that randomator generates just one number instead of 5 field.

CODE:

PHP код:
new randomkod random(9);
format(poruka,sizeof(poruka),"{FFFFFF}Cestitamo. Postavljani ste na administracijsku poziciju levela: "COLOR_WG"%d.{FFFFFF}\nTitulu vam je dodjelio vlasnik"COLOR_ZUTA" %s.\n{FFFFFF} Zelimo vam svu srecu u nasem ADMIN teamu.\n\n"COLOR_CRVENA"[VAZNO]:{FFFFFF}\nDolje navedeni kod zapisite/zapamtite jer cete prilikom logiranja morati to upisati.\n%d%d%d%d%d",level,name2,KOD);
            
strcat(statut,poruka);
PlayerInfo[id][pKod] = format(KOD,sizeof(KOD),"%d%d%d%d%d",randomkod,randomkod,randomkod,randomkod,randomkod); 
Should i use "KOD" five times at the end ?
Reply
#2

Quote:
Originally Posted by NoDi522
Посмотреть сообщение
Hey guys. I made random code number for admin login, and the problem is that randomator generates just one number instead of 5 field.

CODE:

PHP код:
new randomkod random(9);
format(poruka,sizeof(poruka),"{FFFFFF}Cestitamo. Postavljani ste na administracijsku poziciju levela: "COLOR_WG"%d.{FFFFFF}\nTitulu vam je dodjelio vlasnik"COLOR_ZUTA" %s.\n{FFFFFF} Zelimo vam svu srecu u nasem ADMIN teamu.\n\n"COLOR_CRVENA"[VAZNO]:{FFFFFF}\nDolje navedeni kod zapisite/zapamtite jer cete prilikom logiranja morati to upisati.\n%d%d%d%d%d",level,name2,KOD);
            
strcat(statut,poruka);
PlayerInfo[id][pKod] = format(KOD,sizeof(KOD),"%d%d%d%d%d",randomkod,randomkod,randomkod,randomkod,randomkod); 
Should i use "KOD" five times at the end ?
You are using the same random for all kods, you should make a different random for every single one.

PHP код:
format(poruka,sizeof(poruka),"{FFFFFF}Cestitamo. Postavljani ste na administracijsku poziciju levela: "COLOR_WG"%d.{FFFFFF}\nTitulu vam je dodjelio vlasnik"COLOR_ZUTA" %s.\n{FFFFFF} Zelimo vam svu srecu u nasem ADMIN teamu.\n\n"COLOR_CRVENA"[VAZNO]:{FFFFFF}\nDolje navedeni kod zapisite/zapamtite jer cete prilikom logiranja morati to upisati.\n%d%d%d%d%d",level,name2,KOD);
            
strcat(statut,poruka);
PlayerInfo[id][pKod] = format(KOD,sizeof(KOD),"%d%d%d%d%d",random(9),random(9),random(9),random(9),random(9)); 
Reply
#3

Hm nothing changed i just got one field.
Here's my code:

PHP код:
CMD:makeadmin(playerid,params[])
{
    new 
KOD[256],id,level,msg[128],msg3[256],name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME];
    if(!
IsPlayerConnected(playerid)) return SendClientMessage(playerid0xFF0000"{F81414}Greska:{FFFFFF} Niste ulogirani na server.");
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF0000"{F81414}Greska:{FFFFFF} Nemate dozvolu za tu komandu.");
    if(
sscanf(params,"ud",id,level)) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Syntax |{FFFFFF} /makeadmin [ID/Ime] [Level]");
    if(
level 5) return SendClientMessage(playerid0xFF0000,"{F81414}Greska:{FFFFFF} Maximalan level admin za dodijelu je{00C0FF} 5.");
    
GetPlayerName(id,name,sizeof(name));
    
GetPlayerName(playerid,name2,sizeof(name2));
    
    new 
poruka[512],statut[64];
    new 
randomkod random(9);
    
    
format(poruka,sizeof(poruka),"{FFFFFF}Cestitamo. Postavljani ste na administracijsku poziciju levela: "COLOR_WG"%d.{FFFFFF}\nTitulu vam je dodjelio vlasnik"COLOR_ZUTA" %s.\n{FFFFFF} Zelimo vam svu srecu u nasem ADMIN teamu.\n\n"COLOR_CRVENA"[VAZNO]:{FFFFFF}\nDolje navedeni kod zapisite/zapamtite jer cete prilikom logiranja morati to upisati.\n%d%d%d%d%d",level,name2,random(9),random(9),random(9),random(9),random(9));
     
strcat(statut,poruka);
    
ShowPlayerDialog(id,DIALOG_ADMIN_CONG,DIALOG_STYLE_MSGBOX,""COLOR_ZUTA"AdminTeam",poruka,"Uredu","");
    
/* Proredak */
    
format(msg,sizeof(msg),""COLOR_WG"WG:{FFFFFF} Postavili ste admina igracu{FFF1AF} %s {FFFFFF}na levelu:{FFF1AF} %d"name,level);
    
SendClientMessage(playerid,0xFFFFFF,msg);
    
format(msg3,sizeof(msg3),""COLOR_CRVENA"[ ACC ]:{FFFFFF} %s je postavio admina %s na levelu"COLOR_WG" %d",name2,name,level);
    
SendAdminMessage(-1,msg3);
            
    
PlayerInfo[id][pAdministrator] = level;
    
PlayerInfo[id][pKod] = format(KOD,sizeof(KOD),"%d%d%d%d%d",random(9),random(9),random(9),random(9),random(9));
    new 
INI:File INI_Open(UserPath(id));
    
INI_SetTag(File,"data");
    
INI_WriteInt(File,"Administrator",PlayerInfo[id][pAdministrator]);
    
INI_WriteInt(File,"Kod",PlayerInfo[id][pKod]);
    
INI_Close(File);
    return 
1;

Reply
#4

If you want a random 5 digit number you don't have to call random 5 times ... That's just silly. Simply use random(100000) to generate a number between 0 and 99999. Then display using "%05d". And since "Kod" (whatever that may mean) appears to be an integer, all you need is:
pawn Код:
PlayerInfo[id][pKod] = random(100000)
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
If you want a random 5 digit number you don't have to call random 5 times ... That's just silly. Simply use random(100000) to generate a number between 0 and 99999. Then display using "%05d". And since "Kod" (whatever that may mean) appears to be an integer, all you need is:
pawn Код:
PlayerInfo[id][pKod] = random(100000)
Thank you.
Reply
#6

nono, using that random it could give out 1 as "kod" as well, try using this;

Код:
RandomEx(min, max) // By ******
{
    return random(max - min) + min;
}

PlayerInfo[id][pKod] = RandomEx(10000, 99999);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)