24.04.2011, 15:50
This doesnt work and I dont know why it doesnt save:
pawn Код:
#include <a_samp>
#include <dini>
#include <dudb>
#pragma unused ret_memcpy
enum pInfo
{
pLevel,
pCash,
pScore,
pCity,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];
#define SERVER_USER_FILE "Info/Accounts/%s.ini"
//Colours:
#define COLOUR_MESSAGE 0x00C7FFAA
#define COLOUR_LIGHTBLUE 0x33CCFFAA
#define COLOUR_BLUE 0x0000BBAA
#define COLOUR_GREY 0xAFAFAFAA
#define COLOUR_GREEN 0x33AA33AA
#define COLOUR_RED 0xFF0000FF
#define COLOUR_YELLOW 0xFFFF0088
#define COLOUR_ORANGE 0xFF9900AA
#define COLOUR_WHITE 0xFFFFFFAA
#define COLOUR_LIGHTRED 0xFF6347AA
#define COLOUR_LIGHTBLUE 0x33CCFFAA
#define COLOUR_LIGHTBLUE 0x33CCFFAA
#define COLOUR_LIGHTGREEN 0x9ACD32AA
#define COLOUR_GREEN2 0x33FF33AA
#define COLOUR_ERROR 0xFF0000AA
#define COLOUR_MSG 0x00FFFFFF
#define COLOUR_PINK 0xFF66FFAA
#define COLOUR_WHITE 0xFFFFFFAA
#define COLOUR_GREEN1 0x33AA33AA
#define COLOUR_BROWN 0xA52A2AAA
#define COLOUR_PURPLE 0x800080AA
#define COLOUR_BLACK 0x000000AA
#define COLOUR_GREEN1 0x33AA33AA
main(){}
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
gPlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if (!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register/Login:","You Are Not Registered, Write Your Password Below", "Register", "Leave");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Register/Login:","You Are Registered, Write Your Password Below To Login", "Login", "Leave");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(gPlayerLogged[playerid] == 1)
{
dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel]);
dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
dini_IntSet(file, "City", PlayerInfo[playerid][pCity]);
}
gPlayerLogged[playerid] = 0;
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/help", cmdtext, true, 10) == 0)
{
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register/Login:","You Are Not Registered, Write Your Password Below", "Register", "Leave");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel] = 0);
dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 100);
dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
dini_IntSet(file, "City",PlayerInfo[playerid][pCity] = 0);
gPlayerLogged[playerid] = 1;
}
if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT, "Register/Login:","You Are Registered, Write Your Password Below To Login","Login","Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
SendClientMessage(playerid, COLOUR_RED, "You Have Entered Wrong Password");
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT, "Register/Login:","You Are Registered, Write Your Password Below To Login","Login","Leave");
}
else
{
gPlayerLogged[playerid] = 1;
PlayerInfo[playerid][pLevel] = dini_Int(file, "Level");
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
SendClientMessage(playerid,COLOUR_RED, "[System]: You Have Successfully Logged In!");
PlayerInfo[playerid][pCity] = dini_Int(file, "City");
}
if (dialogid == 3856)
{
if(response)
{
switch(dialogid)
{
case 1:
{
switch(listitem)
{
case 0://LS
{
PlayerInfo[playerid][pCity] = 1;
if(PlayerInfo[playerid][pCity] == 1) {
SetSpawnInfo(playerid, 0, 0, 477.359375, -1498.8811035156, 20.481548309326, 270, 0, 0, 0, 0, 0, 0);
}
else if(PlayerInfo[playerid][pCity] == 2) {
SetSpawnInfo(playerid, 0, 0, -1968.7583007813, 162.01661682129, 27.6875, 180, 0, 0, 0, 0, 0, 0);
}
else if(PlayerInfo[playerid][pCity] == 3) {
SetSpawnInfo(playerid, 0, 0, 2020.3387451172, 1919.8436279297, 12.340795516968, 270, 0, 0, 0, 0, 0, 0);
}
}
case 1://SF
{
PlayerInfo[playerid][pCity] = 2;
if(PlayerInfo[playerid][pCity] == 1) {
SetSpawnInfo(playerid, 0, 0, 477.359375, -1498.8811035156, 20.481548309326, 270, 0, 0, 0, 0, 0, 0);
}
else if(PlayerInfo[playerid][pCity] == 2) {
SetSpawnInfo(playerid, 0, 0, -1968.7583007813, 162.01661682129, 27.6875, 180, 0, 0, 0, 0, 0, 0);
}
else if(PlayerInfo[playerid][pCity] == 3) {
SetSpawnInfo(playerid, 0, 0, 2020.3387451172, 1919.8436279297, 12.340795516968, 270, 0, 0, 0, 0, 0, 0);
}
}
case 2://LV
{
PlayerInfo[playerid][pCity] = 3;
if(PlayerInfo[playerid][pCity] == 1) {
SetSpawnInfo(playerid, 0, 0, 477.359375, -1498.8811035156, 20.481548309326, 270, 0, 0, 0, 0, 0, 0);
}
else if(PlayerInfo[playerid][pCity] == 2) {
SetSpawnInfo(playerid, 0, 0, -1968.7583007813, 162.01661682129, 27.6875, 180, 0, 0, 0, 0, 0, 0);
}
else if(PlayerInfo[playerid][pCity] == 3) {
SetSpawnInfo(playerid, 0, 0, 2020.3387451172, 1919.8436279297, 12.340795516968, 270, 0, 0, 0, 0, 0, 0);
}
}
}
}
}
}
}
if(PlayerInfo[playerid][pCity] == 0)
{
ShowPlayerDialog(playerid, 3856, DIALOG_STYLE_LIST, "Select Your Home City", "Los Santos\nSan Fierro\nLas Venturas", "Select", "Decline");
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}