SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 23/04/2010, 10:14 PM   #1
ipsBruno
Godfather
 
ipsBruno's Avatar
 
Join Date: Apr 2010
Location: Brazil, Caxias RS
Posts: 6,084
Reputation: 545
Default [TUT] Salvamento de Dados

Bom Vou Aqui Postar um Tutorial de Como Salvar/Carregar Algumas Coisas com a Dini
Primeiramente Baixem a Include:
http://dracoblue.net/download-release/35/dini_1_6.zip
Adicionem Dini.INC na Pasta PAWNO/INCLUDES


Agora Vamos "Codar"
Primeiramente Ao Topo do GM:

pawn Code:
#include <Dini>
[b]_________________________
Agora Vamos Algums Códigos
*Salvar Money
*Salvar Skin
*Salvar Score
*Salvar Armas
*Salvar Vida
*Salvar Colete
*Salvar Nível Procurado
*Salvar Cor do Player
*Salvar IP (para Admin Ver IP)

__________________________________________________ _____________________________
[size=15pt]Salvar Skins
Em OnPlayerSpawn:
pawn Code:
if(dini_Isset("skins.ini",PlayerName(playerid))) SetPlayerSkin(playerid,dini_Int("skins.ini",PlayerName(playerid)));
em OnPlayerDisconnect:
pawn Code:
dini_IntSet("skins.ini",PlayerName(playerid),GetPlayerSkin(playerid));
Em OnGameModeInit:
pawn Code:
if(!fexist("skins.ini")) dini_Create("skins.ini");

[size=15pt]Salvar Money

Em OnPlayerConnect:
pawn Code:
if(dini_Isset("dinheiro.ini",PlayerName(playerid))) GivePlayerMoney(playerid,dini_Int("dinheiro.ini",PlayerName(playerid)));

em OnPlayerDisconnect:
pawn Code:
dini_IntSet("dinheiro.ini",PlayerName(playerid),GetPlayerMoney(playerid));

Em OnGameModeInit:[b]
pawn Code:
if(!fexist("dinheiro.ini")) dini_Create("dinheiro.ini");

[size=15pt]Salvar Score
Em OnPlayerConnect:
pawn Code:
if(dini_Isset("score.ini",PlayerName(playerid))) SetPlayerScore(playerid,dini_Int("score.ini",PlayerName(playerid)));

em OnPlayerDisconnect:
pawn Code:
dini_IntSet("score.ini",PlayerName(playerid),GetPlayerScore(playerid));

Em OnGameModeInit:[b]
pawn Code:
if(!fexist("score.ini")) dini_Create("score.ini");

[size=15pt]Salvar Armas

Em OnPlayerSpawn:
pawn Code:
if(dini_Isset("Weapon.ini",PlayerName(playerid))) GivePlayerWeapon(playerid,dini_Int("Weapon.ini",PlayerName(playerid)));



em OnPlayerDisconnect:
pawn Code:
dini_IntSet("Weapon.ini",PlayerName(playerid),GetPlayerWeapon(playerid));

Em OnGameModeInit:[b]
pawn Code:
if(!fexist("Weapon.ini")) dini_Create("Weapon.ini");
[size=15pt]Salvar Vida

Em OnPlayerSpawn:
pawn Code:
if(dini_Isset("Health.ini",PlayerName(playerid))) SetPlayerHealth(playerid,dini_Int("Health.ini",PlayerName(playerid)));

em OnPlayerDisconnect:
pawn Code:
dini_IntSet("Health.ini",PlayerName(playerid),GetPlayerHealth(playerid));

Em OnGameModeInit:[b]
pawn Code:
if(!fexist("Health.ini")) dini_Create("Health.ini");

[size=15pt]Salvar Colete

Em OnPlayerSpawn:
pawn Code:
if(dini_Isset("Armour.ini",PlayerName(playerid))) SetPlayerArmour(playerid,dini_Int("Armour.ini",PlayerName(playerid)));

em OnPlayerDisconnect:
pawn Code:
dini_IntSet("Armour.ini",PlayerName(playerid),GetPlayerArmour(playerid));

Em OnGameModeInit:[b]
pawn Code:
if(!fexist("Armour.ini")) dini_Create("Armour.ini");


[size=15pt]Salvar Nível de Procurado

Em OnPlayerSpawn:
pawn Code:
if(dini_Isset("WantedLevel .ini",PlayerName(playerid))) SetPlayerWantedLevel (playerid,dini_Int("WantedLevel.ini",PlayerName(playerid)));

em OnPlayerDisconnect:
pawn Code:
dini_IntSet("WantedLevel.ini",PlayerName(playerid),GetPlayerWantedLevel (playerid));

Em OnGameModeInit:[b]
pawn Code:
if(!fexist("WantedLevel.ini")) dini_Create("WantedLevel .ini");

[size=15pt]Salvar Cor do Player

Em OnPlayerConnect:
pawn Code:
if(dini_Isset("Color.ini",PlayerName(playerid))) SetPlayerColor(playerid,dini_Int("Color.ini",PlayerName(playerid)));

em OnPlayerDisconnect:
pawn Code:
dini_IntSet("Color.ini",PlayerName(playerid),GetPlayerColor (playerid));

Em OnGameModeInit:[b]
pawn Code:
if(!fexist("Color.ini")) dini_Create("Color .ini");

[size=15pt]Salvar IP do Player

em OnPlayerDisconnect:
pawn Code:
dini_IntSet("IPPlayers.ini",PlayerName(playerid),GetPlayerIp(playerid));

Em OnGameModeInit:[b]
pawn Code:
if(!fexist("IPPlayers.ini")) dini_Create("IPPlayers");

Resumindo:
Repararam Que Todas Função São as Mesmas? Funciona Assim

Função:
pawn Code:
dini_IntSet("NOMEDOARQUIVO");
Ira "Salvar" o tal Arquivo

Função:
pawn Code:
dini_Create("NOMEDOARQUIVO");
Ira "Criar" o tal Arquivo

Função:
pawn Code:
dini_Isset("NOMEDORARQUIVO");
ou
pawn Code:
dini_Int("NOMEDOARQUIVO");
Irá "Carregar" o Arquivo"

Então é Assim
GET-CRIAR-SALVAR-CARREGAR-SET


Não Testei Tudo xD

Antes que Me Esquece Adicionar :
Final do GM ou Abaixo das New (inicio GM)
pawn Code:
stock PlayerName(playerid)
{
new Name[MAX_PLAYERS];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}

Para Não Dar "Undefined PlayerName"
__________________
https://github.com/ipsBruno
ipsBruno is offline   Reply With Quote
Old 23/04/2010, 10:25 PM   #2
russo666
High-roller
 
Join Date: Sep 2007
Posts: 1,007
Reputation: 5
Default Re: [TUT] Salvamento de Dados

Bom tutorial drakon. Mas também podias utilizar um único .ini para cada jogador e com tudo lá dentro.
russo666 is offline   Reply With Quote
Old 23/04/2010, 10:26 PM   #3
andmeida10
High-roller
 
andmeida10's Avatar
 
Join Date: Jan 2010
Location: Aveiro - Portugal
Posts: 1,202
Reputation: 31
Default Re: [TUT] Salvamento de Dados

isso é codigo, e não Tuto, mas ta bom... so mudar a TAG
__________________
andmeida10 is offline   Reply With Quote
Old 23/04/2010, 10:27 PM   #4
Ambrósio
Huge Clucker
 
Ambrósio's Avatar
 
Join Date: Dec 2009
Location: Foz do Iguaçu - Brasil
Posts: 447
Reputation: 20
Default Re: [TUT] Salvamento de Dados

Muito bom, parabens.
__________________
Ambrósio is offline   Reply With Quote
Old 23/04/2010, 10:31 PM   #5
ipsBruno
Godfather
 
ipsBruno's Avatar
 
Join Date: Apr 2010
Location: Brazil, Caxias RS
Posts: 6,084
Reputation: 545
Default Re: [TUT] Salvamento de Dados

Antes que Me Esquece Adicionar :
Final do GM ou Abaixo das New (inicio GM)
pawn Code:
PlayerName(playerid) {
new PlayerName[MAX_PLAYERS];
GetPlayerName(playerid, PlayerName, MAX_PLAYERS);
return PlayerName;
}

Para Não Dar "Undefined PlayerName"
__________________
https://github.com/ipsBruno
ipsBruno is offline   Reply With Quote
Old 23/04/2010, 10:34 PM   #6
andmeida10
High-roller
 
andmeida10's Avatar
 
Join Date: Jan 2010
Location: Aveiro - Portugal
Posts: 1,202
Reputation: 31
Default Re: [TUT] Salvamento de Dados

Quote:
Originally Posted by DraKoN
Antes que Me Esquece Adicionar :
Final do GM ou Abaixo das New (inicio GM)
PlayerName(playerid) {
new PlayerName[MAX_PLAYERS];
GetPlayerName(playerid, NPlayerName, MAX_PLAYERS);
return PlayerName;
}[/pawn]

Para Não Dar "Undefined PlayerName"
poem isso la no 1º post mesmo..
__________________
andmeida10 is offline   Reply With Quote
Old 23/04/2010, 10:47 PM   #7
tshadow
Huge Clucker
 
Join Date: Jan 2010
Posts: 434
Reputation: 0
Default Re: [TUT] Salvamento de Dados

ta fixe
__________________
tshadow is offline   Reply With Quote
Old 23/04/2010, 10:49 PM   #8
andmeida10
High-roller
 
andmeida10's Avatar
 
Join Date: Jan 2010
Location: Aveiro - Portugal
Posts: 1,202
Reputation: 31
Default Re: [TUT] Salvamento de Dados

Quote:
Originally Posted by tshadow
eu fiz um Filterscripte assim
pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <Dini>

#if defined FILTERSCRIPT

#pragma unused PlayerName

public OnFilterScriptInit()
{
    if(!fexist("score.ini")) dini_Create("score.ini");
    if(!fexist("Weapon.ini")) dini_Create("Weapon.ini");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{

}

#endif

public OnPlayerConnect(playerid)
{
  if(dini_Isset("Weapon.ini",PlayerName(playerid))) GivePlayerWeapon(playerid,dini_Int("Weapon.ini",PlayerName(playerid)));
    if(dini_Isset("score.ini",PlayerName(playerid))) SetPlayerScore(playerid,dini_Int("score.ini",PlayerName(playerid)));
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  dini_IntSet("score.ini",PlayerName(playerid),GetPlayerScore(playerid));
    dini_IntSet("Weapon.ini",PlayerName(playerid),GetPlayerWeapon(playerid));
    return 1;
}

Code:
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(35) : error 017: undefined symbol "PlayerName"
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(35) : error 017: undefined symbol "PlayerName"
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(36) : error 017: undefined symbol "PlayerName"
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(36) : error 017: undefined symbol "PlayerName"
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(42) : error 017: undefined symbol "PlayerName"
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(43) : error 017: undefined symbol "PlayerName"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


6 Errors.


ACORDA PA VIDA:


Quote:
Originally Posted by DraKoN
Antes que Me Esquece Adicionar :
Final do GM ou Abaixo das New (inicio GM)
pawn Code:
PlayerName(playerid) {
new PlayerName[MAX_PLAYERS];
GetPlayerName(playerid, NPlayerName, MAX_PLAYERS);
return PlayerName;
}

Para Não Dar "Undefined PlayerName"
__________________
andmeida10 is offline   Reply With Quote
Old 23/04/2010, 10:50 PM   #9
tshadow
Huge Clucker
 
Join Date: Jan 2010
Posts: 434
Reputation: 0
Default Re: [TUT] Salvamento de Dados

Code:
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(35) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(48) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(49) : error 017: undefined symbol "NPlayerName"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
continua a dar estes erros
__________________
tshadow is offline   Reply With Quote
Old 23/04/2010, 10:52 PM   #10
andmeida10
High-roller
 
andmeida10's Avatar
 
Join Date: Jan 2010
Location: Aveiro - Portugal
Posts: 1,202
Reputation: 31
Default Re: [TUT] Salvamento de Dados

Quote:
Originally Posted by tshadow
Code:
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(35) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(48) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\server\Server\filterscripts\Set.pwn(49) : error 017: undefined symbol "NPlayerName"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
continua a dar estes erros
posta as linhas, não??s
__________________
andmeida10 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] [INC] Protioso Gerenciamento de Dados (PGD) 1.3F2 (06/12/09) [VGS]Protioso Lançamentos/Releases 53 11/11/2012 10:21 PM
[PEDIDO]Sistema de salvamento de level. Clansman_PKS Português/Portuguese 2 23/01/2012 01:08 PM
[ajuda]salvamento de gang [BR]JD Português/Portuguese 3 10/05/2010 09:13 PM
[DUV] Salvamento de SCORE COM DINI BurrodaZero Português/Portuguese 6 20/04/2010 05:35 PM


All times are GMT. The time now is 08:45 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.