[TUT] REGISTER/LOGIN SISTEM [sa TextDrawima]

Započeo Kunnaâ„¢, Januar 09, 2014, 02:50:13 PRE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Pozdrav ovo je unikatni Reg/log Sistem sa TextDrawima by KuNNa
PA DA KRENEMO :)
1. Korak
Da bi vam sve radilo potreban je YSI (Nadam se da svi znate kako instalirati YSI ko nezna neka mi se javi na PM )
NOVA VERZIJA YSI-a :
https://github.com/Y-Less/YSI/archive/master.zip
Prvo Definirate Include YSI to izgleda ovako

#include <YSI\y_ini>

2. Korak
Zatim definirat cemo dialoge.Dobro obratite paznju da nemate slucajo gdje definiran sa 1 i 2 dialog.
To bi ovako izgledalo


#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2


3. Korak

Definisite 'PATH',Ovo vam sluzi da bi vam se accounti spasavali
Morate u Scriptfiles napraviti Foleder pod nazivom "Korisnici"


#define PATH "/Korisnici/%s.ini"

4. Korak
Posto je ovo Reg/Log sistem sa TextDrawima dodajte ovo.

new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;
new Text:Textdraw3;
new Text:Textdraw4;
new Text:Textdraw5;
new Text:Textdraw6;
new Text:Textdraw7;
new Text:Textdraw8;
new Text:Textdraw9;
new Text:Textdraw10;


5. Korak
Ako u kojem slucaju nemate enum pinfo dodajte ovako

enum pInfo
{
pLozinka,
pNovac,
pAdmin,
pUbistva,
pSmrti
};
new PlayerInfo[MAX_PLAYERS][pInfo];


Ako ga vec imate onda dodajte samo ove varijable


   pLozinka,
pNovac,
pAdmin,
pUbistva,
pSmrti


6. Korak
Sada cemo napraviti funkciju koja ce vam Ucitavati podatke


forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Lozinka",PlayerInfo[playerid][pLozinka]);
INI_Int("Novac",PlayerInfo[playerid][pNovac]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Ubistva",PlayerInfo[playerid][pUbistva]);
INI_Int("Smrti",PlayerInfo[playerid][pSmrti]);
return 1;
}

7. Korak
Dodajte ovaj stock


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

8. Korak
Ovo trebate dodati ispod Stocka UserPath
Ovo vam sluzi za hashovanje sifri,Ako bi vam kojim slucajem provalili u GP nebi mogli vidjeti sifre vasih Igraca.


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;
}

9. Korak
Pod onplayerspawn dodajte ovo

        TextDrawHideForPlayer(playerid,Textdraw0);
TextDrawHideForPlayer(playerid,Textdraw1);
TextDrawHideForPlayer(playerid,Textdraw2);
TextDrawHideForPlayer(playerid,Textdraw3);
TextDrawHideForPlayer(playerid,Textdraw4);
TextDrawHideForPlayer(playerid,Textdraw5);
TextDrawHideForPlayer(playerid,Textdraw6);
TextDrawHideForPlayer(playerid,Textdraw7);
TextDrawHideForPlayer(playerid,Textdraw8);
TextDrawHideForPlayer(playerid,Textdraw9);
TextDrawHideForPlayer(playerid,Textdraw10);

   
10. Korak
Zatim pod OnPlayerRequestClass dodajte

SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);// Ovde stavite koordinate svog spawna
SpawnPlayer(playerid);

11.Korak
Zatim pod ongamemodeinit dodajte ovo

Textdraw0 = TextDrawCreate(644.000000, 2.000000, "_");
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 12.400003);
TextDrawColor(Textdraw0, -1);
TextDrawSetOutline(Textdraw0, 0);
TextDrawSetProportional(Textdraw0, 1);
TextDrawSetShadow(Textdraw0, 1);
TextDrawUseBox(Textdraw0, 1);
TextDrawBoxColor(Textdraw0, 255);
TextDrawTextSize(Textdraw0, -3.000000, 0.000000);

Textdraw1 = TextDrawCreate(644.000000, 334.000000, "_");
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 1);
TextDrawLetterSize(Textdraw1, 0.500000, 12.400003);
TextDrawColor(Textdraw1, -1);
TextDrawSetOutline(Textdraw1, 0);
TextDrawSetProportional(Textdraw1, 1);
TextDrawSetShadow(Textdraw1, 1);
TextDrawUseBox(Textdraw1, 1);
TextDrawBoxColor(Textdraw1, 255);
TextDrawTextSize(Textdraw1, -3.000000, 0.000000);

Textdraw2 = TextDrawCreate(229.000000, 40.000000, "KUNNA");
TextDrawBackgroundColor(Textdraw2, 255);
TextDrawFont(Textdraw2, 2);
TextDrawLetterSize(Textdraw2, 0.480000, 3.299998);
TextDrawColor(Textdraw2, -65281);
TextDrawSetOutline(Textdraw2, 1);
TextDrawSetProportional(Textdraw2, 1);

Textdraw3 = TextDrawCreate(266.000000, 344.000000, "Skripter: KuNNa");
TextDrawBackgroundColor(Textdraw3, 255);
TextDrawFont(Textdraw3, 1);
TextDrawLetterSize(Textdraw3, 0.330000, 2.799999);
TextDrawColor(Textdraw3, -16776961);
TextDrawSetOutline(Textdraw3, 1);
TextDrawSetProportional(Textdraw3, 1);

Textdraw4 = TextDrawCreate(271.000000, 373.000000, "Maper: KuNNa");
TextDrawBackgroundColor(Textdraw4, 255);
TextDrawFont(Textdraw4, 1);
TextDrawLetterSize(Textdraw4, 0.330000, 2.799999);
TextDrawColor(Textdraw4, -65281);
TextDrawSetOutline(Textdraw4, 1);
TextDrawSetProportional(Textdraw4, 1);

Textdraw5 = TextDrawCreate(242.000000, 406.000000, "WWW.BALKAN-SAMP.COM");
TextDrawBackgroundColor(Textdraw5, 255);
TextDrawFont(Textdraw5, 3);
TextDrawLetterSize(Textdraw5, 0.330000, 2.799999);
TextDrawColor(Textdraw5, -16776961);
TextDrawSetOutline(Textdraw5, 1);
TextDrawSetProportional(Textdraw5, 1);

Textdraw6 = TextDrawCreate(366.000000, 25.000000, "v0.0.1");
TextDrawBackgroundColor(Textdraw6, 255);
TextDrawFont(Textdraw6, 2);
TextDrawLetterSize(Textdraw6, 0.330000, 2.799999);
TextDrawColor(Textdraw6, -65281);
TextDrawSetOutline(Textdraw6, 1);
TextDrawSetProportional(Textdraw6, 1);

Textdraw7 = TextDrawCreate(302.000000, 40.000000, "ROLEPLAY");
TextDrawBackgroundColor(Textdraw7, 255);
TextDrawFont(Textdraw7, 2);
TextDrawLetterSize(Textdraw7, 0.480000, 3.299998);
TextDrawColor(Textdraw7, -16776961);
TextDrawSetOutline(Textdraw7, 1);
TextDrawSetProportional(Textdraw7, 1);

Textdraw8 = TextDrawCreate(35.000000, 10.000000, "dobrodosli");
TextDrawBackgroundColor(Textdraw8, 255);
TextDrawFont(Textdraw8, 2);
TextDrawLetterSize(Textdraw8, 0.480000, 3.299998);
TextDrawColor(Textdraw8, -65281);
TextDrawSetOutline(Textdraw8, 1);
TextDrawSetProportional(Textdraw8, 1);

Textdraw9 = TextDrawCreate(178.000000, 10.000000, "na");
TextDrawBackgroundColor(Textdraw9, 255);
TextDrawFont(Textdraw9, 2);
TextDrawLetterSize(Textdraw9, 0.480000, 3.299998);
TextDrawColor(Textdraw9, -16776961);
TextDrawSetOutline(Textdraw9, 1);
TextDrawSetProportional(Textdraw9, 1);

Textdraw10 = TextDrawCreate(556.000000, 425.000000, "COPYRIGHT (C) 2014");
TextDrawBackgroundColor(Textdraw10, 255);
TextDrawFont(Textdraw10, 2);
TextDrawLetterSize(Textdraw10, 0.200000, 2.799999);
TextDrawColor(Textdraw10, -16776961);
TextDrawSetOutline(Textdraw10, 1);
TextDrawSetProportional(Textdraw10, 1);

12. Korak
Zatim pod onplayerconnect dodajte ovo


   if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Prijavljivanje","Ukucajte lozinku da bi se ulogovali","Prijavi se","Izadji");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Registracija","Ukucajte lozinku da bi se registrovali.","Registruj se","Izadji");
}

13. Korak
pod OnDialogResponse dodajte


    switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registracija","Ukucali ste pogresnu lozinku.\nUkucajte ispravnu lozinku da bi se registrovali.","Registruj se","Izadji");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Lozinka",udb_hash(inputtext));
INI_WriteInt(File,"Novac",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Ubistva",0);
INI_WriteInt(File,"Smrti",0);
INI_Close(File);
TextDrawShowForPlayer(playerid,Textdraw0);
TextDrawShowForPlayer(playerid,Textdraw1);
TextDrawShowForPlayer(playerid,Textdraw2);
TextDrawShowForPlayer(playerid,Textdraw3);
TextDrawShowForPlayer(playerid,Textdraw4);
TextDrawShowForPlayer(playerid,Textdraw5);
TextDrawShowForPlayer(playerid,Textdraw6);
TextDrawShowForPlayer(playerid,Textdraw7);
TextDrawShowForPlayer(playerid,Textdraw8);
TextDrawShowForPlayer(playerid,Textdraw9);
TextDrawShowForPlayer(playerid,Textdraw10);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);// Ovde stavite koordinate svog spawna
SpawnPlayer(playerid);
}
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(response)
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pLozinka])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pNovac]);
TextDrawShowForPlayer(playerid,Textdraw0);
TextDrawShowForPlayer(playerid,Textdraw1);
TextDrawShowForPlayer(playerid,Textdraw2);
TextDrawShowForPlayer(playerid,Textdraw3);
TextDrawShowForPlayer(playerid,Textdraw4);
TextDrawShowForPlayer(playerid,Textdraw5);
TextDrawShowForPlayer(playerid,Textdraw6);
TextDrawShowForPlayer(playerid,Textdraw7);
TextDrawShowForPlayer(playerid,Textdraw10);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Prijavljivanje","Ukucali ste pogresnu lozinku.\nUkucajte ispravnu lozinku da bi se ulogovali.","Prijavi se","Izadji");
}
return 1;
}
}
}

14. Korak
pod OnPlayerDisconnect dodajte ovo

        TextDrawHideForPlayer(playerid,Textdraw0);
TextDrawHideForPlayer(playerid,Textdraw1);
TextDrawHideForPlayer(playerid,Textdraw2);
TextDrawHideForPlayer(playerid,Textdraw3);
TextDrawHideForPlayer(playerid,Textdraw4);
TextDrawHideForPlayer(playerid,Textdraw5);
TextDrawHideForPlayer(playerid,Textdraw6);
TextDrawHideForPlayer(playerid,Textdraw7);
TextDrawHideForPlayer(playerid,Textdraw8);
TextDrawHideForPlayer(playerid,Textdraw9);
TextDrawHideForPlayer(playerid,Textdraw10);

Pa onda ovo
    new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Novac",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Ubistva",PlayerInfo[playerid][pUbistva]);
INI_WriteInt(File,"Smrti",PlayerInfo[playerid][pSmrti]);
INI_Close(File);


15. Korak
pod OnPlayerDeath dodajte


PlayerInfo[killerid][pUbistva]++;
PlayerInfo[playerid][pSmrti]++;



To je bilo to nadam se da ste shvatili,ako imate nesto da pitate PM
Ako vam je nejasna neka linija neki kod PM / SKYP.
Poslednja Izmena: Januar 09, 2014, 03:00:59 PRE PODNE od KuNNaâ„¢



Fino uraÄ'eno, objaÅ¡njeno. Pohvale, nadam se da će nekome zatrebati. 

tut je jednostavan ali ce pomoci mnogima pohvale.
69


dobro je


[FS]Rent
[FS] Vremenska prognoza
[TuT] PayDay
[TuT]PayDay sistem[UPDATED]
Moja Biografija

Respect:Mr.Gagi,FlasH,Streetboy,David (Sabljak) A.k.A SABO(T)
ÄŒovjek nije stvoren za poraze, moze biti unisten, ali ne i pobjeÄ'en!

mozda da si sliku dao pocetnicima ? :)
TUTORIALI :

Big Respect: " C++ "  (Majke mi nepamtim boljeg moderatora pawno sekcije, dada Blaeks je nekad bio :P)

Hvala svima.

Citatmozda da si sliku dao pocetnicima ?
Ako stignem nekad dobit ce jer imam previse posla

a i nisi bas nesto dobro objasnio deckima, za one koji tek pocinjeju "Dodaj ovo" "Ovo tu" i tako te :)
TUTORIALI :

Big Respect: " C++ "  (Majke mi nepamtim boljeg moderatora pawno sekcije, dada Blaeks je nekad bio :P)

CitatAko vam je nejasna neka linija neki kod PM / SKYP.
nisi sve procitao.Ko ima zelju da mu obasnim  skyp/pm
Poslednja Izmena: Januar 10, 2014, 01:22:33 PRE PODNE od KuNNaâ„¢

Pohvala brate za TuT i ak moze odg. na PM
Respect: â–... â–† â–ˆ Rudimental â–ˆ â–† â–..., Denis_Lapi, Blaeks, Ñ"ÊŸÑ"ɱÑ"ÆžÏ,,Ä...ÊŸ, Bryant., TiXoR_,   #old_school



Fin tutorijal..Mislim samo da si mogao textdraw-ove da spremis kao stock..Tako bi naucili nesto i tome

[FS] Bank Sistem
[TuT] Array Sistem (Napredna)


"Pa krenite na mene i provesce te se super ko kapetan Kuka kada levom brise dupe"

www.denis-lapi.com

Hvala vam svima.
Mislim da ta ideja sa stockom bi bila prekomlikovana za pocetnike.Ako ima neko zelju da to uradi neka napravi tutorijal pa neka objasni ;)