04.05.2010, 13:27
hi i have a proble with a house system that i saw and i dont really have and idea of whats wrong with the script because everything works just fine ..but when i do /enter into the house it sends me to the house interior but nothing will apear only all blue around the interior wont load can someone help me here is the script
pawn Код:
#include <a_samp>
#include <dini>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 //CREDIT: DracoBlue
#pragma unused strtok
#define MAX_MARKERS 1000 //Max amount of markers (Increasing causes the file to be larger decreasing does the opposite.
enum Info
{
Float:x, //XPos
Float:y, //YPos
Float:z, //ZPos
markertype, //Marker type
color, //Color of the marker
Float:Dist
};
#define MAX_HOUSES 400
enum houseinfo
{
HouseNames[60], //To save into the file
HouseCost, //The house cost
HouseOwner[24], // The house owners Name
Float:PickupX, // PickupX
Float:PickupY, //PickupY
Float:PickupZ, //PickupZ
Float:TeleX, //The house location
Float:TeleY, //The house location
Float:TeleZ, //The house location
Interior, //The house Interior
HouseSell, //House sell price
Owned,
Virtual,
Icon,
Opened
};
new HouseInfo[MAX_HOUSES][houseinfo]; //It saves all the info in this variable.
new HouseCount = -1; //House count
new PickupID[MAX_HOUSES];
new InHouse[MAX_PLAYERS] = -1;
new Invited[MAX_PLAYERS] = -1;
new House[MAX_PLAYERS] = -1;
new Keys[MAX_PLAYERS][MAX_HOUSES];
new MarkerInfo[MAX_MARKERS][Info];
new MarkerID = -1;
new PlayerMarkers[MAX_PLAYERS][MAX_MARKERS];
new MarkerUsed[MAX_MARKERS];
new IconID[MAX_PLAYERS][MAX_MARKERS];
new SlotsUsed[MAX_PLAYERS][100];
new Visiting[MAX_PLAYERS];
new TimeR[MAX_PLAYERS];
new HouseSpawn[MAX_PLAYERS];
public OnPlayerRequestClass(playerid, classid)
{
Invited[playerid] = -1;
InHouse[playerid] = -1;
House[playerid] = -1;
new Pname[24], File[65]; GetPlayerName(playerid, Pname, 24);
for(new V=0; V<HouseCount + 1; V++)
{
if(!strcmp(HouseInfo[V][HouseOwner], Pname, true))
{
House[playerid] = V;
break;
}
}
if(dini_Exists(File))
{
for(new K=0; K<HouseCount + 1; K++)
{
format(File, sizeof(File), "HouseKeys/%s.ini", HouseInfo[K][HouseNames]);
if(dini_Int(File, Pname) == 1) Keys[playerid][K] = 1;
}
}
return 1;
}
public OnFilterScriptInit()
{
//CreateHouse(Filename[], Cost, Float:Pickupx, Float:Pickupy, Float:Pickupz, Float:Telex, Float:Teley, Float:Telez, interior, sell)
CreateHouse("House1 ", 1000000, 2386.595458, -1279.956298,24.571260,2393.593994,-1279.412597,29.558284 , 1, 7000000);
CreateHouse("House2 ", 1000000, 2572.757324,-1069.975219,69.297027, 2588.00 , -1071.04 , 74.63 , 1, 6000000);
CreateHouse("House3 ", 1000000, 2250.396240,-1283.030639,25.367187, 2247.938720 , -1275.897583,30.167814, 1, 6000000);
CreateHouse("House4 ", 1000000, 2842.166992,-1335.650268,14.742118, 2845.392578 , -1327.153564,19.070312, 1, 6000000);
CreateHouse("House5 ", 1000000, 2386.595458,-1279.956298,24.571260, 2393.593994 , -1279.412597,29.558284, 1, 6000000);
CreateHouse("House6 ", 1000000, 2486.109863,-2017.428710,13.546875, 2486.116210 , -2027.527465,18.928577, 1, 6000000);
CreateHouse("House7 ", 1000000, 1985.299560,-1719.062377,15.969563, 1974.645629 , -1719.222290,24.899938, 1, 1000000);
CreateHouse("House8 ", 1000000, 1873.466308,-2066.403076,15.021305, 1874.239501 , -2075.446044,20.578399, 1, 1000000);
CreateHouse("House9 ", 1000000, 1913.679931,-1916.440429,15.028714, 1911.847045 , -1907.851440,19.920385, 1, 1000000);
CreateHouse("House10 ", 1000000, 2070.322509,-1656.487792,13.546875, 2062.322998 , -1655.953735,18.603935, 1, 1000000);
CreateHouse("House11 ", 1000000, 2384.612792,-1670.749633,14.547527, 2384.623535 , -1680.501708,19.789363, 1, 1000000);
CreateHouse("House12 ", 1000000, 2331.678466,-1681.277465,13.903153, 2322.602294 , -1682.503906,19.234832, 1, 1000000);
SetTimer("Stream", 500, true);
if(!dini_Exists("Owners.ini"))
{
dini_Create("Owners.ini");
}
if(!dini_Exists("Opened.ini"))
{
dini_Create("Opened.ini");
}
if(!dini_Exists("HouseSave.ini"))
{
dini_Create("HouseSave.ini");
}
return 1;
}
stock CreateHouse(Filename[], Cost, Float:Pickupx, Float:Pickupy, Float:Pickupz, Float:Telex, Float:Teley, Float:Telez, interior, sell)
{
HouseCount ++;
new ID = HouseCount; //HouseID
format(HouseInfo[ID][HouseNames], 60, "%s", Filename); //Saves the HouseName into a variable
HouseInfo[ID][HouseCost] = Cost;
HouseInfo[ID][PickupX] = Pickupx;
HouseInfo[ID][Virtual] = 2520000 + ID;
HouseInfo[ID][PickupY] = Pickupy;
HouseInfo[ID][PickupZ] = Pickupz;
HouseInfo[ID][TeleX] = Telex;
HouseInfo[ID][TeleY] = Teley;
HouseInfo[ID][TeleZ] = Telez;
HouseInfo[ID][Interior] = interior;
HouseInfo[ID][HouseSell] = sell;
format(HouseInfo[ID][HouseOwner], 24, "gj9043jg-er)((23");
if(strlen(dini_Get("Owners.ini", Filename))) //This is to see if there is any owner.
{
format(HouseInfo[ID][HouseOwner], 24, "%s", dini_Get("Owners.ini", Filename));
HouseInfo[ID][Owned] = 1;
HouseInfo[ID][Icon] = SetPlayerMapIconEx(Pickupx, Pickupy, Pickupz, 32, 1);
if(dini_Int("Opened.ini", HouseInfo[ID][HouseNames]) == 1) HouseInfo[ID][Opened] = 1;
}
PickupID[ID] = CreatePickup(1273, 23, Pickupx, Pickupy, Pickupz, -1); //Creates the pickup :).
Create3DTextLabel("House", 0x00A0F6AA, Pickupx, Pickupy, Pickupz + 0.75, 15.0, 0, 1);
if(HouseInfo[ID][Owned] == 0) HouseInfo[ID][Icon] = SetPlayerMapIconEx(Pickupx, Pickupy, Pickupz, 31, 1);
}
public OnPlayerPickUpPickup(playerid, pickupid) //Pickup callback
{
for(new J; J<MAX_HOUSES; J++) //Loops through all houses
{
if(pickupid == PickupID[J]) //If the pickupid is one of our house ones
{
new str[75];
if(HouseInfo[J][Owned] == 1)
{
format(str, sizeof(str), "~r~House Info~n~~g~Owner: ~w~%s", HouseInfo[J][HouseOwner]);
SendClientMessage(playerid, 0x67F6F6AA, "/enter to enter this house!");
}
if(HouseInfo[J][Owned] == 0)
{
format(str, sizeof(str), "~r~House Info~n~~g~Owner: ~w~Nobody");
SendClientMessage(playerid, 0x67F6F6AA, "This house is up for sale! Type /buy to buy it");
}
new str2[100];
format(str2, sizeof(str2), "~g~Cost price:~w~ %d ~n~~g~Sell Price:~w~ %d", HouseInfo[J][HouseCost], HouseInfo[J][HouseSell]);
new str3[175];
format(str3, sizeof(str3), "%s~n~%s", str, str2);
GameTextForPlayer(playerid, str3, 3500, 3);
break;
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/buy", cmdtext, true, 10) == 0)
{
if(House[playerid] != -1) return SendClientMessage(playerid, 0xF60000AA, "You already have a house!");
for(new i; i<MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
{
new Pname[24];
if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this house");
if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This house is already owned!");
GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
GameTextForPlayer(playerid, "~r~House Purchased!", 2000, 3);
MarkerInfo[HouseInfo[i][Icon]][markertype] = 31;
HouseInfo[i][Owned] = 1;
House[playerid] = i;
GetPlayerName(playerid, Pname, 24);
format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
dini_Set("Owners.ini", HouseInfo[i][HouseNames], Pname);
return 1;
}
}
SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
return 1;
}
if (strcmp("/sell", cmdtext, true, 10) == 0)
{
for(new i; i<MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
{
new Pname[24]; GetPlayerName(playerid, Pname, 24);
if(House[playerid] != i) return SendClientMessage(playerid, 0xF60000AA, "You don't own this house!");
GivePlayerMoney(playerid, HouseInfo[i][HouseSell]);
GameTextForPlayer(playerid, "~r~House Sold!", 2000, 3);
HouseInfo[i][Owned] = 0;
House[playerid] = -1;
format(HouseInfo[i][HouseOwner], 24, "0943jt3u9*egjlfd");
MarkerInfo[HouseInfo[i][Icon]][markertype] = 32;
dini_Unset("Owners.ini", HouseInfo[i][HouseNames]);
return 1;
}
}
SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
for(new i; i<MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
{
new Pname[24]; GetPlayerName(playerid, Pname, 24);
if(House[playerid] != i && Invited[playerid] != i && Keys[playerid][i] == 0 && HouseInfo[i][Opened] == 0) return SendClientMessage(playerid, 0xF60000AA, "You don't own this house and you have no invite!");
SetPlayerPos(playerid, HouseInfo[i][TeleX], HouseInfo[i][TeleY], HouseInfo[i][TeleZ]);
SetPlayerInterior(playerid, HouseInfo[i][Interior]);
Invited[playerid] = -1;
InHouse[playerid] = i;
SetPlayerVirtualWorld(playerid, HouseInfo[i][Virtual]);
SendClientMessage(playerid, 0x00C4F6AA, "You have entered a house");
return 1;
}
}
SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
return 1;
}
if (strcmp("/Visit", cmdtext, true, 10) == 0)
{
for(new i; i<MAX_HOUSES; i++)
{
if(!IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ])) return SendClientMessage(playerid, 0xF60000AA, "You are not close enough to a house");
new Pname[24]; GetPlayerName(playerid, Pname, 24);
if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "You cannot visit a house that has a owner!");
SetPlayerPos(playerid, HouseInfo[i][TeleX], HouseInfo[i][TeleY], HouseInfo[i][TeleZ]);
SetPlayerInterior(playerid, HouseInfo[i][Interior]);
InHouse[playerid] = i;
SetPlayerVirtualWorld(playerid, HouseInfo[i][Virtual]);
SendClientMessage(playerid, 0x00C4F6AA, "You are visiting this house, you have 2 minutes until you are kicked out!");
Visiting[playerid] = i;
TimeR[playerid] = SetTimerEx("Kicked", 120000, false, "d", playerid);
return 1;
}
return 1;
}
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(InHouse[playerid] == -1) return SendClientMessage(playerid, 0xF60000AA, "You are not in a house");
SetPlayerPos(playerid, HouseInfo[InHouse[playerid]][PickupX], HouseInfo[InHouse[playerid]][PickupY], HouseInfo[InHouse[playerid]][PickupZ]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SendClientMessage(playerid, 0x00C4F6AA, "You have exited a house");
InHouse[playerid] = -1;
if(Visiting[playerid] != -1)
{
Visiting[playerid] = -1;
KillTimer(TimeR[playerid]);
}
return 1;
}
/*if (strcmp("/gotomyhouse", cmdtext, true) == 0)
{
if(House[playerid] == -1) return SendClientMessage(playerid, 0xF60000AA, "You don't own a house");
SetPlayerPos(playerid, HouseInfo[House[playerid]][PickupX], HouseInfo[House[playerid]][PickupY], HouseInfo[House[playerid]][PickupZ]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
ResetPlayerWeapons(playerid);
SendClientMessage(playerid, 0x00C4F6AA, "You have teled to your house");
InHouse[playerid] = -1;
return 1;
}*/
if (strcmp("/Openhouse", cmdtext, true, 10) == 0)
{
if(InHouse[playerid] == -1 || House[playerid] != InHouse[playerid]) return SendClientMessage(playerid, 0xF60000AA, "You are not in a house that you own");
HouseInfo[InHouse[playerid]][Opened] = 1;
dini_IntSet("Opened.ini", HouseInfo[InHouse[playerid]][HouseNames], 1);
SendClientMessage(playerid, 0x00C4F6AA, "You have now opened your house to everyone");
return 1;
}
if (strcmp("/Closehouse", cmdtext, true, 10) == 0)
{
if(InHouse[playerid] == -1 || House[playerid] != InHouse[playerid]) return SendClientMessage(playerid, 0xF60000AA, "You are not in a house that you own");
HouseInfo[InHouse[playerid]][Opened] = 0;
dini_IntSet("Opened.ini", HouseInfo[InHouse[playerid]][HouseNames], 0);
SendClientMessage(playerid, 0x00C4F6AA, "You have now closed your house to everyone");
return 1;
}
if (strcmp("/Clearkeys", cmdtext, true, 10) == 0)
{
if(InHouse[playerid] == -1 || House[playerid] != InHouse[playerid]) return SendClientMessage(playerid, 0xF60000AA, "You are not in a house that you own");
new File[100];
format(File, sizeof(File), "HouseKeys/%s.ini", HouseInfo[InHouse[playerid]][HouseNames]);
fremove(File);
return 1;
}
dcmd(Invite, 6, cmdtext);
dcmd(Givekeys, 8, cmdtext);
return 0;
}
dcmd_Invite(playerid, params[])
{
new Pname2[24]; GetPlayerName(playerid, Pname2, 24);
if(InHouse[playerid] == -1 || House[playerid] != InHouse[playerid]) return SendClientMessage(playerid, 0xF60000AA, "You are not in a house that you own!");
new ID = strval(params);
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, 0xF60000AA, "Player is not connected!");
Invited[ID] = InHouse[playerid];
new Pname[24], string[80], string2[80];
GetPlayerName(ID, Pname, 24);
format(string, sizeof(string), "Invited %s to your house!", Pname);
format(string2, sizeof(string2), "%s has invited you to their house!", Pname2);
SendClientMessage(playerid, 0x00C4F6AA, string);
SendClientMessage(ID, 0x00C4F6AA, string2);
return 1;
}
dcmd_Givekeys(playerid, params[])
{
new Pname2[24]; GetPlayerName(playerid, Pname2, 24);
if(InHouse[playerid] == -1 || House[playerid] != InHouse[playerid]) return SendClientMessage(playerid, 0xF60000AA, "You are not in a house that you own!");
new ID = strval(params);
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, 0xF60000AA, "Player is not connected!");
Keys[ID][InHouse[playerid]] = 1;
new File[65];
new Pname[24], string[80], string2[80];
GetPlayerName(ID, Pname, 24);
format(File, sizeof(File), "HouseKeys/%s.ini", HouseInfo[InHouse[playerid]][HouseNames]);
if(!dini_Exists(File))
{
dini_Create(File);
}
dini_IntSet(File, Pname, 1);
format(string, sizeof(string), "Gave %s Keys to your house!", Pname);
format(string2, sizeof(string2), "%s has given you keys to their house!", Pname2);
SendClientMessage(playerid, 0x00C4F6AA, string);
SendClientMessage(ID, 0x00C4F6AA, string2);
return 1;
}
stock SetPlayerMapIconEx(Float:X, Float:Y, Float:Z, Markertype, Color, Float:dist = 100.0)
{
MarkerID ++; //Marker ID added
MarkerUsed[MarkerID] = 1; //Enabled = 1 disabled = 0
MarkerInfo[MarkerID][markertype] = Markertype; //Marker type check https://sampwiki.blast.hk/wiki/SetPlayerMapIcon for them
MarkerInfo[MarkerID][x] = X; //X of the icon
MarkerInfo[MarkerID][y] = Y; //Y of the icon
MarkerInfo[MarkerID][z] = Z; //Z of the icon
MarkerInfo[MarkerID][color] = Color; //Color of the icon.
MarkerInfo[MarkerID][Dist] = dist;
return MarkerID;
}
forward Stream();
public Stream()
{
for(new i; i<MAX_PLAYERS; i++)//Goes through all players
{
if(IsPlayerConnected(i)) //All online players
{
for(new S; S<MarkerID+1; S++) //All active Markers
{
if(MarkerUsed[S] == 1) //Checks if the Marker is enabled
{
if(IsPlayerInRangeOfPoint(i, MarkerInfo[S][Dist], MarkerInfo[S][x], MarkerInfo[S][y], MarkerInfo[S][z]) && PlayerMarkers[i][S] == 0)//Is the player close enough to the Marker and the player does not already have it streamed
{
for(new K; K<100; K++)
{
if(SlotsUsed[i][K] == 0)
{
SlotsUsed[i][K]++;
IconID[i][S] = K;
break;
}
}
SetPlayerMapIcon(i, IconID[i][S], MarkerInfo[S][x], MarkerInfo[S][y], MarkerInfo[S][z], MarkerInfo[S][markertype], MarkerInfo[S][color]);//Create the Marker
PlayerMarkers[i][S] = 1; //Shows the object streamed for the player
continue;
}
}
if(!IsPlayerInRangeOfPoint(i, MarkerInfo[S][Dist], MarkerInfo[S][x], MarkerInfo[S][y], MarkerInfo[S][z]) && PlayerMarkers[i][S] == 1) //If the player falls out of that distance the marker is destroyed
{
SlotsUsed[i][IconID[i][S]] = 0;
PlayerMarkers[i][S] = 0;
RemovePlayerMapIcon(i, IconID[i][S]);
continue;
}
}
}
}
return 1;
}
forward Kicked(playerid);
public Kicked(playerid)
{
SetPlayerPos(playerid, HouseInfo[InHouse[playerid]][PickupX], HouseInfo[InHouse[playerid]][PickupY], HouseInfo[InHouse[playerid]][PickupZ]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SendClientMessage(playerid, 0x00C4F6AA, "You have been kicked from this house for staying longer than 2 minutes");
InHouse[playerid] = -1;
Visiting[playerid] = -1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(InHouse[playerid] == 1 && House[playerid] == InHouse[playerid])
{
new Pname[24];
GetPlayerName(playerid, Pname, 24);
dini_Set("HouseSave.ini", Pname, HouseInfo[House[playerid]][HouseNames]);
}
return 1;
}
public OnPlayerConnect(playerid)
{
HouseSpawn[playerid] = -1;
new Pname[24];
GetPlayerName(playerid, Pname, 24);
if(strlen(dini_Get("HouseSave.ini", Pname)) != 0)
{
for(new S; S < HouseCount + 1; S++)
{
GetPlayerName(playerid, Pname, 24);
if(!strcmp(dini_Get("HouseSave.ini", Pname), HouseInfo[S][HouseNames]))
{
HouseSpawn[playerid] = S;
}
}
}
return 1;
}
public OnPlayerSpawn(playerid)
{
if(HouseSpawn[playerid] != -1)
{
new i = HouseSpawn[playerid];
SetPlayerPos(playerid, HouseInfo[i][TeleX], HouseInfo[i][TeleY], HouseInfo[i][TeleZ]);
SetPlayerInterior(playerid, HouseInfo[i][Interior]);
Invited[playerid] = -1;
InHouse[playerid] = i;
SetPlayerVirtualWorld(playerid, HouseInfo[i][Virtual]);
SendClientMessage(playerid, 0x00C4F6AA, "You have spawned at your house");
}
return 1;
}