Cornelis Posted October 6, 2010 Share Posted October 6, 2010 (edited) 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 October 6, 2010 by Guest Link to comment
dzek (varez) Posted October 6, 2010 Share Posted October 6, 2010 https://community.multitheftauto.com/ AFAIR there was such resource, i cant remember its name though Link to comment
Castillo Posted October 6, 2010 Share Posted October 6, 2010 I think there is no such resource of that at mta community, i think you should make it yourself Link to comment
Cornelis Posted October 6, 2010 Author Share Posted October 6, 2010 That was my question, how to script something like this: If player dies in regio around San Fierro, spawn at San Fierro hospital. Link to comment
FUNExtreme Posted October 6, 2010 Share Posted October 6, 2010 colshapes would probably be the best solution I assume Link to comment
dzek (varez) Posted October 6, 2010 Share Posted October 6, 2010 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 comment
CowTurbo Posted October 6, 2010 Share Posted October 6, 2010 nop, not rly , make tabel EDIT, damn, varez was first.. Link to comment
Cornelis Posted October 6, 2010 Author Share Posted October 6, 2010 I always get spawnen at LS hospital now! Link to comment
dzek (varez) Posted October 6, 2010 Share Posted October 6, 2010 post script, i written this in browser so maybe i did something wrong.. tell me which coords are in LS Link to comment
Cornelis Posted October 6, 2010 Author Share Posted October 6, 2010 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 comment
dzek (varez) Posted October 6, 2010 Share Posted October 6, 2010 dude, i gave you full script, you didnt use it, and asking why its not working??!! Link to comment
CowTurbo Posted October 6, 2010 Share Posted October 6, 2010 in this way it s rly funny 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 ) 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: enyway, i will understand wrongly too .. Link to comment
Cornelis Posted October 6, 2010 Author Share Posted October 6, 2010 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 comment
dzek (varez) Posted October 6, 2010 Share Posted October 6, 2010 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 comment
Castillo Posted October 6, 2010 Share Posted October 6, 2010 I don't get why you didn't used the one i PM'ed you, it works fine since it was running at my server. it works like varez one actually just some differences but it uses a table also to store cords. Link to comment
Xierra Posted October 7, 2010 Share Posted October 7, 2010 Whew, that's my next scripting project... Btw, I forgot the zones too... It's better to wait till the wiki is up, or varez would get mistakes like how karlis helped me. Wiki really helps you right? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now