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

GTA un SA:MP daž ne dažādas pamācības.

Moderator: Moderātori

Post Reply
User avatar
Shetch
Jauniņais
Jauniņais
Posts: 107
Joined: 25 Oct 2010, 01:09
Location: Latvija,Valka

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

Post by Shetch » 07 Mar 2011, 23:19

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
Last edited by Shetch on 10 Feb 2012, 16:37, edited 1 time in total.

HiZ
Jauniņais
Jauniņais
Posts: 4
Joined: 17 Mar 2011, 13:20

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

Post by HiZ » 21 Mar 2011, 07:07

Laba pamācība man noderēja jo veidoju savu serveri... ;)
Image

Disaster[1337]
Rakstnieks
Rakstnieks
Posts: 424
Joined: 09 Jun 2009, 16:39

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

Post by Disaster[1337] » 21 Mar 2011, 09:40

Noderēja,+1 Paldies

p,S jav kur redzēts

User avatar
blossom[eQ]
Censoņa
Censoņa
Posts: 393
Joined: 12 Sep 2008, 14:05
Location: Pagrabs

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

Post by blossom[eQ] » 21 Mar 2011, 14:24

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.
18 beigušies brīdinājumi, 5 beigušies bani

WOH_plovovich.
Censoņa
Censoņa
Posts: 335
Joined: 11 Oct 2010, 19:27
Contact:

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

Post by WOH_plovovich. » 21 Mar 2011, 15:01

Paldies par pamācību,noderēja!
Brīdinājis v6k - Otrdiena Augusts 02, 2011 20:11. Beigsies: Pirmdiena Augusts 15, 2011 210:11
Iemesls: Nav iemesls ,man vnk gribejas uzlikt warning.

User avatar
Disaster
Nelabojams spameris
Nelabojams spameris
Posts: 2194
Joined: 15 Sep 2008, 06:11
Location: Rēzekne

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

Post by Disaster » 21 Mar 2011, 16:28

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.
Image
:) Piedāvāju palīdzēt kādam serverim ar skriptošanu. :)

User avatar
[AoD]Coyote
Nelabojams spameris
Nelabojams spameris
Posts: 1174
Joined: 12 Aug 2009, 12:19
Location: Compton

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

Post by [AoD]Coyote » 21 Mar 2011, 17:39

Paldies,būs jāpamēģina.
Image

User avatar
HUG
Jauniņais
Jauniņais
Posts: 19
Joined: 13 Mar 2011, 09:49

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

Post by HUG » 23 Mar 2011, 14:27

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?
Image

Disaster[1337]
Rakstnieks
Rakstnieks
Posts: 424
Joined: 09 Jun 2009, 16:39

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

Post by Disaster[1337] » 23 Mar 2011, 14:43

Tak iedodat gatavo failu,nevajadzēsies chamaties!
p.S man 26 errorus met!

User avatar
Briesmoniz[TITNS]
Nelabojams spameris
Nelabojams spameris
Posts: 716
Joined: 20 Dec 2008, 23:18

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

Post by Briesmoniz[TITNS] » 23 Mar 2011, 17:24

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."

Goliaats[SR]
Jauniņais
Jauniņais
Posts: 140
Joined: 07 Mar 2011, 18:59
Location: Liepāja.

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

Post by Goliaats[SR] » 23 Mar 2011, 20:56

Žetons tev par uzcītību! ;)

Post Reply