10.10.2011, 10:36
Hi,i have a problem with register/login system,when i join the server and register,the file won't create in my scriptfiles/Users folder.Sorry for bad english i think you understand me.
PHP код:
#include <a_samp>
#include <dini>
#include <dudb>
#pragma unused ret_memcpy
#define COLOR_GREEN 0x33AA33AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_PURPLE 0x800080AA
#define COLOR_BLACK 0x000000AA
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_GREEN 0x33AA33AA
#define COLOR_BROWN 0xA52A2AAA
#define BLUE "{375FFF}"
#define RED "{FF0000}"
#define WHITE "{FFFFFF}"
#define GREEN "{33FF33}"
#define YELLOW "{FFFF00}"
#define GREY "{C0C0C0}"
#define ORANGE "{FF9900}"
#define PINK "{FF66FF}"
new gPlayerLogged[MAX_PLAYERS];
enum pInfo
{
pAdminLevel,
pHide,
pCash,
pScore,
pWarns,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pAdminLevel] = 0;
PlayerInfo[playerid][pHide] = 0;
PlayerInfo[playerid][pCash] = 0;
PlayerInfo[playerid][pScore] = 0;
PlayerInfo[playerid][pWarns] = 0;
gPlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file),"Users/%s.ini", name);
if (!dini_Exists(file))
{
new String[128];
format(String, sizeof (String),WHITE"Welcome "GREEN"%s"WHITE"\n\nPlease register your account:", name);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT,"Register", String,"Register","Kick");
}
if(fexist(file))
{
new String[128];
format(String, sizeof (String),WHITE"Welcome back "GREEN"%s"WHITE"\n\nPlease login into your account:", name);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT,"Login", String,"Login","Kick");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file),"Users/%s.ini", name);
if(gPlayerLogged[playerid] == 1)
{
dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
}
gPlayerLogged[playerid] = 0;
PlayerInfo[playerid][pAdminLevel] = 0;
PlayerInfo[playerid][pHide] = 0;
PlayerInfo[playerid][pCash] = 0;
PlayerInfo[playerid][pScore] = 0;
PlayerInfo[playerid][pWarns] = 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[])
{
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], string[300];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file),"Users/%s.ini", name);
if(!response) return Kick(playerid);
if(strlen(inputtext) < 4)
{
format(string, sizeof (string),WHITE"Welcome "GREEN"%s"WHITE"\n\nPlease register your account:\nPassword must be min 4 characters", name);
return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT,"Register", string,"Register","Kick");
}
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 0);
dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
format(string, 128, "{FFB400}[SYSTEM]: {969696}You succesfully registered the nickname %s with password {FFB400}%s{969696}.", name, inputtext);
SendClientMessage(playerid, COLOR_YELLOW, string);
gPlayerLogged[playerid] = 1;
}
if (dialogid == 2)
{
new pName[MAX_PLAYER_NAME], String[300], file[256];
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file),"Users/%s.ini", pName);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi you are registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
new tmp2;
tmp2 = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp2)
{
SendClientMessage(playerid, COLOR_RED, "[ERROR]Wrong Password try again");
GetPlayerName(playerid, pName[playerid], MAX_PLAYER_NAME);
format(String, sizeof (String),WHITE"Welcome back "GREEN"%s"WHITE"\n\nPlease login into your account:\nWrong password", pName[playerid]);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT,"Login", String,"Login","Kick");
}
else
{
gPlayerLogged[playerid] = 1;
PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}