Jump to content

Wasted


Cornelis

Recommended Posts

Hi, I have a question about wasted. When somebody died in my server now he spawns at LV hospital, but I want a script that do these things:

- When u die in SF, go to SF hospital.

- When u die in LS, go to LS hospital.

- When u die in LV, go to LV hospital.

Can somebody help me? This is my simple code now:

addEventHandler( "onPlayerWasted", getRootElement( ), 
    function() 
        setTimer( spawnPlayer, 2000, 1, source, 1607.2362060547, 1816.2670898438, 10.8303125) 
    end 
) 

Edited by Guest
Link to post

this will spawn in the nearest location, it's NOT based on areas, but distance to hispital!

  
hospitals = { 
  { 0, 0, 10 }, 
  { 100, 100, 10 } 
  { 200, 400, 10 } 
} 
  
function findNearestHostpital(thePlayer) 
  local nearest = nil 
  local min = 999999 
  for key,val in pairs(hospitals) do 
    local xx,yy,zz=getElementPosition(thePlayer) 
    local x1=val[1] 
    local y1=val[2] 
    local z1=val[3] 
    local dist = getDistanceBetweenPoints2D(xx,yy,x1,y1) 
    if dist      nearest = val 
      min = dist 
    end 
  end 
  return nearest[1],nearest[2],nearest[3] 
  end 
end 
  
addEventHandler("onPlayerWasted", getRootElement(), function() 
  local xx,yy,zz = findNearestHostpital(source) 
  spawnPlayer(source,xx,yy,zz) 
end) 
  

the way you are looking for is a bit different and is based on getZoneName() but the wiki is down, and i dont know the zones list

colshapes would probably be the best solution I assume

and i KNOW they won't ;p getZoneName() is the best way - its something like getZoneName()

Link to post

addEventHandler ( "onPlayerWasted", getRootElement( ), 
    function() 
        setTimer( spawnPlayer, 2000, 1, source, 1607.2362060547, 1816.2670898438, 10.8303125) 
    end 
) 

So the coords of LV are:

X = 1607.2362060547

Y = 1816.2670898438

Z = 10.8303125

Link to post

in this way it s rly funny :lol:

but, let i example you varez ;)

I always get spawnen at LS hospital now!

oke, now, he say, hes getting spawned in LS ( i hope whit your script xD )

addEventHandler ( "onPlayerWasted", getRootElement( ), 
    function() 
        setTimer( spawnPlayer, 2000, 1, source, 1607.2362060547, 1816.2670898438, 10.8303125) 
    end 
) 

So the coords of LV are:

X = 1607.2362060547

Y = 1816.2670898438

Z = 10.8303125

before that, you asked cords, enyway, he shows you hes old code, and says cords :

So the coords of LV are:

:wink:

enyway, i will understand wrongly too ..

Link to post

Varez, in your script I have to put coordinates of hospitals right here?

hospitals = { 
  { 0, 0, 10 }, 
  { 100, 100, 10 } 
  { 200, 400, 10 } 
} 

//EDIT by Cornelis:

If I start the resource I get 2 errors:

- SCRIPT ERROR: myserver/spawnplayer.lua:14: '}; expected (to close '{' at line 11) near '{'

and

- WARNING: Loading script failed: myserver/spawnplayers.lua:14 '}' expcted (to close blabla same as first error!

Link to post

if you can't fix SYNTAX errors you shouldn't ask for help but keep reading tutorials:/

  
hospitals = { 
  { 0, 0, 10 }, 
  { 100, 100, 10 }, -- forgot about "," 
  { 200, 400, 10 } 
} 
  

these are coords of hospitals, btw notice i forgot about one "," character

also remove your spawning code, and be sure to fix all syntax errors made by me (i was writting this in browser, you can use Unofficial MTA Editor to see syntax errors before copying the script to server)

Link to post

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