Доступ к архиву

Переход в группу "Пользователь"

300.00 ₽
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

проблема с модом

Статус
В этой теме нельзя размещать новые ответы.

Playback

Новичок
Пытаюсь делать мод с нуля.. возникли 2 проблемы:

1) Проблема с акками:
Регаюсь, Логинюсь, заполняю инфу перса (пол, фозраст) все норм... при перезаходах все сохраняет - всю информацию о персе и его местоположение при выходе.... Но потом если перезагрузить мод, зайти, залогиниться, то у меня все сбрасывается.. причем иногда после перезагрузки мода это бывает сразу как я войду, а бывает зайду все сохранено, а через 1-2 перезахода сбрасывается..
никакой закономерности я ненашел....

2) Проблема с домами:
При запуске и закрытии мода работает паблик на загрузку и сохранение домов... так вот в нем что-то не так... в пункте Владельца дома строкового типа Owner он не может её считать...и соответственно сохранить...кароче допустим вначале в каждом доме стоит Owner = State, потом запускаю серв, иду к любому дому, вижу что в 3д тексте напротив пункта "Владелец:" пусто... закрываю серв...захожу в файлы с домами и там уже напротив Owner пусто...

Очень прошу помочь... уже неделю работа над модом стоит из-за этих двух багов..

PHP:
#include <a_samp>
#include <mxINI>
//#include <manticheat>
#include <streamer>
#include <utils>
#include <core>
#include <float>
#include <morphinc>
#include <MapIconStreamer>

//========[AntiDeAMX]=========//
AntiDeAMX()
 {
 new a[][] =
 {
 "Unarmed (Fist)",
 "Brass K"
 };
 #pragma unused a
 }
 public DeAMXI(playerid)
 {
 AntiDeAMX();
 return 1;
 }
 forward DeAMXI ();
//===========================//
#define DIALOG_AGE 996
#define DIALOG_SEX 997
#define DIALOG_LOGIN 998 
#define DIALOG_REGISTER 999 
#define AccauntBD "accounts/%s.ini" 
#define HouseBD "houses/%s.ini"
#define house_num 8
//цвета//
#define COLOR_GREY 0xAFAFAFAA   // серый
#define COLOR_GREEN 0x44DD44AA  //  зеленый
#define COLOR_RED 0xFF0000AA   //  красный
#define COLOR_DARKRED 0xB02323AA   //  темно красный
#define COLOR_YELLOW 0xFFFF00AA   //  желтый
#define COLOR_WHITE 0xFFFFFFAA   // белый
#define COLOR_DARKBLUE 0x0000BBAA   // темно синий
#define COLOR_LTBLUE 0x5050FFAA // синий
#define COLOR_CYAN 0x33CCFFAA // голубой
#define COLOR_ORANGE 0xFF9900AA   // оранжевый

forward OnPlayerRegistered(playerid, password[]);
forward OnPlayerLogin(playerid, password[]);
forward SaveAccounts();
forward SaveHouses();
forward LoadHouses();
forward MoneyUpdate();
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
//Диалоги
forward ShowPlayerRegisterDialog(playerid);
forward ShowPlayerLoginDialog(playerid);
forward ShowPlayerSexDialog(playerid);
forward ShowPlayerAgeDialog(playerid);
forward SavePlayerInfo(playerid);
//===================================//
forward ShowStats(playerid,targetid);
forward SetPlayerSpawn(playerid);
forward split(const strsrc[], strdest[][], delimiter);

enum pInfo
{
	pMoney,
	pAdmin,
	pSkin,
	pSex,
	pAge,
	pReg,
	pCharInfo,
	Float:pPos_x,
	Float:pPos_y,
	Float:pPos_z,
	pInt,
	pWorld
};

enum hInfo
{
	hId,
	Float:hEnterPos_x,
	Float:hEnterPos_y,
	Float:hEnterPos_z,
	Float:hIntPos_x,
	Float:hIntPos_y,
	Float:hIntPos_z,
	hInt,
	hWorld,
	hClass,
	hCost,
	hSale,
	hOwner[MAX_PLAYER_NAME]
};

new PlayerInfo[MAX_PLAYERS][pInfo];
new HouseInfo[house_num][hInfo];
new gPlayerLogged[MAX_PLAYERS];
new Text:InfoTextDraw[MAX_PLAYERS];
new Text:Textdraw0;
new Text3D:HouseText[256];//массив 3д текстов дома
new HouseEntrancePickups[256]; //массив пикапов входа в дом
new SaveAccountsTimer;
new MoneyUpdateTimer;
main() {}

public OnGameModeInit()
{
	SaveAccountsTimer = SetTimer("SaveAccounts",1000*10,true);
	MoneyUpdateTimer = SetTimer("MoneyUpdate",1000*10,true);
	AllowAdminTeleport(1);
	AllowInteriorWeapons(1);
	DisableInteriorEnterExits();
	SetGameModeText("RolePlay");
	//////////////////////////////ДОМА///////////////////////////////////
	LoadHouses();
	ShowPlayerMarkers(2);//чтоб маркеры на радаре игроков были тока вблизи
 	for(new h = 0; h < house_num; h++)
	{
		if(HouseInfo[h][hSale] == 1)
		{
			new strstr[256];
	    	format(strstr,sizeof(strstr),"{FFFF00}Дом продается\n{FFFF00}Номер дома: {FFFFFF}%d\n{FFFF00}Владелец: {FFFFFF}%s\n{FFFF00}Класс дома: {FFFFFF}%d \n{FFFF00}Цена: {FFFFFF}$%d",h,HouseInfo[h][hOwner],HouseInfo[h][hClass],HouseInfo[h][hCost]);
			HouseText[h] = CreateDynamic3DTextLabel(strstr,0xFF8000AA,HouseInfo[h][hEnterPos_x], HouseInfo[h][hEnterPos_y], HouseInfo[h][hEnterPos_z],35.0);
		}
		if(HouseInfo[h][hSale] == 0)
		{
			new strstr[256];
	    	format(strstr,sizeof(strstr),"{FF9900}Номер дома: {FFFFFF}%d\n{FF9900}Владелец: {FFFFFF}%s\n{FF9900}Класс дома: {FFFFFF}%d",h,HouseInfo[h][hOwner],HouseInfo[h][hClass]);
			HouseText[h] = CreateDynamic3DTextLabel(strstr,0x37E3ECAA,HouseInfo[h][hEnterPos_x], HouseInfo[h][hEnterPos_y], HouseInfo[h][hEnterPos_z],35.0);
		}
		HouseEntrancePickups[h] = AddStaticPickup(1273, 35, HouseInfo[h][hEnterPos_x], HouseInfo[h][hEnterPos_y], HouseInfo[h][hEnterPos_z]);
	}
	return 1;
}


public SaveAccounts()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			SavePlayerInfo(i);
		}
	}
}

public MoneyUpdate()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			new string[90];
			format(string,sizeof(string),"$%d",PlayerInfo[i][pMoney]);
			TextDrawSetString(InfoTextDraw[i], string);
		}
	}
}

public SaveHouses()
{
    for(new h = 0; h < house_num; h++)
	{
        new string[128];
    	format(string,sizeof(string),"houses/%d.ini",h);
    	new iniFile = ini_openFile(string);
 		ini_setInteger(iniFile,"Id",HouseInfo[h][hId]);
		ini_setFloat(iniFile,"EntrancePos_x",HouseInfo[h][hEnterPos_x]);
		ini_setFloat(iniFile,"EntrancePos_y",HouseInfo[h][hEnterPos_y]);
		ini_setFloat(iniFile,"EntrancePos_z",HouseInfo[h][hEnterPos_z]);
		ini_setFloat(iniFile,"InteriorPos_x",HouseInfo[h][hIntPos_x]);
		ini_setFloat(iniFile,"InteriorPos_y",HouseInfo[h][hIntPos_y]);
		ini_setFloat(iniFile,"InteriorPos_z",HouseInfo[h][hIntPos_z]);
		ini_setInteger(iniFile,"Interior",HouseInfo[h][hInt]);
		ini_setInteger(iniFile,"VirtWorld",HouseInfo[h][hWorld]);
		ini_setInteger(iniFile,"Class",HouseInfo[h][hClass]);
		ini_setInteger(iniFile,"Cost",HouseInfo[h][hCost]);
		ini_setInteger(iniFile,"Sale",HouseInfo[h][hSale]);
		ini_setString(iniFile,"Owner",HouseInfo[h][hOwner]);
		//
    	ini_closeFile(iniFile);
	}
}

public LoadHouses()
{
    for(new h = 0; h < house_num; h++)
	{
        new string[128];
    	format(string,sizeof(string),"houses/%d.ini",h);
    	new iniFile = ini_openFile(string);
 		ini_getInteger(iniFile,"Id",HouseInfo[h][hId]);
		ini_getFloat(iniFile,"EntrancePos_x",HouseInfo[h][hEnterPos_x]);
		ini_getFloat(iniFile,"EntrancePos_y",HouseInfo[h][hEnterPos_y]);
		ini_getFloat(iniFile,"EntrancePos_z",HouseInfo[h][hEnterPos_z]);
		ini_getFloat(iniFile,"InteriorPos_x",HouseInfo[h][hIntPos_x]);
		ini_getFloat(iniFile,"InteriorPos_y",HouseInfo[h][hIntPos_y]);
		ini_getFloat(iniFile,"InteriorPos_z",HouseInfo[h][hIntPos_z]);
		ini_getInteger(iniFile,"Interior",HouseInfo[h][hInt]);
		ini_getInteger(iniFile,"VirtWorld",HouseInfo[h][hWorld]);
		ini_getInteger(iniFile,"Class",HouseInfo[h][hClass]);
		ini_getInteger(iniFile,"Cost",HouseInfo[h][hCost]);
		ini_getInteger(iniFile,"Sale",HouseInfo[h][hSale]);
		ini_getString(iniFile,"Owner",HouseInfo[h][hOwner]);
		//
    	ini_closeFile(iniFile);
    	printf("Дом: houses/%d.ini успешно загружен",h);
	}
}

public OnGameModeExit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			gPlayerLogged[i] = 0;
		}
	}
	SaveAccounts();
	SaveHouses();
	KillTimer(MoneyUpdateTimer);
	KillTimer(SaveAccountsTimer);
	return 1;
}

public split(const strsrc[], strdest[][], delimiter)
{
	new i, li;
	new aNum;
	new len;
	while(i <= strlen(strsrc)){
	    if(strsrc[i]==delimiter || i==strlen(strsrc)){
	        len = strmid(strdest[aNum], strsrc, li, i, 128);
	        strdest[aNum][len] = 0;
	        li = i+1;
	        aNum++;
		}
		i++;
	}
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    new string[128];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    format(string,sizeof(string),AccauntBD,playername);
    if(fexist(string))
	{
        ShowPlayerLoginDialog(playerid);
    }
	else
	{
 		ShowPlayerRegisterDialog(playerid);
 	}
 	SetPlayerCameraPos(playerid,-1789.275634,996.532592,141.859664);
	SetPlayerCameraLookAt(playerid,-1789.296752,995.533325,141.827224);
	return 1;
}

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid,COLOR_YELLOW,"OnPlayerConnect");
    gPlayerLogged[playerid] = 0;
	PlayerInfo[playerid][pMoney] = 0;
	PlayerInfo[playerid][pAdmin] = 0;
	PlayerInfo[playerid][pSkin] = 137;
	PlayerInfo[playerid][pSex] = 0;
	PlayerInfo[playerid][pAge] = 0;
	PlayerInfo[playerid][pReg] = 0;
	PlayerInfo[playerid][pCharInfo] = 0;
	PlayerInfo[playerid][pPos_x] = 822.0577;
	PlayerInfo[playerid][pPos_y] = -1344.6753;
	PlayerInfo[playerid][pPos_z] = 13.5190;
	PlayerInfo[playerid][pInt] = 0;
	PlayerInfo[playerid][pWorld] = 0;
	//-----------------------------------------------------//
	TextDrawShowForPlayer(playerid, Textdraw0);
 	InfoTextDraw[playerid] = TextDrawCreate(500.0,78,"_");
  	TextDrawAlignment(InfoTextDraw[playerid],0);
   	TextDrawBackgroundColor(InfoTextDraw[playerid],0x000000ff);
   	TextDrawFont(InfoTextDraw[playerid],3);
   	TextDrawLetterSize(InfoTextDraw[playerid],0.5,2.1);
    TextDrawColor(InfoTextDraw[playerid],0x3655ccFF);
    TextDrawSetOutline(InfoTextDraw[playerid],1);
    TextDrawSetProportional(InfoTextDraw[playerid],1);
    TextDrawSetShadow(InfoTextDraw[playerid],1);
    TextDrawShowForPlayer(playerid, InfoTextDraw[playerid]);
    //------------------------------------------------------//
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	SavePlayerInfo(playerid);
	gPlayerLogged[playerid] = 0;
	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[])
{
    new cmd[128],idx,tmp[128];
	cmd = strtok(cmdtext, idx);
	if (strcmp("/аккаунт", cmdtext, true, 10) == 0)
	{
	    ShowStats(playerid,playerid);
	}
	if (strcmp("/kill", cmdtext, true, 10) == 0)
	{
		SetPlayerHealth(playerid,-1);
	}
	//===============[новый дом]==============//
	if(strcmp(cmd, "/hnew", true) == 0)
	{
  		tmp = strtok(cmdtext, idx);
    	if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFAA,"***Использование: /hnew [type 1-10] [hworld] [id\filename] ");
    	new housetype = strval(tmp);
		//
    	tmp = strtok(cmdtext, idx);
    	if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFAA,"***Использование: /hnew [type 1-10] [hworld] [id\filename] ");
    	new houseworld = strval(tmp);
		//
    	tmp = strtok(cmdtext, idx);
    	if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFAA,"***Использование: /hnew [type 1-10] [hworld] [id\filename] ");
    	new houseid = strval(tmp);
		new houseint, housecost, Float:iX, Float:iY, Float:iZ;
		//
		if(housetype==1){houseint = 10; housecost = 200000; iX = 2259.7595; iY = -1135.7062; iZ = 1050.6328;}
 		else if(housetype==2){houseint = 2; housecost = 300000; iX = 2468.4490; iY = -1698.3065; iZ = 1013.5078;}
  		else if(housetype==3){houseint = 3; housecost = 400000; iX = 2496.0002; iY = -1692.4706; iZ = 1014.7422;}
	 	else if(housetype==4){houseint = 10; housecost = 500000; iX = 2269.6284; iY = -1210.4397; iZ = 1047.5625;}
	    else if(housetype==5){houseint = 5; housecost = 600000; iX = 226.6236; iY = 1114.3126; iZ = 1080.9946;}
	    else if(housetype==6){houseint = 8; housecost = 700000; iX = 2317.6868; iY = -1026.7524; iZ = 1050.2178;}
	    else if(housetype==7){houseint = 9; housecost = 800000; iX = 2365.1089; iY = -1133.0795; iZ = 1050.8750;}
	    else if(housetype==8){houseint = 8; housecost = 900000; iX = 2365.3064; iY = -1135.3292; iZ = 1050.8750;}
	    else if(housetype==9){houseint = 12; housecost = 1000000; iX = 2324.2317; iY = -1149.0736; iZ = 1050.7101;}
		new Float:pX,Float:pY,Float:pZ;
		GetPlayerPos(playerid,pX,pY,pZ);
		//сохраняем все в файл
		new string[128];
    	format(string,sizeof(string),HouseBD,tmp);
    	new iniFile = ini_createFile(string);
    	if(iniFile < 0)
    	iniFile = ini_openFile(string);
 		ini_setInteger(iniFile,"Id",houseid);
		ini_setFloat(iniFile,"EntrancePos_x",pX);
		ini_setFloat(iniFile,"EntrancePos_y",pY);
		ini_setFloat(iniFile,"EntrancePos_z",pZ);
		ini_setFloat(iniFile,"InteriorPos_x",iX);
		ini_setFloat(iniFile,"InteriorPos_y",iY);
		ini_setFloat(iniFile,"InteriorPos_z",iZ);
		ini_setInteger(iniFile,"Interior",houseint);
		ini_setInteger(iniFile,"VirtWorld",houseworld);
		ini_setInteger(iniFile,"Class",housetype);
		ini_setInteger(iniFile,"Cost",housecost);
		ini_setInteger(iniFile,"Sale",1);
		ini_setString(iniFile,"Owner","State");

    	ini_closeFile(iniFile);
    	SendClientMessage(playerid,COLOR_GREEN,"*** Дом успешно создан ***");
    }
    if(strcmp(cmd, "/дом", true) == 0)
	{
  		tmp = strtok(cmdtext, idx);
    	if(!strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFAA,"***Использование: /дом [купить/продать] ");
    	new buystring[10] = "купить";
    	new sellstring[10] = "продать";
    	if(!strcmp(buystring,tmp))
    	{
    	    for(new h = 0; h < house_num; h++)
    	    {
    	    	if(PlayerToPoint(1, playerid, HouseInfo[h][hEnterPos_x], HouseInfo[h][hEnterPos_y], HouseInfo[h][hEnterPos_z]))
    	    	{
					if(HouseInfo[h][hSale] == 1)
					{
						if(PlayerInfo[playerid][pMoney] >= HouseInfo[h][hCost])
    	    	    	{
    	    	        	new plname[MAX_PLAYER_NAME];
    	    	        	GetPlayerName(playerid,plname,sizeof(plname));
				  			strmid(HouseInfo[h][hOwner], plname, 0, strlen(plname), 255);
				  			HouseInfo[h][hSale] = 0;
		 					PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - HouseInfo[h][hCost];
							SendClientMessage(playerid,COLOR_GREEN,"*** Поздравляем вас с покупкой нового дома! ");
							//
							new strstr[256];
							format(strstr,sizeof(strstr),"{FF9900}Номер дома: {FFFFFF}%d\n{FF9900}Владелец: {FFFFFF}%s\n{FF9900}Класс дома: {FFFFFF}%d",h,HouseInfo[h][hOwner],HouseInfo[h][hClass]);
							UpdateDynamic3DTextLabelText(HouseText[h],0x37E3ECAA,strstr);
							SaveHouses();
    	    	    	}
					}
				}
			}
		}
        if(!strcmp(sellstring,tmp))
    	{
    	    for(new h = 0; h < house_num; h++)
    	    {
    	    	if(PlayerToPoint(1, playerid, HouseInfo[h][hEnterPos_x], HouseInfo[h][hEnterPos_y], HouseInfo[h][hEnterPos_z]))
    	    	{
  	    			new plname[MAX_PLAYER_NAME];
	        		GetPlayerName(playerid,plname,sizeof(plname));
					if(!strcmp(plname,HouseInfo[h][hOwner]))
					{
  						strmid(HouseInfo[h][hOwner], "State", 0, strlen("State"), 255);
			  			HouseInfo[h][hSale] = 1;
						PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] + (HouseInfo[h][hCost]/100)*90;
						SendClientMessage(playerid,COLOR_GREEN,"*** Поздравляем вас с продажей дома! ");
						//
						new strstr[256];
						format(strstr,sizeof(strstr),"{FFFF00}Дом продается\n{FFFF00}Номер дома: {FFFFFF}%d\n{FFFF00}Владелец: {FFFFFF}%s\n{FFFF00}Класс дома: {FFFFFF}%d \n{FFFF00}Цена: {FFFFFF}$%d",h,HouseInfo[h][hOwner],HouseInfo[h][hClass],HouseInfo[h][hCost]);
						UpdateDynamic3DTextLabelText(HouseText[h],0x37E3ECAA,strstr);
						SaveHouses();
					}
				}
			}
		}
		else
		{
		    SendClientMessage(playerid,0xFFFFFFAA,"***Использование: /дом [купить/продать]");
		}
	}
    return 1;
}

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 ShowStats(playerid,targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
	{
	    new playername[MAX_PLAYER_NAME];
	    new admin=PlayerInfo[targetid][pAdmin];
		new money=PlayerInfo[targetid][pMoney];
  		new skin=PlayerInfo[targetid][pSkin];
  		new sex[10];
		new age=PlayerInfo[playerid][pAge];
  		if(PlayerInfo[targetid][pSex] == 1){sex="мужчина";}
		else if(PlayerInfo[targetid][pSex] == 2){sex="женщина";}
		new interior=PlayerInfo[playerid][pInt];
		new world=PlayerInfo[playerid][pWorld];
	 	new statistic[1520];
	 	GetPlayerName(playerid, playername, sizeof(playername));
		format(statistic,sizeof(statistic),
		"{FF9900}Ник: {FFFFFF}%s \n{FF9900}Админ лвл: {FFFFFF}%d \n{FF9900}Деньги: {FFFFFF}%d \n{FF9900}Id скина: {FFFFFF}%d \n{FF9900}Пол: {FFFFFF}%s \n{FF9900}Возраст: {FFFFFF}%d\n{FF9900}------------------------\n{FF9900}Интерьер: {FFFFFF}%d \n{FF9900}Вирт.Мир: {FFFFFF}%d \n{FF9900}------------------------", playername, admin, money, skin, sex, age,interior,world);
		ShowPlayerDialog(playerid, 1932, DIALOG_STYLE_MSGBOX,"RolePlay (Ваша Статистика)",statistic,"Ок","");
	}
}
public SavePlayerInfo(playerid)
{
	new string[128];
	new playername[MAX_PLAYER_NAME];
	new Float:X,Float:Y,Float:Z;
	GetPlayerPos(playerid,X,Y,Z);
	PlayerInfo[playerid][pPos_x]=X;
	PlayerInfo[playerid][pPos_y]=Y;
	PlayerInfo[playerid][pPos_z]=Z;
	GetPlayerName(playerid, playername, sizeof(playername));
    format(string,sizeof(string),AccauntBD,playername);
    new iniFile = ini_openFile (string);
	ini_setInteger(iniFile,"Money",PlayerInfo[playerid][pMoney]);
	ini_setInteger(iniFile,"Admin",PlayerInfo[playerid][pAdmin]);
	ini_setInteger(iniFile,"Skin",PlayerInfo[playerid][pSkin]);
	ini_setInteger(iniFile,"Sex",PlayerInfo[playerid][pSex]);
	ini_setInteger(iniFile,"Age",PlayerInfo[playerid][pAge]);
	ini_setInteger(iniFile,"Reg",PlayerInfo[playerid][pReg]);
	ini_setInteger(iniFile,"CharInfo",PlayerInfo[playerid][pCharInfo]);
	ini_setFloat(iniFile,"Pos_x",PlayerInfo[playerid][pPos_x]);
 	ini_setFloat(iniFile,"Pos_y",PlayerInfo[playerid][pPos_y]);
 	ini_setFloat(iniFile,"Pos_z",PlayerInfo[playerid][pPos_z]);
 	ini_setInteger(iniFile,"Interior",PlayerInfo[playerid][pInt]);
 	ini_setInteger(iniFile,"VirtWorld",PlayerInfo[playerid][pWorld]);
    ini_closeFile(iniFile);
    return 1;
}
public OnPlayerLogin(playerid, password[])
{
    SendClientMessage(playerid,COLOR_YELLOW,"OnPlyerLogin");
    new string[64];
	new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
	format(string, sizeof(string), AccauntBD, playername);
	new iniFile = ini_openFile(string);
	if(!iniFile)
	{
	    SendClientMessage(playerid,COLOR_CYAN,"Загрузка данных об аккаунте...");
        ini_getInteger(iniFile,"Money",PlayerInfo[playerid][pMoney]);
        ini_getInteger(iniFile,"Admin",PlayerInfo[playerid][pAdmin]);
        ini_getInteger(iniFile,"Skin",PlayerInfo[playerid][pSkin]);
        ini_getInteger(iniFile,"Sex",PlayerInfo[playerid][pSex]);
        ini_getInteger(iniFile,"Age",PlayerInfo[playerid][pAge]);
        ini_getInteger(iniFile,"Reg",PlayerInfo[playerid][pReg]);
		ini_getInteger(iniFile,"CharInfo",PlayerInfo[playerid][pCharInfo]);
        ini_getFloat(iniFile,"Pos_x",PlayerInfo[playerid][pPos_x]);
        ini_getFloat(iniFile,"Pos_y",PlayerInfo[playerid][pPos_y]);
        ini_getFloat(iniFile,"Pos_z",PlayerInfo[playerid][pPos_z]);
 		ini_getInteger(iniFile,"Interior",PlayerInfo[playerid][pInt]);
 		ini_getInteger(iniFile,"VirtWorld",PlayerInfo[playerid][pWorld]);
 		
        ini_closeFile(iniFile);
	}
 	format(string,sizeof(string),"{FFA500}%s{ffffff} присоединился к серверу",PlayerName(playerid));
	SendClientMessageToAll(COLOR_LTBLUE,string);
	gPlayerLogged[playerid] = 1;
 	if(PlayerInfo[playerid][pReg] == 0)
	{
	    SendClientMessage(playerid,COLOR_ORANGE,"pReg = 0");
		PlayerInfo[playerid][pMoney] = 500;
		PlayerInfo[playerid][pAdmin] = 0;
		PlayerInfo[playerid][pSkin] = 137;
		PlayerInfo[playerid][pReg] = 1;
		PlayerInfo[playerid][pCharInfo] = 0;
		PlayerInfo[playerid][pPos_x] = 822.0577;
		PlayerInfo[playerid][pPos_y] = -1344.6753;
		PlayerInfo[playerid][pPos_z] = 13.5190;
		PlayerInfo[playerid][pInt] = 0;
		PlayerInfo[playerid][pWorld] = 0;
	}
	SetSpawnInfo(playerid, 1, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
	//id,team,skin,x,y,z,angle,wep1,ammo1,wep2,ammo2,wep3,ammo3
	SpawnPlayer(playerid);
    return 1;
}

public OnPlayerRegistered(playerid, password[])
{
    new string[128];
    format(string,sizeof(string),AccauntBD,PlayerName(playerid));
    new iniFile = ini_createFile(string);
    if(iniFile < 0)
    iniFile = ini_openFile(string);
    ini_setString(iniFile,"Password",password);
 	ini_setInteger(iniFile,"Money",PlayerInfo[playerid][pMoney]);
	ini_setInteger(iniFile,"Admin",PlayerInfo[playerid][pAdmin]);
	ini_setInteger(iniFile,"Skin",PlayerInfo[playerid][pSkin]);
	ini_setInteger(iniFile,"Sex",PlayerInfo[playerid][pSex]);
	ini_setInteger(iniFile,"Age",PlayerInfo[playerid][pAge]);
	ini_setInteger(iniFile,"Reg",PlayerInfo[playerid][pReg]);
	ini_setInteger(iniFile,"CharInfo",PlayerInfo[playerid][pCharInfo]);
	PlayerInfo[playerid][pPos_x] = 822.0577;
	PlayerInfo[playerid][pPos_y] = -1344.6753;
	PlayerInfo[playerid][pPos_z] = 13.5190;
	PlayerInfo[playerid][pInt] = 0;
	PlayerInfo[playerid][pWorld] = 0;
	ini_setFloat(iniFile,"Pos_x",PlayerInfo[playerid][pPos_x]);
 	ini_setFloat(iniFile,"Pos_y",PlayerInfo[playerid][pPos_y]);
 	ini_setFloat(iniFile,"Pos_z",PlayerInfo[playerid][pPos_z]);
 	ini_setInteger(iniFile,"Interior",PlayerInfo[playerid][pInt]);
 	ini_setInteger(iniFile,"VirtWorld",PlayerInfo[playerid][pWorld]);
    ini_closeFile(iniFile);
    ShowPlayerLoginDialog(playerid);
    format(string,sizeof(string), "Вы зарегистрировались. Ваш пароль: %s, Теперь авторизуйтесь",password);
    SendClientMessage(playerid,COLOR_ORANGE,string);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SendClientMessage(playerid,COLOR_YELLOW,"OnPlayerSpawn");
    if(gPlayerLogged[playerid] == 0)
	{
    	SendClientMessage(playerid, COLOR_RED, "* Извините но этот сервер требует авторизации (Kicked) **");
        Kick(playerid);
 	}
 	for(new h = 0; h < house_num; h++)
	{
    	if(HouseInfo[h][hSale] == 1)
    	{
    		CreateMapIcon(31,COLOR_GREEN,HouseInfo[h][hEnterPos_x], HouseInfo[h][hEnterPos_y], HouseInfo[h][hEnterPos_z]);
    	}
    	if(HouseInfo[h][hSale] == 0)
    	{
     		CreateMapIcon(32,COLOR_GREEN,HouseInfo[h][hEnterPos_x], HouseInfo[h][hEnterPos_y], HouseInfo[h][hEnterPos_z]);
		}
	}
	SetPlayerSpawn(playerid);
	return 1;
}
public SetPlayerSpawn(playerid)
{
    SendClientMessage(playerid,COLOR_YELLOW,"SetPlayerSpawn");
	if(IsPlayerConnected(playerid))
	{
    	if(PlayerInfo[playerid][pCharInfo]==0)
		{
		    SendClientMessage(playerid,COLOR_ORANGE,"pCharInfo = 0");
	    	SendClientMessage(playerid,COLOR_CYAN,"Заполните информацию о персонаже...");
			ShowPlayerSexDialog(playerid);
		}
		SetPlayerInterior(playerid,PlayerInfo[playerid][pInt]);
		SetPlayerPos(playerid,PlayerInfo[playerid][pPos_x],PlayerInfo[playerid][pPos_y],PlayerInfo[playerid][pPos_z]);
		SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]);
	}
	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 == DIALOG_LOGIN) 
    {
        if(response)
		{
			if(!strlen(inputtext))
			{
				ShowPlayerLoginDialog(playerid);
			}
			new password[256];
			new string[256];
			format(string,sizeof(string),AccauntBD,PlayerName(playerid));
			new File = ini_openFile(string);
			ini_getString(File,"Password",password);
			ini_closeFile(File);
            if(!strcmp(inputtext,password,true))
            {
                OnPlayerLogin(playerid,inputtext);
            }
            else
            {
				
	   			SendClientMessage(playerid,COLOR_RED,"***Вы ввели неверный пароль");
	    		ShowPlayerLoginDialog(playerid);
	            return 1;
            }
		}
	}
	if(dialogid == DIALOG_REGISTER) 
    {
        if(!response) Kick(playerid);
        if(strlen(inputtext) == 0) return ShowPlayerRegisterDialog(playerid);
        OnPlayerRegistered(playerid, inputtext);
        return 1;
    }
    if(dialogid == DIALOG_SEX)
    {
        if(response)
	 	{
	 	    if(listitem == 0)
	 	    {
	 	    	PlayerInfo[playerid][pSex] = 1;
			    SendClientMessage(playerid, COLOR_GREEN, "Хорошо, вы мужчина.");
   				SetPlayerSkin(playerid, 7);
				PlayerInfo[playerid][pSkin]=7;
			    ShowPlayerAgeDialog(playerid);
				return 1;
   			}
   			if(listitem == 1)
   			{
   			    PlayerInfo[playerid][pSex] = 2;
			    SendClientMessage(playerid, COLOR_GREEN, "Хорошо, вы женщина.");
   				SetPlayerSkin(playerid, 12);
   				PlayerInfo[playerid][pSkin]=12;
				ShowPlayerAgeDialog(playerid);
				return 1;
	   		}
 		}
 		else
 		{
 		    Kick(playerid);
     	}
    }
    if(dialogid == DIALOG_AGE)
    {
        if(!strlen(inputtext))
	    {
			ShowPlayerAgeDialog(playerid);
	        return 1;
	    }
	    new year, month,day;
		getdate(year, month, day);
	    new DateInfo[3][20];
		split(inputtext, DateInfo, '/');
		if(year - strval(DateInfo[2]) > 100 || strval(DateInfo[2]) < 1 || strval(DateInfo[2]) >= year)
		{
		    ShowPlayerAgeDialog(playerid);
		    return 1;
		}
		new check = year - strval(DateInfo[2]);
		if(check == year)
		{
		    ShowPlayerAgeDialog(playerid);
		    return 1;
		}
		if(strval(DateInfo[1]) > month)
		{
		    check -= 1;
		}
		else if(strval(DateInfo[1]) == month && strval(DateInfo[0]) > day)
		{
		    check -= 1;
		}
		PlayerInfo[playerid][pAge] = check;
		new string[256];
  		format(string, sizeof(string), "Baшему персонажу %d лет.",PlayerInfo[playerid][pAge]);
		SendClientMessage(playerid, COLOR_GREEN, string);
		PlayerInfo[playerid][pCharInfo]=1;
		format(string, sizeof(string), "===================================",PlayerInfo[playerid][pAge]);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		format(string, sizeof(string), "Вы заполнили информацию о персонаже",PlayerInfo[playerid][pAge]);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		
    }
	return 0;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}

public ShowPlayerRegisterDialog(playerid) 
{
	new string[256];
	format(string,sizeof(string), "Добро пожаловать на сервер!\nПожалуйста зарегистрируйтесь ваш ник '%s'\nвведите пароль и нажмите 'Ок'",PlayerName(playerid));
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Регистрация:", string, "Ок", "Выход");
	return 1;
}

public ShowPlayerLoginDialog(playerid)
{
 	new string[256];
	format(string,sizeof(string), "Здраствуйте %s вы здесь уже зарегистрированы\nпожалуйтса введите свой пароль\nуказанный при регистрации в окошко ниже",PlayerName(playerid));
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Авторизация:", string, "Ок", "Выход");
	return 1;
}

public ShowPlayerSexDialog(playerid)
{
 	new string[256];
 	new listitems[] = "Мужчина\nЖенщина";
	format(string,sizeof(string), "Выберите пол ващего персонажа:",PlayerName(playerid));
    ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_LIST, "Выберите пол", listitems, "Ок", "Выход");
	return 1;
}
public ShowPlayerAgeDialog(playerid)
{
 	new string[256];
	format(string,sizeof(string), "Введите дату рождения вашего персонажа в формате дд/мм/гггг \nПример: 09/07/1981",PlayerName(playerid));
    ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Возраст персонажа", string, "Ок", "Выход");
	return 1;
}

public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}

stock PlayerName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
	return name;
}

strtok(const string[], &index)
{
     new length = strlen(string);
     while ((index < length) && (string[index] <= ' '))
     {
         index++;
     }

     new offset = index;
     new result[20];
     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
     {
         result[index - offset] = string[index];
         index++;
     }
     result[index - offset] = EOS;
     return result;
}

Так же вот вся папка с сервером:
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу