22.10.2012, 15:15
Click Here to watch the video please.
I can't solve this problem. I have tried everything. here is my script:
Can anyone help me?
I can't solve this problem. I have tried everything. here is my script:
pawn Код:
#define FILTERSCRIPT
#include <a_samp>
#include <SII>
#include <sscanf2>
#include <zcmd>
#include <foreach>
#define MAX_HOUSES 100
#define red 0xFF0000FF
#define green 0x00FF00AA
enum HInfo {
HouseName[28],
Price,
ForSale,
Float:XPos,
Float:YPos,
Float:ZPos,
Owner[MAX_PLAYER_NAME],
Float:SpawnXPos,
Float:SpawnYPos,
Float:SpawnZPos,
HouseInterior,
VirtualWorld,
Text3D:HouseLabel
};
new HouseInfo[MAX_HOUSES][HInfo];
new HouseCount;
new HouseEnter[MAX_HOUSES];
new PlayerInHouseID[MAX_PLAYERS];
new Iterator:Houses<MAX_HOUSES>;
COMMAND:createhouse(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new HousePrice,id = HouseCount;
if(sscanf(params, "i", HousePrice)) return SendClientMessage(playerid, red, "Usage: /createhouse [price]");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(HouseInfo[id][HouseName], 28, "House For Sale!");
HouseInfo[id][Price] = HousePrice;
HouseInfo[id][ForSale] = 1;
HouseInfo[id][XPos] = x;
HouseInfo[id][YPos] = y;
HouseInfo[id][ZPos] = z;
HouseInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
format(HouseInfo[id][Owner], MAX_PLAYER_NAME, "None");
SendClientMessage(playerid, green, "House Created!");
HouseEnter[id] = CreatePickup(1273, 1, x, y, z, 0);
new file[20], labelstring[128];
format(file, sizeof(file), "Houses/%i.ini", id);
INI_Open(file);
INI_WriteString("HouseName", "House For Sale!");
INI_WriteInt("Price",HousePrice);
INI_WriteInt("ForSale", 1);
INI_WriteFloat("XPos", x);
INI_WriteFloat("YPos", y);
INI_WriteFloat("ZPos", z);
INI_WriteInt("VirtualWorld", GetPlayerVirtualWorld(playerid));
INI_WriteString("Owner", "None");
INI_Save();
INI_Close();
format(labelstring, sizeof(labelstring), "HouseName: {FFFFFF}House For Sale! \n{FF0000}ForSale: {FFFFFF}Yes\n{FF0000}Price: {FFFFFF}%i\n{FF0000}Owner: {FFFFFF}None", HousePrice);
HouseInfo[id][HouseLabel] = Create3DTextLabel(labelstring, 0xFF0000FF, x, y, z, 25.0, GetPlayerVirtualWorld(playerid));
HouseCount++;
Iter_Add(Houses, id);
return 1;
}
COMMAND:buy(playerid, params[])
{
foreach(Houses, i)
{
if(!IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[i][XPos], HouseInfo[i][YPos], HouseInfo[i][ZPos])) continue;
if(GetPlayerMoney(playerid) < HouseInfo[i][Price]) return SendClientMessage(playerid, red, "Error: You don't have enough money");
if(HouseInfo[i][ForSale] == 0) return SendClientMessage(playerid, red, "Error: This house is not for sale");
HouseInfo[i][ForSale] = 0;
new file[60], pname[24], string[150];
GetPlayerName(playerid, pname, sizeof(pname));
format(HouseInfo[i][Owner], 24, "%s", pname);
format(file, 60, "Houses/%i.ini", i);
format(HouseInfo[i][HouseName], 28, "%s's house", pname);
INI_Open(file);
INI_WriteString("HouseName", HouseInfo[i][HouseName]);
INI_WriteInt("ForSale", 0);
INI_WriteString("Owner", pname);
INI_Save();
INI_Close();
format(string, sizeof(string), "HouseName: {FFFFFF}%s\n{FF0000}ForSale: {FFFFFF}No\n{FF0000}Price: {FFFFFF}%i\n{FF0000}Owner: {FFFFFF}%s", HouseInfo[i][HouseName], HouseInfo[i][Price], pname);
Update3DTextLabelText(HouseInfo[i][HouseLabel], red, string);
GivePlayerMoney(playerid, -HouseInfo[i][Price]);
DestroyPickup(HouseEnter[i]);
HouseEnter[i] = CreatePickup(1272, 1, HouseInfo[i][XPos], HouseInfo[i][YPos], HouseInfo[i][ZPos], 0);
}
SendClientMessage(playerid, red, "Error: You are not in a house pickup");
return 1;
}
COMMAND:sell(playerid,params[])
{
foreach(Houses, i)
{
if(!IsPlayerInRangeOfPoint(playerid,1.0,HouseInfo[i][XPos],HouseInfo[i][YPos],HouseInfo[i][ZPos])) continue;
if(HouseInfo[i][ForSale] == 1) return SendClientMessage(playerid,red,"This house isn't owned");
new pName[24];
GetPlayerName(playerid,pName,sizeof(pName));
if(HouseInfo[i][ForSale] == 0 && strcmp(pName,HouseInfo[i][Owner]) != 0) return SendClientMessage(playerid,-1,"You aren't the owner of this house!");
HouseInfo[i][ForSale] = 1;
new file[60],string[128];
format(HouseInfo[i][HouseName], 28, "House For Sale!");
format(HouseInfo[i][Owner],24,"Nonusablenameforthishouse");
format(file,sizeof(file),"Houses/%i.ini",i);
INI_Open(file);
INI_WriteString("HouseName", "House For Sale!");
INI_WriteInt("ForSale",1);
INI_WriteString("Owner","Nonusablenameforthishouse");
INI_Save();
INI_Close();
format(string,sizeof(string),"HouseName: {FFFFFF}House For Sale!\n{FF0000}ForSale: {FFFFFF}Yes\n{FF0000}Price: {FFFFFF}%i\n{FF0000}Owner: {FFFFFF}None",HouseInfo[i][Price]);
Update3DTextLabelText(HouseInfo[i][HouseLabel],red,string);
GivePlayerMoney(playerid, HouseInfo[i][Price]);
DestroyPickup(HouseEnter[i]);
HouseEnter[i] = CreatePickup(1273, 1, HouseInfo[i][XPos], HouseInfo[i][YPos], HouseInfo[i][ZPos], 0);
}
SendClientMessage(playerid,red,"You aren't near a house!");
return 1;
}
COMMAND:enter(playerid, params[])
{
foreach(Houses, i)
{
if(!IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][XPos], HouseInfo[i][YPos], HouseInfo[i][ZPos])) continue;
new pName[24];
GetPlayerName(playerid, pName, sizeof(pName));
if(HouseInfo[i][ForSale] == 0 && strcmp(HouseInfo[i][Owner],pName) == 0)
{
SetPVarInt(playerid,"PlayersInteriorHouse",GetPlayerInterior(playerid));
SetPVarInt(playerid,"PlayerVirtualWorldHouse",GetPlayerVirtualWorld(playerid));
SetPlayerInterior(playerid,12);
SetPlayerPos(playerid,446.7281,507.0475,1001.4195);
SetPlayerVirtualWorld(playerid,HouseInfo[i][VirtualWorld]);
PlayerInHouseID[playerid] = i;
}
if(HouseInfo[i][ForSale] == 0 && strcmp(HouseInfo[i][Owner],pName) != 0)
{
SendClientMessage(playerid, red, "Error: This house is not yours");
}
if(HouseInfo[i][ForSale] == 1)
{
SendClientMessage(playerid, green, "This house is for sale! You can buy it using /buy!");
}
}
SendClientMessage(playerid, red, "Error: You are not in a house Pickup");
return 1;
}
COMMAND:exit(playerid, params[])
{
foreach(Houses, i)
{
if(PlayerInHouseID[playerid] != -1)
{
SetPlayerPos(playerid, HouseInfo[i][XPos], HouseInfo[i][YPos], HouseInfo[i][ZPos]);
SetPlayerInterior(playerid,GetPVarInt(playerid,"PlayersInteriorHouse"));
SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"PlayerVirtualWorldHouse"));
PlayerInHouseID[playerid] = 0;
}
else return SendClientMessage(playerid, red, "You are not in a house");
}
return 1;
}
public OnFilterScriptInit()
{
LoadHouses();
return 1;
}
stock LoadHouses()
{
new file[60],houseowner[24], housename[30];
for(new i = 0; i < MAX_HOUSES; i++)
{
format(file,sizeof(file),"Houses/%i.ini",i);
if(!INI_Exist(file)) return 0;
INI_Open(file);
INI_ReadString(housename, "HouseName");
HouseInfo[i][Price] = INI_ReadInt("Price");
HouseInfo[i][ForSale] = INI_ReadInt("ForSale");
HouseInfo[i][XPos] = INI_ReadFloat("XPos");
HouseInfo[i][YPos] = INI_ReadFloat("YPos");
HouseInfo[i][ZPos] = INI_ReadFloat("ZPos");
HouseInfo[i][VirtualWorld] = INI_ReadInt("VirtualWorld");
INI_ReadString(houseowner,"Owner");
format(HouseInfo[i][Owner],24,"%s",houseowner);
format(HouseInfo[i][HouseName], 28, "%s", housename);
new labelstring[150];
switch(HouseInfo[i][ForSale])
{
case 0:
{
HouseEnter[i] = CreatePickup(1272, 1, HouseInfo[i][XPos], HouseInfo[i][YPos], HouseInfo[i][ZPos], 0);
format(labelstring,sizeof(labelstring),"HouseName: {FFFFFF}%s\n{FF0000}ForSale: {FFFFFF}No\n{FF0000}Price: {FFFFFF}%i\n{FF0000}Owner: {FFFFFF}%s",housename,HouseInfo[i][Price],houseowner);
}
case 1:
{
HouseEnter[i] = CreatePickup(1273, 1, HouseInfo[i][XPos], HouseInfo[i][YPos], HouseInfo[i][ZPos], 0);
format(labelstring,sizeof(labelstring),"HouseName: {FFFFFF}House For Sale!\n{FF0000}ForSale: {FFFFFF}Yes\n{FF0000}Price: {FFFFFF}%i",HouseInfo[i][Price]);
}
}
HouseInfo[i][HouseLabel] = Create3DTextLabel(labelstring,red,HouseInfo[i][XPos],HouseInfo[i][YPos],HouseInfo[i][ZPos],25.0,HouseInfo[i][VirtualWorld]);
HouseCount++;
Iter_Add(Houses, i);
INI_Close();
}
return 1;
}
public OnFilterScriptExit()
{
foreach(Houses, i)
{
DestroyPickup(HouseEnter[i]);
Delete3DTextLabel(HouseInfo[i][HouseLabel]);
}
return 1;
}