Sziasztok!
Csináltam egy Double of Files 2 függvénnyel egy regisztrációs rendszert
Script:
[pawn]/* Double-O-Files_2 Register/Login system by Ty$oN
DOF2 Tutorial By SmiT
Double-O-Seven for Double-O-Files_2 (DOF2)*/
#include <a_samp>
#include <Double-O-Files_2>
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define WHITE \"{FFFFFF}\"
#define RED \"{F81414}\"
#define GREEN \"{00FF22}\"
enum P_ENUM
{
pMoney,
pAdmin,
pKills,
pDeaths
}
new P_DATA[ MAX_PLAYERS ][ P_ENUM ];
stock USER_FILE(playerid)
{
new
STR[ 128 ],
P_NAME[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, P_NAME, sizeof ( P_NAME ) );
format( STR, sizeof ( STR ), USER_FILE_PATH, P_NAME);
return
STR;
}
stock Load_Player_Stats(playerid)
{
P_DATA[ playerid ][ pKills ] = DOF2_GetInt( USER_FILE( playerid ),\"Olesek\");
P_DATA[ playerid ][ pDeaths ] = DOF2_GetInt( USER_FILE( playerid ),\"Halalok\");
P_DATA[ playerid ][ pMoney ] = DOF2_GetInt( USER_FILE( playerid ),\"Penz\");
P_DATA[ playerid ][ pAdmin ] = DOF2_GetInt( USER_FILE( playerid ),\"AdminSzint\");
GivePlayerMoney(playerid, P_DATA[ playerid ][ pMoney ]);
}
public OnFilterScriptInit()
{
return 1;
}
public OnFilterScriptExit()
{
DOF2_Exit();
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
if( DOF2_FileExists ( USER_FILE ( playerid ) ) )
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,\"\"WHITE\"Belépés\",\"\"WHITE\"Üdvözöllek!\\n\"RED\"%s\\n\"WHITE\"Te már regisztrálva vagy!\\nLépj be!\",\"Belépés\",\"Kilépés\");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,\"\"WHITE\"Regisztráció\",\"\"WHITE\"Üdvözöllek!\\n\"RED\"%s\\n\"WHITE\"Te még nem vagy regisztrálva!\\nLépj be!\",\"Belépés\",\"Kilépés\");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
switch( dialogid )
{
case DIALOG_REGISTER:
{
if ( !response ) return Kick( playerid );
if( response )
{
if( !strlen ( inputtext ) ) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,\"\"WHITE\"Belépés\",\"\"WHITE\"Üdvözöllek!\\n\"RED\"%s\\n\"WHITE\"Te már regisztrálva vagy!\\nLépj be!\",\"Belépés\",\"Kilépés\");
DOF2_CreateFile( USER_FILE ( playerid ), inputtext );
DOF2_SetInt( USER_FILE ( playerid ), \"Olesek\", 0);
DOF2_SetInt( USER_FILE ( playerid ), \"Halalok\", 0);
DOF2_SetInt( USER_FILE ( playerid ), \"Penz\", 1000);
DOF2_SetInt( USER_FILE ( playerid ), \"AdminSzint\", 0);
DOF2_SaveFile();
SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
SpawnPlayer( playerid );
GivePlayerMoney(playerid, 1000);
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick( playerid );
if( response )
{
if( DOF2_CheckLogin( USER_FILE( playerid ), inputtext ) )
{
Load_Player_Stats(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,\"\"WHITE\"Elfelejtett jelszó\",\"\"WHITE\"Rossz jelszót adtál meg!\\n\"RED\"%s\\n\"WHITE\"Írd be a jelszavadat!\",\"Belépés\",\"Kilépés\");
}
return 1;
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
DOF2_SetInt( USER_FILE ( playerid ), \"Olesek\", P_DATA[ playerid ][ pKills ] );
DOF2_SetInt( USER_FILE ( playerid ), \"Halalok\", P_DATA[ playerid ][ pDeaths ] );
DOF2_SetInt( USER_FILE ( playerid ), \"Penz\", GetPlayerMoney( playerid ) );
DOF2_SetInt( USER_FILE ( playerid ), \"AdminSzint\", P_DATA[ playerid ][ pAdmin ] );
DOF2_SaveFile();
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if( killerid != INVALID_PLAYER_ID )
{
P_DATA[ playerid ][ pKills ] ++;
}
P_DATA[ playerid ][ pDeaths ] ++;
return 1;
}[/pawn]
(Angol tutorial alapján!!)
Üdv:Ty$oN