Page 1 of 1

[PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 08 Mar 2011, 00:19
by Shetch
Info: Šajā pamācībā parādīšu jums kā savā serverī izveidot Reģistrēšanos, Ielogošanos, un naudas, levelu saglabāšanu.

Nepaskaidrošu ko katra līnija nozīmē, jo esmu slinks.

Orģinālo pamācību veidoja Cale no sa-mp.com.

Visus erorus vai warnus kurus saņemat lūdzu postojiet šeit.

Tip: Pārliecinaties ka ierakstat visus skriptus taismā rindā, vai arī metīs šādu warnu

Code: Select all

warning 217: loose indentation
DINI: Lūk arī pats dini.inc, jāliek iekš '\pawno\include'
http://dracoblue.net/download/dini-16/35/

Sākam:

1. Atverat PAWNO, un izveidojat jaunu skriptu, spiežot baltās lapas ikonu kreisajā augšējā stūrī.

Image


2. Zem #include liekat #include .
Ja gadijumā jums nav Dini inklūds, tad lejumplādēt to var šeit.

Image

3. Zem #include divas reizes nospiežat pogu Enter, un tur liekat šo skriptu

Code: Select all

// Dialogu ID
#define DIALOG_REG 1
#define DIALOG_LOGIN 2
Image

4. Zem skripta ko tikko ierakstijāt liekat

Code: Select all

enum Player_stats
{
 	Logged,
 	Regged,
	Money,
	Score
}
new Player[MAX_PLAYERS][Player_stats];
Image

5. Tagad zem

Code: Select all

public OnPlayerConnect(playerid)
{
liekat

Code: Select all

// Uzliek spēlētājam visu pa 0
Player[playerid][Logged] = 0;
Player[playerid][Regged] = 0;
Player[playerid][Money] = 0;
Player[playerid][Score] = 0;
un

Code: Select all

	// Parāda dialogus
	new pname[MAX_PLAYERS],accFormat[128];
	GetPlayerName(playerid,pname,sizeof pname);
	format(accFormat,sizeof accFormat,"acc/%s.sav",pname);
	if(fexist(accFormat))
	{
	ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Regg","Ielogojies","Ok","Atcelt");
	}
	else
	{
	ShowPlayerDialog(playerid,DIALOG_REG,1,"Regg","Reģistrējies","Ok","Atcelt");
 }
Image

6. Zem

Code: Select all

public OnPlayerDisconnect(playerid, reason)
{
liekat

Code: Select all

new pname[MAX_PLAYERS],accFormat[128];
	GetPlayerName(playerid,pname,sizeof pname);
	format(accFormat,sizeof accFormat,"acc/%s.sav",pname);
	if(fexist(accFormat))
	{
	Player[playerid][Logged] = 0;
	Player[playerid][Regged] = 1;
	dini_IntSet(accFormat,"Money",GetPlayerMoney(playerid));
	dini_IntSet(accFormat,"Score",GetPlayerScore(playerid));
	}
Image

7. Tad beidzot zem

Code: Select all

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

Code: Select all

new pname[MAX_PLAYERS],accFormat[128];
	GetPlayerName(playerid,pname,sizeof pname);
	format(accFormat,sizeof accFormat,"acc/%s.sav",pname);
	if(response)
	{
	switch(dialogid)
	{
	case DIALOG_LOGIN: // ID Login
	{
	if(!strlen(inputtext))
	{
	ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Regg","Ievadi savu paroli.","Ok","Atcelt");
	return 1;
	}
	if(strcmp(inputtext,dini_Get(accFormat,"Passwort")) == 0)
	{
 	Player[playerid][Regged] = dini_Int(accFormat,"Regged");
 	Player[playerid][Logged] = dini_Int(accFormat,"Logged");
	GivePlayerMoney(playerid,dini_Int(accFormat,"Money"));
	SetPlayerScore(playerid,dini_Int(accFormat,"Score"));
	Player[playerid][Logged] = 1;
	SendClientMessage(playerid,0xFFFFFFFF,"Veiksmīgi esi ielogojies.");
	}
	else
	{
	ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Regg","Nepareiza parole","Ok","Atcelt");
	}
	}
	case DIALOG_REG:
	{
	if(!strlen(inputtext))
	{
	ShowPlayerDialog(playerid,DIALOG_REG,1,"Regg","Pārāk īsa parole","Ok","Atcelt");
	return 1;
	}
	dini_Create(accFormat);
	dini_Set(accFormat,"Passwort",inputtext);
 	Player[playerid][Regged] = dini_Int(accFormat,"Regged");
 	Player[playerid][Logged] = dini_Int(accFormat,"Logged");
	GivePlayerMoney(playerid,dini_Int(accFormat,"Money"));
	SetPlayerScore(playerid,dini_Int(accFormat,"Score"));
	Player[playerid][Regged] = 1;
	ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Regg","Reģistrācija veiksmīga, ielogojies.","Ok","Atcelt");
	}
	}
	}
	else
	{
	switch(dialogid)
	{
	case DIALOG_LOGIN:ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Regg","Ielogojies","Ok","Atcelt");
	case DIALOG_REG:ShowPlayerDialog(playerid,DIALOG_REG,1,"Regg","Reģistrējies","Ok","Atcelt");
	}
	if(!response)
	{
	switch(dialogid)
	{
	case DIALOG_LOGIN:
	{
	Kick(playerid);
	}
	}
	}
	if(!response)
	{
	switch(dialogid)
	{
	case DIALOG_REG:
	{
	Kick(playerid); // Šeit varat likt kas notiks ar spēlētāju ja viņš uzspiedīs " Cancel ".
	}
	}
	}
	}
Šim ^ bilde es domāju nepieciešama nav.

8. Tagad vien atliek doties uz servera Scriptfiles mapi un iekš tās izveidot mapi acc

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 21 Mar 2011, 08:07
by HiZ
Laba pamācība man noderēja jo veidoju savu serveri... ;)

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 21 Mar 2011, 10:40
by Disaster[1337]
Noderēja,+1 Paldies

p,S jav kur redzēts

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 21 Mar 2011, 15:24
by blossom[eQ]
Pamācība samērā sakarīga tikai žēl ka tu pamāci, kā rīkoties ar pašiem sliktākajiem tūļiem. Šis ir pats lēnākais ini saglabāšanas veids, pārējie ir 100x (un es nepārspīlēju) ātrāki.

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 21 Mar 2011, 16:01
by WOH_plovovich.
Paldies par pamācību,noderēja!

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 21 Mar 2011, 17:28
by Disaster
ieliec linku uz Dini inkludu, savādāk iesācēji neatradīs. :P
pašam ganjau nenoderēs, bet kādam citam gan...
cepums par pamācību.

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 21 Mar 2011, 18:39
by [AoD]Coyote
Paldies,būs jāpamēģina.

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 23 Mar 2011, 15:27
by HUG
Man ir diezgan,diezgan daudz kļūdu, lūk tās
  • C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(27) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(39) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(39) : error 029: invalid expression, assumed zero
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(39) : error 004: function "OnPlayerDisconnect" is not implemented
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(40) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(42) : warning 219: local variable "pname" shadows a variable at a preceding level
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(42) : warning 219: local variable "accFormat" shadows a variable at a preceding level
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(43) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(53) : error 029: invalid expression, assumed zero
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(53) : error 004: function "OnDialogResponse" is not implemented
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(54) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(56) : warning 219: local variable "pname" shadows a variable at a preceding level
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(56) : warning 219: local variable "accFormat" shadows a variable at a preceding level
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(57) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(59) : error 017: undefined symbol "response"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(61) : error 017: undefined symbol "dialogid"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(65) : error 017: undefined symbol "inputtext"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(70) : error 017: undefined symbol "inputtext"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(74) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(86) : error 017: undefined symbol "inputtext"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(92) : error 017: undefined symbol "inputtext"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(93) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(95) : warning 217: loose indentation
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(104) : error 017: undefined symbol "dialogid"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(109) : error 017: undefined symbol "response"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(111) : error 017: undefined symbol "dialogid"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(119) : error 017: undefined symbol "response"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(121) : error 017: undefined symbol "dialogid"
    C:Documents and SettingsVitaDesktopSkriptingamemodes
    eg&loggin.pwn(130) : error 030: compound statement not closed at the end of file (started at line 56)
Vai kāds man nevarētu atsūtīt pareizu skriptu, vai pateikt kā šo izlabot?

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 23 Mar 2011, 15:43
by Disaster[1337]
Tak iedodat gatavo failu,nevajadzēsies chamaties!
p.S man 26 errorus met!

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 23 Mar 2011, 18:24
by Briesmoniz[TITNS]
MiXeP man pēc taviem tekstiem vien izklausās, ka tu esi "slikts vārds" es jau tev vienreiz teicu taisi visu pēc pamācības, tak nēsi tāds "slikts vārds."

Re: [PAWNO] Reģistrs, Ielogošanās, Naudas saglabāšana.

Posted: 23 Mar 2011, 21:56
by Goliaats[SR]
Žetons tev par uzcītību! ;)