Jump to content

House icon


Jammie

Recommended Posts

take some brushes and blue color and give your best :roll:

Very useful.

TS: if this function isn't already included in the script, (that is, changing icon when someone buys it) you will have to modify the resource on your own. When the blip is created and should change (ie if ownership changes) you will need to check if there is an owner and use setElementModel on the pickup accordingly.

If this doesn't make sense, read more lua and study the code.

Link to comment

I've found some lines of the house script, kihc does'nt have that script included. What I have found when you "buy" a house then he must change to "blue".

House blue = "1272".

This is when you create a house:

function createHouseXX( x , y , z, ix, iy , iz , ii , cost , owner )
local pickup = createPickup( x , y , z, 3 ,1273 )
pickupCount = pickupCount + 1
houseElement = "house"..pickupCount
id[ pickup ] = houseElement
HouseOutX[ houseElement ] = x
HouseOutY[ houseElement ] = y
HouseOutZ[ houseElement ] = z
HouseInX[ houseElement ] = ix
HouseInY[ houseElement ] = iy
HouseInZ[ houseElement ] = iz
HouseInI[ houseElement ] = ii
IsHousePickup[ houseElement ] = true
if existData_kihc( houseElement ) then
-- nothing
else
	createData_kihc( houseElement )
	saveData_kihc( houseElement , "owner" , owner )
	saveData_kihc( houseElement , "cost" , cost )
	saveData_kihc( houseElement , "rent" , "50" )
	saveData_kihc( houseElement , "bank" , "0" )
end
 
return houseElement 	
end

And this is when you buy a house and here you must add the lines that you change the icon color to blue:

function houseSystem( player , arg1 , arg2 )
local sourceAccount = getClientAccount ( player )
if not isGuestAccount( sourceAccount ) then
if PlayerInHouse[ player ] then
if arg1 == "buy" then
if getHouseOwner( PlayerInHouse[ player ] ) == "none" then
if getPlayerMoney( player ) > getHouseCost( PlayerInHouse[ player ] ) then
local name = getClientName( player )
					setHouseOwner( PlayerInHouse[ player ] , name )
outputChatBox( "#00FF00 Congrats, now you are the owner of this house." , player , 255, 255, 255, true)
outputChatBox( "#00FF00 [  #FF9900/Withdraw ] - ]  #FF9900/Setrent ] - [  #FF9900/Sell ]" , player , 255, 255, 255, true)
takePlayerMoney( player , getHouseCost( PlayerInHouse[ player ] ))
					PlayerBlip[ player ] = createBlip( HouseOutX[ PlayerInHouse[ player ] ] , HouseOutY[ PlayerInHouse[ player ] ] , HouseOutZ[ PlayerInHouse[ player ] ] , 35 , 2 , 0 , 0 , 0 , 0 , 0 , player )
else
outputChatBox( "#00FF00 You dont have enough money." , player, 255, 255, 255, true )
end
else
outputChatBox( "#00FF00 The house is not for sale." , player )				
end

Link to comment

Its should work...

You just need to fill in the "No Owner Name" something like "The State"

function createHouseXX( x , y , z, ix, iy , iz , ii , cost , owner )
local pickup
if(owner == "?")then -- Fill the No Owner Name here
pickup = createPickup( x , y , z, 3 ,1272 ) -- Icon Id 1272 if the House is 2 sell
else
pickup = createPickup( x , y , z, 3 ,1273) -- if the House is occupied Icon ID 1273
end
  pickupCount = pickupCount + 1
  houseElement = "house"..pickupCount
  id[ pickup ] = houseElement
  HouseOutX[ houseElement ] = x
  HouseOutY[ houseElement ] = y
  HouseOutZ[ houseElement ] = z
  HouseInX[ houseElement ] = ix
  HouseInY[ houseElement ] = iy
  HouseInZ[ houseElement ] = iz
  HouseInI[ houseElement ] = ii
  IsHousePickup[ houseElement ] = true
if existData_kihc( houseElement ) then
-- nothing
else
     createData_kihc( houseElement )
     saveData_kihc( houseElement , "owner" , owner )
     saveData_kihc( houseElement , "cost" , cost )
     saveData_kihc( houseElement , "rent" , "50" )
     saveData_kihc( houseElement , "bank" , "0" )
end
 
return houseElement    
end

Ps: We need the setHouseOwner Function too.

Link to comment

createHouseXX function is called only from createDebugHouse, loadHouses uses createHouse.

anyway, this'll only make blue (well actually green, cause you messed up the id's :D) icons when "owned" houses are created, not when someone buys it.

as for setHouseOwner:

function setHouseOwner( house , name )
saveData_kihc( house , "owner" , name )
saveData_kihc( name , "house" , house )
end

not much there. :D

setElementModel is not working for pickups. well, wiki says objects/peds/vehicles only, and i've tried, you can only getElementModel from pickup, but not set it.

so i guess you'll have to replace the whole pickup element.

though i may be wrong *)

Link to comment

That's right, because if you create a house then its the icon "green" because no owners. But if you buy a house then it stays the icon "green".

And if i change the whole script to that blue icon "1272" and I delete "1273" (the green icon) then I've the same problem.. then it stays "blue".

What I want is if you buy a house then it must be the icon "blue". Why did kihc not included that -,- I hope so you can help me with this. ;)

But it doesn't work if I change the id of the icon to blue... then you have only blue icons...

Link to comment
That's right, because if you create a house then its the icon "green" because no owners. But if you buy a house then it stays the icon "green".

And if i change the whole script to that blue icon "1272" and I delete "1273" (the green icon) then I've the same problem.. then it stays "blue".

What I want is if you buy a house then it must be the icon "blue". Why did kihc not included that -,- I hope so you can help me with this. ;)

But it doesn't work if I change the id of the icon to blue... then you have only blue icons...

That's what they are trying to do. I've never used this script and don't know how it works but as someone said, the script has to know if the house has been bought before it creates the house pickup and the "if" statement is what you want to check if the house has owner.

Link to comment

Its ok now, I have another house script. that works great!. kihc has little bugs and I hope they update their script! uhmm I hope you can help me with this!.

I have made a screen of it. and the script I will put here:

Script (cylinder),

createMarker ( x, y, z, "cylinder", 2.0, 255, 255, 255, 255 )

Why is he fly in the air ?!

SEE THE ATTACHMENT!

[attachment=0]Naamloos2.png[/attachment]

Link to comment
i'm pretty sure getGroundPosition works this way:
local groundz = getGroundPosition(x, y, z)
createMarker(x, y, groundz, "cylinder", 2.0, 255, 255, 255, 255)

and it's a client-only function.

Lol this wont work dude youre not defining a Integer, groundz contains the whole GroundPosition and if you use

the GroundPosition, the Icon is IN the Ground.

Link to comment

man, what's wont work for sure is this:

local groundx, groundy, groundz
getGroundPosition ( groundx, groundy, groundz+2 )
createMarker ( x, y, groundz , "cylinder", 2.0, 255, 255, 255, 255 )

groundx, groundy, groundz without values and getGroundPosition result goes nowhere.

please, click on function name and read how getGroundPosition works:

Returns a float with the highest ground-level Z coord if parameters are valid, 0 if the point you tried to test is outside the loaded world map, false otherwise.

as for "omg its in the ground" - just add +2 or whatever, its not the reason for "it wont work dude".

Link to comment
Its ok now, I have another house script. that works great!. kihc has little bugs and I hope they update their script! uhmm I hope you can help me with this!.

I have made a screen of it. and the script I will put here:

Script (cylinder),

createMarker ( x, y, z, "cylinder", 2.0, 255, 255, 255, 255 )

Why is he fly in the air ?!

SEE THE ATTACHMENT!

[attachment=0]Naamloos2.png[/attachment]

It floats because in the past (DP2 era) cylinder markers where snapped to the ground, no matter how heigh they were created. People used player's position to use for markers (including cylinders) which is center of the player's body (~1 unit above the floor). Since MTA 1.0 markers don't snap to the ground but instead they are created at the exact position as the coordinates passed to createMarker function, so center of the player's body. This is why they float. To fix it, you can subtract 1 (or .8, can't remember exact number) from Z value.

Link to comment

as a proof for Jason_Gregory:

addCommandHandler("marker", 
function ()
local x, y, z = getElementPosition(getLocalPlayer())
local groundz = getGroundPosition(x, y, z)
createMarker(x, y, groundz, "cylinder", 2.0, 255, 255, 255, 255) 
end
)

Link to comment
i'm pretty sure getGroundPosition works this way:
local groundz = getGroundPosition(x, y, z)
createMarker(x, y, groundz, "cylinder", 2.0, 255, 255, 255, 255)

and it's a client-only function.

Lol this wont work dude youre not defining a Integer, groundz contains the whole GroundPosition and if you use

the GroundPosition, the Icon is IN the Ground.

It's great that you want to help, it's always appreciated, but please try and get an idea of what you're talking about before you reply and make other people uncertain. xbost is right, that is the correct usage.

Link to comment

I tryed it with the House Icons the Big Marker is allright, but the Little House Marker is 50% under the Ground for me.

But if it works for him....yeah, i thought

getGroundPosition(x, y, z)

gets the Correct Position of the Ground and not of an Spawning Player.

For me it still dont work with the House Icons (Color: Blue/Green).

Whatever!

Link to comment
I tryed it with the House Icons the Big Marker is allright, but the Little House Marker is 50% under the Ground for me.

But if it works for him....yeah, i thought

getGroundPosition(x, y, z)

gets the Correct Position of the Ground and not of an Spawning Player.

For me it still dont work with the House Icons (Color: Blue/Green).

Whatever!

Don't you understand he was asking why do cylinder markers float? Every pickup floats and that's correct functionality in most games. The floating cylinder isn't though, so getGroundPosition was used to get ground position which then can create cylinder marker on the ground not in air.

https://forum.multitheftauto.com/posting ... 0#pr302982

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...