house sistem
#1

Hello, I'm trying to make a house system but I do not know what to start with...
You can give me some advice or a code that I can take

That's what i did
Код:
#define  HOUSE_MENU              2013
#define  HOUSE_LEVEL            2014
#define  HOUSE_INTERIOR             2015

enum hInfo {
	hLevel,
    Float:ExteriorX,
    Float:ExteriorY,
    Float:ExteriorZ,
    hInterior
};
new HouseInfo[MAX_PLAYERS][hInfo];
CMD:createhouse(playerid,params[])
{
 	ShowPlayerDialog(playerid, HOUSE_MENU, DIALOG_STYLE_LIST, "Bank Menu", "Level\nInterior", "Choose", "Cancel");
	return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == HOUSE_MENU && response)
	{
	   if(listitem == 0)
	   {
          ShowPlayerDialog(playerid, HOUSE_LEVEL, DIALOG_STYLE_INPUT, "House Level", "Alege un level care vrei sa il aiba casa ta.\n" , "Set", "Cancel");
	   }
	   if(listitem == 1)
	   {
          ShowPlayerDialog(playerid, HOUSE_INTERIOR, DIALOG_STYLE_INPUT, "House Interior", "Alege un interior care vrei sa il aiba casa ta.\n" , "Set", "Cancel");

	   }
	}
	if(dialogid == HOUSE_LEVEL && response)
	{
	   new str[120];
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_LEVEL, DIALOG_STYLE_INPUT, "House Level", "Alege un level care vrei sa il aiba casa ta.\n" , "Set", "Cancel");
	   format(str, sizeof str, "Ai setat level %d casei tale", strval(inputtext));
	   HouseInfo[playerid][hLevel] = strval(inputtext)
	   ShowPlayerDialog(playerid,HOUSE_INTERIOR, DIALOG_STYLE_INPUT, "House INT", "Alege interiorul casei:", "Set", "Cancel");

	}
	if(dialogid == HOUSE_INTERIOR && response)
	{
       new str[120];
       new Float:x, Float:y, Float:z;
       GetPlayerPos(playerid, x, y, z);
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_INTERIOR, DIALOG_STYLE_INPUT, "House Interior", "Alege un level care vrei sa il aiba casa ta.\n" , "Set", "Cancel");
	   format(str, sizeof str, "Ai setat interiorul %d", strval(inputtext));
	   HouseInfo[playerid][hInterior] = strval(inputtext)
	   CreateDynamicPickup(1273, 4, x, y, z, -1, strval(inputtext), -1,100.0);
	}
	return 1;
}
P.S : I do not want to save anything at this moment
Reply
#2

Good Enough, My own suggestion to make a system and do not get conflicted while working is following these steps.

1. Put a define for only a one part of this system.
2. Put the enums related to that part.
3. Saving stuff of that part.
4. The Commands, Dialogs related to that part.

I suggest also that the first part which you start with, Is to be the basic, Like the X, Y, Z, icon enums, etc..
Reply
#3

Cough up the fact that you're using retarded macros. It's reccomended that you use enums.#

PHP код:
#define  HOUSE_MENU              2013
#define  HOUSE_LEVEL            2014
#define  HOUSE_INTERIOR             2015 
EQUALS

PHP код:
enum
{
    
HOUSE_MENU,
    
HOUSE_LEVEL,
    
HOUSE_INTERIOR

For the hInfo enum, you're missing the House Interior X, Y and Z, along with the house ID, as a bare minimum.

PHP код:
enum hInfo {
    
hID//house id
    
hLevel,
    
Float:hEX//house exterior X
    
Float:hEY
    
Float:hEZ,
    
Float:hIX//house interior x
    
Float:hIY,
    
Float:hIZ,
    
hInterior
}; 
Reply
#4

Erm, not, it does not equal that, and doing it this way would introduce dialog id collisions.
You'd have to use something like
pawn Код:
enum
{
    HOUSE_MENU = 2013,
    HOUSE_LEVEL,
    HOUSE_INTERIOR
}
Good article about it: https://sampforum.blast.hk/showthread.php?tid=318307
Reply
#5

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Erm, not, it does not equal that, and doing it this way would introduce dialog id collisions.
You'd have to use something like
pawn Код:
enum
{
    HOUSE_MENU = 2013,
    HOUSE_LEVEL,
    HOUSE_INTERIOR
}
Good article about it: https://sampforum.blast.hk/showthread.php?tid=318307
I think you are wrong! As I have read that article now, he says this part
Quote:

The pre-compiler automatically sets the values of these constants starting from 0 to .. n
Whereas in making constants, you are the one who has to assign it. But in enum, it's automatically structured.

In an enum it's automatically set from number 0 etc. Or Im I wrong?
Reply
#6

Yes it does, but xLucy was wrong in saying that OP's defines are equal enum starting with 0. What do you think will happen when you have something like this:
pawn Код:
enum
{
    HOUSE_MENU,
    HOUSE_LEVEL,
    HOUSE_INTERIOR
}

enum
{
    OTHER_MENU,
    OTHER_LEVEL,
    OTHER_INTERIOR
}

ShowPlayerDialog(playerid, OTHER_MENU, (...));

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == HOUSE_MENU) {
        SendClientMessage(playerid, -1, "OOPS!");
    }
}
Reply
#7

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Yes it does, but xLucy was wrong in saying that OP's defines are equal enum starting with 0. What do you think will happen when you have something like this:
pawn Код:
enum
{
    HOUSE_MENU,
    HOUSE_LEVEL,
    HOUSE_INTERIOR
}

enum
{
    OTHER_MENU,
    OTHER_LEVEL,
    OTHER_INTERIOR
}

ShowPlayerDialog(playerid, OTHER_MENU, (...));

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == HOUSE_MENU) {
        SendClientMessage(playerid, -1, "OOPS!");
    }
}
Aah now I get you, house menu and other menu would conflict
Reply
#8

I tried again to reset the script
But now that I want to create a house, the pickup does not appear.


Код:
#include 			<a_samp>
#include 			<a_npc>
#include 			<zcmd>
#include 			<foreach>
#include            <sscanf2>
#include 			<streamer>
#include 			<YSI\y_ini>

#define COLOR_GREY       0xAFAFAFAA
#define COLOR_BLUE2      0x4682B4FF
#define COLOR_RED        0xFF0000AA
#define COLOR_YELLOW     0xE9E312FF
#define COLOR_ORANGE     0xFF9900AA
#define COLOR_WHITE      0xFFFEFFFF
#define COLOR_GREEN      0x33AA33AA
#define COLOR_BLUE       0x0000FFFF
#define COLOR_LIGHTGREEN 0x90EE90FF
#define COLOR_OLIVE      0x808000FF
#define COLOR_SALAMON    0xFA8072FF
#define COLOR_BLACK      0x000000FF

enum
{
    HOUSE_MENU,
    HOUSE_LEVEL,
    HOUSE_INTERIOR,
    HOUSE_PRICE
}

enum hInfo {
    hOwner[24],
    hID, //house id
    hLevel,
    Text3D:hLabel,
    Float:hEX, //house exterior X
    Float:hEY,
    Float:hEZ,
    Float:hIX, //house interior x
    Float:hIY,
    Float:hIZ,
    hInterior,
    hPickup,
    hPrice
};
new HouseInfo[MAX_PLAYERS][hInfo];
new HouseCount;
#define HousePATH "House/%d.ini"
#define MAX_HOUSES 100

CMD:createhouse(playerid,params[])
{
 	ShowPlayerDialog(playerid, HOUSE_MENU, DIALOG_STYLE_LIST, "House Menu", "Cereaza o noua casa", "Create", "Cancel");
	return 1;
}
CMD:buyhouse(playerid,params[])
{
    new pName[MAX_PLAYER_NAME]; //For the player's name - For the house
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME); //Get the name of the player and store it in pName
    for(new i = 0; i < MAX_HOUSES; i++) //Last time I'm gonna say it: Loop through all the houses
    {
        if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hEX], HouseInfo[i][hEY], HouseInfo[i][hEZ])) //Is player near house entrance, and if player is in interior of that house + virtual world (Last time I said this too!)
        {
            if(HouseInfo[i][hOwner]) return SendClientMessage(playerid, COLOR_RED, "This house is already owned!"); //Is the house owned? Then send message that it's owned and stop.
            if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money for this!"); //Has player too less money? Send him a message!

            HouseInfo[i][hOwner] = true; //The house is owned, where the player used /buyhouse
            strmid(HouseInfo[i][hOwner], pName, 0, false, strlen(pName)); //Put the players name into the "hOwner" of the house
            GivePlayerMoney(playerid, -HouseInfo[i][hPrice]); //Remove some money of the player.. The value of the house
            SendClientMessage(playerid, COLOR_GREEN, "House bought!"); //Send the player an message.
            return 1;
        }
    }
    return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == HOUSE_MENU && response)
	{
	   if(listitem == 0)
	   {
          ShowPlayerDialog(playerid, HOUSE_LEVEL, DIALOG_STYLE_INPUT, "House Menu", "Creeaza o noua casa.\n" , "Create", "Cancel");
	   }
	}
	if(dialogid == HOUSE_LEVEL && response)
	{
	   new str[120];
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_LEVEL, DIALOG_STYLE_INPUT, "House Level", "Alege un level care vrei sa il aiba casa ta.\n" , "Set", "Cancel");
	   format(str, sizeof str, "Ai setat level %d casei tale", strval(inputtext));
	   HouseInfo[playerid][hLevel] = strval(inputtext);
       new INI:File = INI_Open(HousePath());
       INI_WriteInt(File, "HouseLevel", HouseInfo[playerid][hLevel]);
       INI_Close(File);
	   ShowPlayerDialog(playerid,HOUSE_INTERIOR, DIALOG_STYLE_INPUT, "House INT", "Alege interiorul casei:", "Set", "Cancel");
	}
	if(dialogid == HOUSE_INTERIOR && response)
	{
       new str[120];
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_INTERIOR, DIALOG_STYLE_INPUT, "House Interior", "Alege un level care vrei sa il aiba casa ta.\n" , "Set", "Cancel");
	   format(str, sizeof str, "Ai setat interiorul %d", strval(inputtext));
	   HouseInfo[playerid][hInterior] = strval(inputtext);
	   ShowPlayerDialog(playerid, HOUSE_PRICE, DIALOG_STYLE_INPUT, "House Price", "Alege pretul casei.\n" , "Set", "Cancel");
	}
	if(dialogid == HOUSE_PRICE && response)
	{
	   new str[120],hprice, Float:X, Float:Y, Float:Z;
	   HouseInfo[playerid][hPrice] = hprice;
	   new Float:x, Float:y, Float:z;
       GetPlayerPos(playerid, x, y, z);
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_PRICE, DIALOG_STYLE_INPUT, "House Price", "Alege pretul casei.\n" , "Set", "Cancel");
	   format(str, sizeof str, "Casa costa %d$", strval(inputtext));
	   HouseInfo[playerid][hPrice] = strval(inputtext);
       new INI:File = INI_Open(HousePath());
       INI_WriteInt(File, "HousePrice", HouseInfo[playerid][hPrice]);
       INI_Close(File);
   	   new string[128];
	   format(string, sizeof string, "Owner : brak \n" "Pret : %d\n", hprice);
	   HouseInfo[playerid][hLabel] = Create3DTextLabel(string, COLOR_RED, X, Y, Z, 7.0, 0);
	   HouseInfo[playerid][hPickup] = CreatePickup(1242, 2, X, Y, Z, -1);
	}
	return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
	new INI:File = INI_Open(HousePath());
	INI_SetTag(File,"data");
	INI_WriteString(File, "Owned", HouseInfo[playerid][hOwner]);
	INI_WriteInt(File, "HouseID", HouseInfo[playerid][hID]);
	INI_WriteInt(File, "HouseLevel", HouseInfo[playerid][hLevel]);
	INI_WriteInt(File, "HousePrice", HouseInfo[playerid][hPrice]);
	INI_WriteFloat(File, "HEX", HouseInfo[playerid][hEX]);
	INI_WriteFloat(File, "HEY", HouseInfo[playerid][hEY]);
	INI_WriteFloat(File, "HEZ", HouseInfo[playerid][hEZ]);
	INI_WriteFloat(File, "HIZ", HouseInfo[playerid][hIX]);
	INI_WriteFloat(File, "HIY", HouseInfo[playerid][hIY]);
	INI_WriteFloat(File, "HIZ", HouseInfo[playerid][hIZ]);
	INI_WriteInt(File, "HInt", HouseInfo[playerid][hInterior]);
	INI_Close(File);
    return 1;
 }
main()
{
	print("\n----------------------------------");
	print("  Bare Script\n");
	print("----------------------------------\n");
}

public OnPlayerConnect(playerid)
{
	GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	new idx;
	new cmd[256];
	
	cmd = strtok(cmdtext, idx);

	if(strcmp(cmd, "/yadayada", true) == 0) {
    	return 1;
	}

	return 0;
}

public OnPlayerSpawn(playerid)
{
	SetPlayerInterior(playerid,0);
	TogglePlayerClock(playerid,0);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
   	return 1;
}

SetupPlayerForClassSelection(playerid)
{
 	SetPlayerInterior(playerid,14);
	SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
	SetPlayerFacingAngle(playerid, 270.0);
	SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
	SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}

public OnPlayerRequestClass(playerid, classid)
{
	SetupPlayerForClassSelection(playerid);
	return 1;
}

public OnGameModeInit()
{
	SetGameModeText("Bare Script");
	ShowPlayerMarkers(1);
	ShowNameTags(1);
	AllowAdminTeleport(1);

	AddPlayerClass(265,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);

	return 1;
}

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;
}
stock HousePath()
{
	new string[256];
	format(string, sizeof string, HousePATH, HouseCount);
	return string;
}
Reply
#9

Inside your OnDialogResponse, there doesn't seem to be any code to actually add house or pickups - the first block is the one you want. You only create pickups when the house price changes somehow.
Reply
#10

now it's good?

Код:
#include 			<a_samp>
#include 			<a_npc>
#include 			<zcmd>
#include 			<foreach>
#include            <sscanf2>
#include 			<streamer>
#include 			<YSI\y_ini>

#define COLOR_GREY       0xAFAFAFAA
#define COLOR_BLUE2      0x4682B4FF
#define COLOR_RED        0xFF0000AA
#define COLOR_YELLOW     0xE9E312FF
#define COLOR_ORANGE     0xFF9900AA
#define COLOR_WHITE      0xFFFEFFFF
#define COLOR_GREEN      0x33AA33AA
#define COLOR_BLUE       0x0000FFFF
#define COLOR_LIGHTGREEN 0x90EE90FF
#define COLOR_OLIVE      0x808000FF
#define COLOR_SALAMON    0xFA8072FF
#define COLOR_BLACK      0x000000FF

enum
{
    HOUSE_MENU,
    HOUSE_LEVEL,
    HOUSE_INTERIOR,
    HOUSE_PRICE,
    HOUSE_BUY,
    HOUSE_ID
}

enum hInfo {
    bool:hOwned,
    hOwner[MAX_PLAYER_NAME],
    hID, //house id
    hLevel,
    Text3D:hLabel,
    Float:hEX, //house exterior X
    Float:hEY,
    Float:hEZ,
    Float:hIX, //house interior x
    Float:hIY,
    Float:hIZ,
    hInterior,
    hPickup,
    hPrice
};
new HouseInfo[MAX_PLAYERS][hInfo];
new HouseCount;
new houseid;

#define HousePATH "House/%d.ini"
#define MAX_HOUSES 100

forward LoadHouse_data(playerid, name[], value[]);
public LoadHouse_data(playerid, name[], value[])
{
	new Name[24], string[128];
	GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
	INI_String("Owner", Name, 48);
	INI_Float("HEX", HouseInfo[playerid][hEX]);
	INI_Float("HEY", HouseInfo[playerid][hEY]);
	INI_Float("HEZ", HouseInfo[playerid][hEZ]);
	INI_Float("HIX", HouseInfo[playerid][hIX]);
	INI_Float("HIY", HouseInfo[playerid][hIY]);
	INI_Float("HIZ", HouseInfo[playerid][hIZ]);
	INI_Int("hInterior", HouseInfo[playerid][hInterior]);
	INI_Int("hPick", HouseInfo[playerid][hPickup]);
	INI_Int("hPrice", HouseInfo[playerid][hPrice]);
	INI_Int("HouseID", HouseInfo[playerid][hID]);
	INI_Int("HouseLevel", HouseInfo[playerid][hLevel]);
	INI_Int("HousePrice", HouseInfo[playerid][hPrice]);

	if(HouseInfo[playerid][hOwner] == 1)
	{
    	format(string, sizeof string, "Owner : " "%s \n", Name);
    	HouseInfo[playerid][hLabel] = Create3DTextLabel(string, COLOR_RED, HouseInfo[playerid][hEX], HouseInfo[playerid][hEY], HouseInfo[playerid][hEZ], 7.0, 0);
    	HouseInfo[houseid][hPickup] = CreateDynamicCP(HouseInfo[playerid][hEX], HouseInfo[playerid][hEY], HouseInfo[playerid][hEZ], 2, 0, 0, 0, 20);
	}
	else
	{
    	format(string, sizeof string, "Owner : " "The State \n" "Pret : " "%d\n", HouseInfo[playerid][hPrice]);
    	HouseInfo[playerid][hLabel] = Create3DTextLabel(string, COLOR_RED, HouseInfo[playerid][hEX], HouseInfo[playerid][hEY], HouseInfo[playerid][hEZ], 7.0, 0);
    	HouseInfo[houseid][hPickup] = CreateDynamicCP(HouseInfo[playerid][hEX], HouseInfo[playerid][hEY], HouseInfo[playerid][hEZ], 2, 0, 0, 0, 20);
    }
	return 1;
}

CMD:givemoney(playerid, params[])
{
    new targetid, amount;
    if(sscanf(params, "ud", targetid, amount)) return SendClientMessage(playerid, -1, "usage - /givemoney <playerid/part of name> <amount>");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Player is not connected");
	GivePlayerMoney(targetid, amount);
	SetPlayerScore(targetid, GetPlayerScore(targetid) + 1);
	return 1;
}

CMD:createhouse(playerid,params[])
{
 	ShowPlayerDialog(playerid, HOUSE_LEVEL, DIALOG_STYLE_INPUT, "House ID", "ID-ul casei.\n" , "Set", "Cancel");
	return 1;
}
CMD:buyhouse(playerid,params[])
{
	for(new h = 0; h < MAX_HOUSES; h++)
    {
		if(!fexist(HousePath()))
		{
			INI_ParseFile(HousePath(), "LoadHouse_%d", .bExtra = true, .extra = playerid);
  			ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_MSGBOX, "House Sistem", "Asta este casa ta ,vrei sa intri in ea? ", "Da", "Nu");
		}
 		else
		{
 			ShowPlayerDialog(playerid, HOUSE_BUY, DIALOG_STYLE_MSGBOX, "House Sistem", "Vrei sa cumperi aceasta casa? ", "Da", "Nu");
		}
    }
   	return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == HOUSE_BUY)
	{
		if(response)
		{
            if(GetPlayerMoney(playerid) > HouseInfo[playerid][hPrice])
	    	{
            	SendClientMessage(playerid, COLOR_GREEN, "House created ");

            	new string[128];
            	format(string, sizeof string, "House ID : %d" "Owner: %s \n",HouseInfo[playerid][hID], PlayerName(playerid));
             	Update3DTextLabelText(HouseInfo[playerid][hLabel], COLOR_RED, string);

            	new INI:File = INI_Open(HousePath());
				INI_WriteString(File, "Owned", PlayerName(playerid));
				INI_WriteInt(File, "HouseID", HouseInfo[playerid][hID]);
				INI_WriteInt(File, "HouseLevel", HouseInfo[playerid][hLevel]);
				INI_WriteInt(File, "HousePrice", HouseInfo[playerid][hPrice]);
				INI_WriteFloat(File, "HEX", HouseInfo[playerid][hEX]);
				INI_WriteFloat(File, "HEY", HouseInfo[playerid][hEY]);
				INI_WriteFloat(File, "HEZ", HouseInfo[playerid][hEZ]);
				INI_WriteFloat(File, "HIZ", HouseInfo[playerid][hIX]);
				INI_WriteFloat(File, "HIY", HouseInfo[playerid][hIY]);
				INI_WriteFloat(File, "HIZ", HouseInfo[playerid][hIZ]);
				INI_WriteInt(File, "HInt", HouseInfo[playerid][hInterior]);
            	INI_Close(File);
		    }
		    else SendClientMessage(playerid, COLOR_LIGHTGREEN, "You can not afford this house! ");
    	}
	}
	if(dialogid == HOUSE_ID && response)
	{
	   new str[120];
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_LEVEL, DIALOG_STYLE_INPUT, "House ID", "ID-ul casei.\n" , "Set", "Cancel");
	   format(str, sizeof str, "ID-ul casei este %d casei tale", strval(inputtext));
	   HouseInfo[playerid][hID] = strval(inputtext);
       new INI:File = INI_Open(HousePath());
       INI_WriteInt(File, "HouseID", HouseInfo[playerid][hID]);
       INI_Close(File);
	   ShowPlayerDialog(playerid, HOUSE_LEVEL, DIALOG_STYLE_INPUT, "House Level", "Alege un level care vrei sa il aiba casa ta.\n" , "Set", "Cancel");
	}
	if(dialogid == HOUSE_LEVEL && response)
	{
	   new str[120];
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_LEVEL, DIALOG_STYLE_INPUT, "House Level", "Alege un level care vrei sa il aiba casa ta.\n" , "Set", "Cancel");
	   format(str, sizeof str, "Ai setat level %d casei tale", strval(inputtext));
	   HouseInfo[playerid][hLevel] = strval(inputtext);
       new INI:File = INI_Open(HousePath());
       INI_WriteInt(File, "HouseLevel", HouseInfo[playerid][hLevel]);
       INI_Close(File);
	   ShowPlayerDialog(playerid,HOUSE_INTERIOR, DIALOG_STYLE_INPUT, "House INT", "Alege interiorul casei:", "Set", "Cancel");
	}
	if(dialogid == HOUSE_INTERIOR && response)
	{
       new str[120];
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_INTERIOR, DIALOG_STYLE_INPUT, "House Interior", "Alege un level care vrei sa il aiba casa ta.\n" , "Set", "Cancel");
	   format(str, sizeof str, "Ai setat interiorul %d", strval(inputtext));
	   HouseInfo[playerid][hInterior] = strval(inputtext);
	   ShowPlayerDialog(playerid, HOUSE_PRICE, DIALOG_STYLE_INPUT, "House Price", "Alege pretul casei.\n" , "Set", "Cancel");
	}
	if(dialogid == HOUSE_PRICE && response)
	{
	   new str[120],hprice, Float:X, Float:Y, Float:Z;
	   GetPlayerPos(playerid, X, Y, Z);
	   HouseInfo[playerid][hPrice] = hprice;
	   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_PRICE, DIALOG_STYLE_INPUT, "House Price", "Alege pretul casei.\n" , "Set", "Cancel");
	   format(str, sizeof str, "Casa costa %d$", strval(inputtext));
	   HouseInfo[playerid][hPrice] = strval(inputtext);
       new INI:File = INI_Open(HousePath());
       INI_WriteInt(File, "HousePrice", HouseInfo[playerid][hPrice]);
       INI_Close(File);
   	   new string[128];
	   format(string, sizeof string, "Owner : brak \n" "Pret : %d\n", hprice);
	   HouseInfo[playerid][hLabel] = Create3DTextLabel(string, COLOR_RED, X, Y, Z, 7.0, 0);
	   HouseInfo[playerid][hPickup] = CreateDynamicPickup(1273, 1, X, Y, X, -1, -1, -1, 100.0);
	}
	return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
	new INI:File = INI_Open(HousePath());
	INI_SetTag(File,"data");
	INI_WriteString(File, "Owned", HouseInfo[playerid][hOwner]);
	INI_WriteInt(File, "HouseID", HouseInfo[playerid][hID]);
	INI_WriteInt(File, "HouseLevel", HouseInfo[playerid][hLevel]);
	INI_WriteInt(File, "HousePrice", HouseInfo[playerid][hPrice]);
	INI_WriteFloat(File, "HEX", HouseInfo[playerid][hEX]);
	INI_WriteFloat(File, "HEY", HouseInfo[playerid][hEY]);
	INI_WriteFloat(File, "HEZ", HouseInfo[playerid][hEZ]);
	INI_WriteFloat(File, "HIZ", HouseInfo[playerid][hIX]);
	INI_WriteFloat(File, "HIY", HouseInfo[playerid][hIY]);
	INI_WriteFloat(File, "HIZ", HouseInfo[playerid][hIZ]);
	INI_WriteInt(File, "HInt", HouseInfo[playerid][hInterior]);
	INI_Close(File);
    return 1;
 }
main()
{
	print("\n----------------------------------");
	print("  Bare Script\n");
	print("----------------------------------\n");
}

public OnPlayerConnect(playerid)
{
	GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	new idx;
	new cmd[256];
	
	cmd = strtok(cmdtext, idx);

	if(strcmp(cmd, "/yadayada", true) == 0) {
    	return 1;
	}

	return 0;
}

public OnPlayerSpawn(playerid)
{
	SetPlayerInterior(playerid,0);
	TogglePlayerClock(playerid,0);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
   	return 1;
}

SetupPlayerForClassSelection(playerid)
{
 	SetPlayerInterior(playerid,14);
	SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
	SetPlayerFacingAngle(playerid, 270.0);
	SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
	SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}

public OnPlayerRequestClass(playerid, classid)
{
	SetupPlayerForClassSelection(playerid);
	return 1;
}

public OnGameModeInit()
{
	SetGameModeText("Bare Script");
	ShowPlayerMarkers(1);
	ShowNameTags(1);
	AllowAdminTeleport(1);

	AddPlayerClass(265,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);

	return 1;
}

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;
}
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)