[Tutorial] Criando Sistema de Salvamento Simples!
#1

Bom Galera vou tentar ser o mais breve possivel!
pawn Код:
//PARA COMEЗAR VAMOS POR NO TOPO DO GAMEMODE AS INCLUDES NECESSARIAS..
#include <a_samp> // TODO SCRIPT DEVE TER =D
#include <DOF2>   // NOSSO SISTEMA DE SALVAMENTO SERA COMPLETAMENTE EM DOF2..

//BOM, AGORA VAMOS VER OQUE IREMOS SALVAR...
//~~SKIN
//ACHO QUE JA ESTA BOM POIS Й SO UM SIMPLES TUTORIAL! ^^
//AGORA VAMOS CRIAR UMA ENUM (POIS NГO LEMBRO O NOME CORRETO)
//E UMA NEW (TBM NГO LEMBRO O NOME CORRETO!)
enum pInfo // CRIA A ENUM
{//AKI ABRIMOS A ENUM(ACHO QUE Й NE ^^)
    pSkin, //AQUI Й A SKIN DГ
};//AKI FEXAMOS A ENUM '-'
//AGORA VAMOS CRIAR A NEW PLAYERINFO (ISSO IRA NOS AJUDAR MAIS PRA FRENTE...)
new PlayerInfo[MAX_PLAYERS][pInfo];
//BOM, PARA QUANDO O PLAYER LOGAR E VERIFICAR SE OS DADOS EXISTEM OU NГO VAMOS
//USAR A FUNЗГO DA DOF2 CHAMADAD "DOF2_FileExists" ELA VERIFICA NA PASTA SCRIPTFILES
//SE O ARQUIVO EXISTE OU NГO!
//PS: ISSO TEM QUE SER FEITO NA CALLBACK ONPLAYERCONNECT!!
public OnPlayerConnect(playerid)
{
//VAMOS CRIAR UMA NEW CHAMADA FILE QUE SERVE PARA DEFINIR O ARQUIVO..
//E OUTRA CHAMADA SENDERNAME PARA PEGAR O NOME DO PLAYER!
    new File[70], sendername[MAX_PLAYER_NAME];
//VAMO USAR AGORA A FUNЗГO GETPLAYERNAME Para saber mais sobre ela pode ler em
//https://sampwiki.blast.hk/wiki/GetPlayerName
    GetPlayerName(playerid, sendername, sizeof(sendername));
//E TAMBEM UMA FORMAT PARA "CRIAR" OU "CARREGAR" OS DADOS!
    format(File, sizeof(File), "%s.ini", sendername); //VAI LER O ARQUIVO DIRETAMENTE NA PASTA SCRIPTFILES!
//AGORA VAMOS UTILIZAR A DOF2_FILEEXISTS QUE CITEI ALI EM CIMA '-'
    if(DOF2_FileExists(File))
    {
//VAMOS USAR LOGO ABAIXO A FUNЗГO "DOF2_GetInt" QUE CARREGA O DADO DO PLAYER
//CITADO LOGO A FRENTE DA FUNЗAO. E TAMBEM VAMOS UTILIZAR A NEW QUE CRIAMOS NO COMEЗO
//LEMBRA?? "PlayerInfo" ^^
        PlayerInfo[playerid][pSkin] = DOF2_GetInt(File, "Skin");
//AGORA VAMOS ENVIAR UMA MENSAGEM PRO PLAYER DIZENDO QUE OS ARQUIVOS FORAM CARREGADOS!
        SendClientMessage(playerid, -1, "Arquivos Carregados!");
    }
    else// ACIMA E SE O ARQUIVO COM O NOME DO PLAYER JБ EXISTIR.. AGORA VAMOS CRIAR CASO NГO EXISTA
    {
//AQUI VAMOS USAR ABAIXO AS FUNЗХES DA DOF2:
//DOF2_CreateFile ~~ CRIA O ARQUIVO COMO O PROPRIO NOME DIZ..
//DOF2_SetInt ~~ SETA OQUE TA ESCRITO LOGO A FRENTE DELE DENTRO NO ARQUIVO CRIADO PELA FUNЗГO ACIMA.
//DOF2_SaveFile ~~ TA OBVIO '-'
        DOF2_CreateFile(File); // CRIA O ARQUIVO.
        DOF2_SetInt(File, "Skin", 23); //SETA O ARQUIVO.. E O NUMERO 23 E O ID DA SKIN.
        DOF2_SaveFile(); // NO COMENTS --*
//AGORA VAMOS ENVIAR UMA MENSAGEM PARA O PLAYER DIZENDO QUE FOI CRIADO O ARQUIVO EM SEU NOME!
        SendClientMessage(playerid, -1, "Arquivos Criados");
        OnPlayerConnect(playerid);//REDIRECIONA PARA ONPLAYERCONNECT, FAZENDO ASSIM OS ARQUIVOS
        //SEREM CARREGADOS ALTOMATICAMENTE'-'
    }
    return 1;
}
//VAMOS POR AGORA NA ONPLAYERDISCONNECT PARA QUE QUANDO O PLAYER DESLOGUE
//SALVE OS ARQUIVOS '-'
public OnPlayerDisconnect(playerid)
{
    new File[70], sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(File, sizeof(File), "%s.ini", sendername);
    DOF2_SetInt(File, "Skin", PlayerInfo[playerid][pSkin]); //VAI SALVAR A SKIN QUE O PLAYER ESTA A USAR!
    DOF2_SaveFile(); // NO COMENTS NOVAMENTE!
    return 1;
}
//AGORA VAMOS CRIAR A PUBLIC ONPLAYERSPAWN, E DENTRO DELA VAMOS SETAR PARA QUANDO O PLAYER
//APERTAR SPAWN ELE TENHA A SKIN SETADA PARA A SKIN QUE ESTA NOS ARQUIVOS...
public OnPlayerSpawn(playerid)
{
//VAMOS USAR AGORA A FUNЗГO SETPLAYERSKIN QUE E DO PROPRIO SAMP!
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    return 1;
}
й um simples tutorial sei que nгo expliquei muito.. mais as itenзхes sгo boas '-'
Reply
#2

Nenhum Comentario.. Vacuo
Reply
#3

1° comentario '-' espera os outros comentarem '-'.l.
Reply
#4

kkkkk, mas oque axou??
Reply
#5

Otimo Tuto
Estava presisando de algo asim
pois eu so usava dini!
+rep
Reply
#6

Quote:
Originally Posted by 4LiSs0N
Посмотреть сообщение
Otimo Tuto
Estava presisando de algo asim
pois eu so usava dini!
+rep
kk Vlw.. Mas tipo se vc sabe usar dini e facil usar dof2 '-'
pawn Код:
dini_Exists             DOF2_FileExists
dini_Remove             DOF2_RemoveFile
dini_Create             DOF2_CreateFile
dini_Set                DOF2_SetString
dini_Get                DOF2_GetString
dini_IntSet             DOF2_SetInt
dini_Int                DOF2_GetInt
dini_BoolSet            DOF2_SetBool
dini_Bool               DOF2_GetBool
dini_FloatSet           DOF2_SetFloat
dini_Float              DOF2_GetFloat
dini_Unset              DOF2_Unset
dini_Isset              DOF2_IsSet
Reply
#7

:P ficou bom + rep
Reply
#8

thanks, good job!
Reply
#9

Vlw a todos '-'
Reply
#10

Boa =]
Atй que ficou legal pro 1є Tutorial.!
Reply
#11

Vlw '-'
Reply
#12

Lol vo ver o tuto eu nem codava em DOF2 >)
Reply
#13

Parabens Bom tuto +rep para ti pela humildade e tempo para fazer o tuto!

So queria saber como eu troco o SII pelo DOF2, ta meio complicado aqui rsrs
Reply
#14

Nгo gostei da forma que foi explicado, ainda faltou explicar algumas coisas, porem como vocк foi banido..

mesmo assim parabйns..
Reply
#15

Tutorial fraquinho...Bom para iniciantes
Reply
#16

pawn Код:
C:\Users\Key\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(122) : warning 217: loose indentation
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(140) : warning 217: loose indentation
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(140) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(140) : error 004: function "Streamer_OnPlayerDisconnect" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(142) : warning 219: local variable "File" shadows a variable at a preceding level
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(142) : warning 219: local variable "sendername" shadows a variable at a preceding level
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(151) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(151) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(151) : error 004: function "OnPlayerSpawn" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(167) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(167) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(167) : error 004: function "OnPlayerDeath" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(169) : error 017: undefined symbol "killerid"
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(172) : error 017: undefined symbol "killerid"
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(173) : error 017: undefined symbol "killerid"
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(174) : error 017: undefined symbol "killerid"
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(178) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(178) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(178) : error 004: function "OnVehicleSpawn" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(183) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(183) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(183) : error 004: function "OnVehicleDeath" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(188) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(188) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(188) : error 004: function "OnPlayerText" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(192) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(192) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(192) : error 004: function "OnPlayerEnterVehicle" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(197) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(197) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(197) : error 004: function "OnPlayerExitVehicle" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(202) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(202) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(202) : error 004: function "OnPlayerStateChange" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(207) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(207) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(207) : error 004: function "OnPlayerEnterCheckpoint" is not implemented
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(212) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(212) : error 029: invalid expression, assumed zero
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(212) : error 004: function "Streamer_OnPlayerLeaveCP" is not implemented

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.
Alguem pode ajudar com isso aqui?
Reply
#17

Adiciona isso ao final do code:

}

Ou isso

}
}
Reply
#18

Resolvii esses erros,eu nao tava colocando as chaves nem nada sу o code mesmo.
agora deu esses Warnings.
pawn Код:
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(139) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(167) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(179) : warning 225: unreachable code
C:\Users\Duality\Desktop\Brasil Play DeathMatch\gamemodes\BPDM.pwn(495) : warning 203: symbol is never used: "DOF2_Exit"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Warnings.
Reply
#19

Posta as linhas nй ?
Reply
#20

Q merda vey,tenho q presta mais atenзao,problemas resolvidos!
Vlw San!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)