Jump to content

[REL] Housing System ( Updates )


CowTurbo

Recommended Posts

  • 2 weeks later...

which gamemode are you using ?

If you are using your own mode, then replace that with your respawn function. ( Server side )

function respawnToHome() 
      local skin = getElementModel ( source ) 
      local playeraccount = getPlayerAccount ( source ) 
      local house = getAccountData ( playeraccount, "house" ) 
      if ( house == "yes" )then 
      local housex = getAccountData ( playeraccount, "housex" ) 
      local housey = getAccountData ( playeraccount, "housey" ) 
      local housez = getAccountData ( playeraccount, "housez" ) 
      if ( housex ) and ( housey ) and ( housez ) then 
      spawnPlayer ( source, housex, housey, housez, 0, skin ) 
      end 
      else 
     --  HERE ADD YOUR OTHER RESPAWN  FUNCTIONS ( IF THE PLAYER DONT HAVE HOME ) 
      end 
end 
addEventHandler ("onPlayerWasted",getRootElement(), respawnToHome ) 

If you are using play then replace this in play folder .lua file

addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
    repeat until spawnPlayer ( player, 2412+math.random(1,1), -1413+math.random(1,1),24.4, 90, math.random(9,288) ) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        spawn(source) 
    end 
) 
  
function respawnToHome() 
      local skin = getElementModel ( source ) 
      local playeraccount = getPlayerAccount ( source ) 
      local house = getAccountData ( playeraccount, "house" ) 
      if ( house == "yes" )then 
      local housex = getAccountData ( playeraccount, "housex" ) 
      local housey = getAccountData ( playeraccount, "housey" ) 
      local housez = getAccountData ( playeraccount, "housez" ) 
      if ( housex ) and ( housey ) and ( housez ) then 
      spawnPlayer ( source, housex, housey, housez, 0, skin ) 
      end 
      else 
    setTimer(spawn, 1800, 1, source) 
    end 
end 
addEventHandler ("onPlayerWasted",getRootElement(), respawnToHome ) 

If you want that too, when player joins and spawn at home with play resource, then use that:

addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
    repeat until spawnPlayer ( player, 2412+math.random(1,1), -1413+math.random(1,1),24.4, 90, math.random(9,288) ) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
         local playeraccount = getPlayerAccount ( source ) 
      local house = getAccountData ( playeraccount, "house" ) 
      if ( house == "yes" )then 
      local housex = getAccountData ( playeraccount, "housex" ) 
      local housey = getAccountData ( playeraccount, "housey" ) 
      local housez = getAccountData ( playeraccount, "housez" ) 
      if ( housex ) and ( housey ) and ( housez ) then 
      spawnPlayer ( source, housex, housey, housez, 0, skin ) 
      end 
      else 
    spawn( source) 
    end 
end 
    end 
) 
  
function respawnToHome() 
      local skin = getElementModel ( source ) 
      local playeraccount = getPlayerAccount ( source ) 
      local house = getAccountData ( playeraccount, "house" ) 
      if ( house == "yes" )then 
      local housex = getAccountData ( playeraccount, "housex" ) 
      local housey = getAccountData ( playeraccount, "housey" ) 
      local housez = getAccountData ( playeraccount, "housez" ) 
      if ( housex ) and ( housey ) and ( housez ) then 
      spawnPlayer ( source, housex, housey, housez, 0, skin ) 
      end 
      else 
    setTimer(spawn, 1800, 1, source) 
    end 
end 
addEventHandler ("onPlayerWasted",getRootElement(), respawnToHome ) 

Hope it helps.

Link to comment
  • 2 weeks later...
Maybe selling houses to other players, and setting price to sell it.

If you have givecash functions in server, then he gives you money what you want, and you sell house, and then he can buy. Need some maths from player, but can be used.

Please , do you have a way to show blips in the radar/map ??

You do got my msn, i will help with that you.

Link to comment

For everyone, who wants to have on bind "B" house blips, add this to server-side script in house resource.

  
function makeBlips (player) 
  local root = xmlLoadFile ("homes.xml") 
  local houseroot = xmlFindChild (root,"houses",0) 
  if (houseroot) then 
    allHouses = {} 
    for i,v in ipairs (xmlNodeGetChildren(houseroot)) do 
      local x = xmlNodeGetAttribute (v,"x") 
      local y = xmlNodeGetAttribute (v,"y") 
      local z = xmlNodeGetAttribute (v,"z") 
      local number = xmlNodeGetAttribute (v,"num") 
      if not (xmlNodeGetAttribute (v,"owner") == "") then 
       blips[tonumber(number)] = createBlip ( x,y,z,32, 2, getRootElement(), getRootElement(), getRootElement(), getRootElement(),0, 99999.0, player ) 
      else 
       blips[tonumber(number)] = createBlip ( x,y,z,31, 2, getRootElement(), getRootElement(), getRootElement(), getRootElement(),0, 99999.0, player ) 
      end 
    end 
  end 
end 
  
function destroyBlips () 
    for i,v in pairs ( blips ) do 
    destroyElement ( v ) 
    end 
end 
  
  
function bindKeys () 
    bindKey ( source, "b", "down", makeBlips ) 
    bindKey ( source, "b", "up", destroyBlips ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), bindKeys ) 
addEventHandler ( "onPlayerLogin", getRootElement(), bindKeys ) 
  
function bindKeysOnStart () 
    for i,v in ipairs ( getElementsByType("player")) do 
    bindKey ( v, "b", "down", makeBlips ) 
    bindKey ( v, "b", "up", destroyBlips ) 
    end 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), bindKeysOnStart ) 

Link to comment
  • 4 weeks later...
  • 2 months later...

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...