17.08.2017, 21:28
salut ,am gasit si eu sistemul asta de case pe net si vreau sa rezolv doua mici probleme la el...
1. De fiecare data cand intru in checkpoint-ul casei indiferent ca este cumparata sau nu imi tot apare dialogul sa cumpar casa.
2.Cum fac sa salvez coordonatele interiorului? adica mie in folderul cu casele salvate la interior x,y,z imi apare 0 la toate... si cand ii setez doar interiorul nu merge comanda enter..
codul este:
1. De fiecare data cand intru in checkpoint-ul casei indiferent ca este cumparata sau nu imi tot apare dialogul sa cumpar casa.
2.Cum fac sa salvez coordonatele interiorului? adica mie in folderul cu casele salvate la interior x,y,z imi apare 0 la toate... si cand ii setez doar interiorul nu merge comanda enter..
codul este:
Код:
#include <a_samp> #include <YSI/y_ini> #include <zcmd> #include <sscanf2> #include <streamer> #define GREY 0xAFAFAFAA #define BLUE2 0x4682B4FF #define RED 0xFF0000AA #define YELLOW 0xE9E312FF #define ORANGE 0xFF9900AA #define WHITE 0xFFFEFFFF #define GREEN 0x33AA33AA #define BLUE 0x0000FFFF #define LIGHTGREEN 0x90EE90FF #define OLIVE 0x808000FF #define SALAMON 0xFA8072FF #define BLACK 0x000000FF #define C_GREY "{AFAFAF}" #define C_BLUE2 "{4682B4}" #define C_RED "{FF0000}" #define C_YELLOW "{E9E312}" #define C_ORANGE "{FF9900}" #define C_WHITE "{FFFEFF}" #define C_GREEN "{33AA33}" #define C_BLUE "{0000FF}" #define C_LIGHTGREEN "{90EE90}" #define C_OLIVE "{808000}" #define C_SALAMON "{FA8072}" #define C_BLACK "{000000}" #define MAX_HOUSE 100 #define HousePATH "GameMod/House/%d.ini" enum hInfo { hOwner[24], Text3D:hLabel, hPickup, Float:hEnterX, Float:hEnterY, Float:hEnterZ, Float:hExitX, Float:hExitY, Float:hExitZ, hInterior, hCost, hSell }; new HouseInfo[MAX_PLAYERS][hInfo]; new MaDom[MAX_PLAYERS]; new Float:X, Float:Y, Float:Z; new houseid; new HouseCount; forward CreateHouse(playerid, koszt, sprzedaz, intek); forward LoadHouse_data(playerid, name[], value[]); public OnPlayerConnect(playerid) { HouseInfo[playerid][hOwner] = 0; HouseInfo[playerid][hEnterX] = 0; HouseInfo[playerid][hEnterY] = 0; HouseInfo[playerid][hEnterZ] = 0; HouseInfo[playerid][hExitX] = 0; HouseInfo[playerid][hExitY] = 0; HouseInfo[playerid][hExitZ] = 0; HouseInfo[playerid][hInterior] = 0; HouseInfo[playerid][hCost] = 0; HouseInfo[playerid][hSell] = 0; MaDom[playerid] = 0; return 1; } public OnPlayerDisconnect(playerid, reason) { if(MaDom[playerid] == 1) { for(new h = 0; h < sizeof(HouseInfo); h++) { new INI:File = INI_Open(HousePath()); INI_WriteString(File, "Wlasciciel", HouseInfo[playerid][hOwner]); INI_WriteFloat(File, "WejscieX", HouseInfo[playerid][hEnterX]); INI_WriteFloat(File, "WejscieY", HouseInfo[playerid][hEnterY]); INI_WriteFloat(File, "WejscieZ", HouseInfo[playerid][hEnterZ]); INI_WriteFloat(File, "WyjscieX", HouseInfo[playerid][hExitX]); INI_WriteFloat(File, "WyjscieY", HouseInfo[playerid][hExitY]); INI_WriteFloat(File, "WyjscieZ", HouseInfo[playerid][hExitZ]); INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]); INI_WriteInt(File, "Cena", HouseInfo[playerid][hCost]); INI_WriteInt(File, "Sprzedaz", HouseInfo[playerid][hSell]); } } return 1; } public OnPlayerEnterDynamicCP(playerid, checkpointid) { for(new h = 0; h < MAX_HOUSE; h++) { if(checkpointid == HouseInfo[playerid][hPickup]) { if(!fexist(HousePath())) { INI_ParseFile(HousePath(), "LoadHouse_%d", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_MSGBOX, "Dom", "This is your home \n Do you want to enter it? ", "Tak", "Nie"); } else { ShowPlayerDialog(playerid, 5001, DIALOG_STYLE_MSGBOX, "Dom", "This house is for sale. Want to buy it? ", "Tak", "Nie"); } } } return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 5001) { if(response) { if(GetPlayerMoney(playerid) > HouseInfo[playerid][hCost]) { MaDom[playerid] = 1; SendClientMessage(playerid, GREEN, "House. "); new string[128]; format(string, sizeof string, ""C_BLUE2"Wlasciciel : "C_BLUE2"%s ", PlayerName(playerid)); Update3DTextLabelText(HouseInfo[playerid][hLabel], RED, string); new INI:File = INI_Open(HousePath()); INI_WriteString(File, "Wlasciciel", PlayerName(playerid)); INI_WriteFloat(File, "WejscieX", HouseInfo[playerid][hEnterX]); INI_WriteFloat(File, "WejscieY", HouseInfo[playerid][hEnterY]); INI_WriteFloat(File, "WejscieZ", HouseInfo[playerid][hEnterZ]); INI_WriteFloat(File, "WyjscieX", HouseInfo[playerid][hExitX]); INI_WriteFloat(File, "WyjscieY", HouseInfo[playerid][hExitY]); INI_WriteFloat(File, "WyjscieZ", HouseInfo[playerid][hExitZ]); INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]); INI_WriteInt(File, "Cena", HouseInfo[playerid][hCost]); INI_WriteInt(File, "Sprzedaz", HouseInfo[playerid][hSell]); INI_Close(File); } else SendClientMessage(playerid, LIGHTGREEN, "You can not afford this house! "); } } return 1; } cmd(nowydom, playerid, params[]) { new cost, sell, interior; if(sscanf(params, "ddd", cost, sell, interior)) return SendClientMessage(playerid, SALAMON, "Wpisz : /nowydom cost price interior "); CreateHouse(playerid, cost, sell, interior); return 1; } public CreateHouse(playerid, koszt, sprzedaz, intek) { GetPlayerPos(playerid, X, Y, Z); new INI:File = INI_Open(HousePath()); HouseCount++; HouseInfo[playerid][hEnterX] = X; HouseInfo[playerid][hEnterY] = Y; HouseInfo[playerid][hEnterZ] = Z; HouseInfo[playerid][hInterior] = intek; HouseInfo[playerid][hCost] = koszt; HouseInfo[playerid][hSell] = sprzedaz; INI_WriteFloat(File, "WejscieX", HouseInfo[playerid][hEnterX]); INI_WriteFloat(File, "WejscieY", HouseInfo[playerid][hEnterY]); INI_WriteFloat(File, "WejscieZ", HouseInfo[playerid][hEnterZ]); INI_WriteFloat(File, "WyjscieX", 0); INI_WriteFloat(File, "WyjscieY", 0); INI_WriteFloat(File, "WyjscieZ", 0); INI_WriteInt(File, "Interior", HouseInfo[playerid][hInterior]); INI_WriteInt(File, "Cena", HouseInfo[playerid][hCost]); INI_WriteInt(File, "Sprzedaz", HouseInfo[playerid][hSell]); INI_Close(File); new string[128]; format(string, sizeof string, ""C_BLUE2"Wlasciciel : "C_YELLOW"brak \n"C_BLUE2"Koszt : "C_YELLOW"%d\n", koszt); HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, X, Y, Z, 7.0, 0); HouseInfo[houseid][hPickup] = CreateDynamicCP(X, Y, Z, 2, 0, 0, 0, 20); return 1; } public LoadHouse_data(playerid, name[], value[]) { new Name[24], string[128]; GetPlayerName(playerid, Name, MAX_PLAYER_NAME); INI_String("Wlasciciel", Name, 48); INI_Float("WejscieX", HouseInfo[playerid][hEnterX]); INI_Float("WejscieY", HouseInfo[playerid][hEnterY]); INI_Float("WejscieZ", HouseInfo[playerid][hEnterZ]); INI_Float("WyjscieX", HouseInfo[playerid][hExitX]); INI_Float("WyjscieY", HouseInfo[playerid][hExitY]); INI_Float("WyjscieZ", HouseInfo[playerid][hExitZ]); INI_Int("Interior", HouseInfo[playerid][hInterior]); INI_Int("Cena", HouseInfo[playerid][hCost]); INI_Int("Sprzedaz", HouseInfo[playerid][hSell]); if(HouseInfo[playerid][hOwner] == 1) { format(string, sizeof string, ""C_BLUE2"Wlasciciel : "C_YELLOW"%s \n", Name); HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterZ], HouseInfo[playerid][hEnterZ], 7.0, 0); HouseInfo[houseid][hPickup] = CreateDynamicCP(HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterY], HouseInfo[playerid][hEnterZ], 2, 0, 0, 0, 20); } else { format(string, sizeof string, ""C_BLUE2"Wlasciciel : "C_YELLOW"brak \n"C_BLUE2"Koszt : "C_YELLOW"%d\n", HouseInfo[playerid][hCost]); HouseInfo[playerid][hLabel] = Create3DTextLabel(string, RED, HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterZ], HouseInfo[playerid][hEnterZ], 7.0, 0); HouseInfo[houseid][hPickup] = CreateDynamicCP(HouseInfo[playerid][hEnterX], HouseInfo[playerid][hEnterY], HouseInfo[playerid][hEnterZ], 2, 0, 0, 0, 20); } return 1; } stock HousePath() { new string[256]; format(string, sizeof string, HousePATH, HouseCount); return string; } stock PlayerName(playerid) { new name[24]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); return name; }