nydlv Posted October 4, 2010 Share Posted October 4, 2010 hi again, how to make the enter script with keybord binds ? Something like house entering example - you would enter the police station, you access to a door and press f now you are inside, press f from inside now you are outside sorry for my lang. Link to comment
12p Posted October 5, 2010 Share Posted October 5, 2010 function teleport (player,teleport) if teleport == 0 then setElementInterior (player,interior,x,y,z) unbindKey ("key","down",teleportToggle) -- Remember, replace key. elseif teleport == 1 then -- For another teleport. end end addEventHandler("onMarkerHit",markerOnEntranceDoor, function (hitPlayer,dimension) teleport = 0 bindKey ("key","down",teleport,hitPlayer,teleport) -- Replace key. end) That's the best way. Remember, on each marker, choose a different "teleport" variable. And do the markers . Link to comment
dzek (varez) Posted October 5, 2010 Share Posted October 5, 2010 this looks like uncompleted.. and it's not the best way.. it will add same binds every time you enter the marker Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 someting not working meta.xml <meta> <script src="tele_c.lua" type="client"/> </meta> tele_c.lua function teleport (player,teleport) if teleport == 0 then setElementInterior (player, 0, 1481.44, -1768.29,18.79) unbindKey ("f","down",teleportToggle) -- Remember, replace key. elseif teleport == 1 then -- For another teleport. end end addEventHandler("onMarkerHit",markerOnEntranceDoor, function (hitPlayer,dimension) teleport = 0 bindKey ("f","down",teleport,hitPlayer,teleport) -- Replace key. end) nothing happens, and no marker visible, help pls Link to comment
dzek (varez) Posted October 5, 2010 Share Posted October 5, 2010 setElementInterior is not for setting position. as i said - this code is wrong. i'm working on good one. Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 meiby setElementPosition (player, 0, 1481.44, -1768.29,18.79) or setPlayerPosition (player, 0, 1481.44, -1768.29,18.79) ? Link to comment
dzek (varez) Posted October 5, 2010 Share Posted October 5, 2010 create resource with map file, in map file put something like that: <map> <marker posX="10" posY="10" posZ="10" interior="0" dimension="0" type="cylinder" size="5" color="#ff0000" atype="teleport" TposX="50" TposY="50" TposZ="50" Tinterior="3" Tdimension="0" /> </map> posX,posY,posZ is FROM position of the marker, interior is interior of the FROM marker, dimension is FROM dimension, type is marker type (check this page for types list), size is marker size, color is color of the marker in HTML color code (you can get HTML color from there), atype should be "teleport" for teleport marker, TposX, TposY, TposZ is TARGET position, Tinterior is targer interior, Tdimension is target dimension. and the client script: dont change ANYTHING in code below! only in map file function tryToTeleport() local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then return false end local tx=tonumber(getElementData(source, "TposX")) local ty=tonumber(getElementData(source, "TposY")) local tz=tonumber(getElementData(source, "TposZ")) local ti=tonumber(getElementData(source, "Tinterior")) local td=tonumber(getElementData(source, "Tdimension")) if (tx and ty and tz and ti and td) then setElementPosition(getLocalPlayer(),tx,ty,tz) setElementDimension(getLocalPlayer(), td) setElementInterior(getLocalPlayer(), ti) end end local keys = getBoundKeys("enter_exit") for key, state in keys do bindKey(key, "up", tryToTeleport) end current = nil function disableCurrentMarker(hitElement, matchingDimension) if (matchingDimension and hitElement==getLocalPlayer()) current = nil end end function setAsCurrentMarker(hitElement, matchingDimension) if (matchingDimension and hitElement==getLocalPlayer()) current = source end end local markers = getElementsByType("marker", getResourceRootElement(getThisResource())) for key, val in ipairs(markers) do local atype = getElementData(val, "atype") if (atype=="teleport") then addEventHandler("onClientMarkerHit", val, setAsCurrentMarker) addEventHandler("onClientMarkerLeave", val, disableCurrentMarker) end end edit: i wrote this in browser, its not tested but should work Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 i was installed all how you say, but when i am on/in red marker nothing happens on marker, no teleport i was presed f, enter too, nothing happens Link to comment
dzek (varez) Posted October 5, 2010 Share Posted October 5, 2010 omfg. debug. https://wiki.multitheftauto.com/wiki/Debugging While wiki is down you can use this ugly copy: http://webcache.googleusercontent.com/s ... ient=opera I forgot about two "then" and this is making a syntax error, perfctly easy to spot and fix ... is you know basics of lua - just fix it. if you dont know - learn (from anywhere, like http://lua.org/ - or just use Unofficial MTA Script Editor which is displaying syntax errors while writing) edit, fixed, with some others bugs fixed too, and with debug messages, you can learn from it how debug should look like: function tryToTeleport() outputDebugString("pressed enter_exit") local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then outputDebugString("in vehicle - cant teleport") return false end local tx=tonumber(getElementData(current, "TposX")) local ty=tonumber(getElementData(current, "TposY")) local tz=tonumber(getElementData(current, "TposZ")) local ti=tonumber(getElementData(current, "Tinterior")) local td=tonumber(getElementData(current, "Tdimension")) if (tx and ty and tz and ti and td) then setElementPosition(getLocalPlayer(),tx,ty,tz) setElementDimension(getLocalPlayer(), td) setElementInterior(getLocalPlayer(), ti) outputDebugString("teleported") return true -- the rest will not run end outputDebugString("failed to teleport - something wrong with marker in map file") end local keys = getBoundKeys('enter_exit') for key, state in pairs(keys) do outputDebugString("bound key: "..key) bindKey(key, "up", tryToTeleport) end current = nil function disableCurrentMarker(hitElement, matchingDimension) outputDebugString("something left the marker") if (matchingDimension and hitElement==getLocalPlayer()) then outputDebugString("you left the marker") current = nil end end function setAsCurrentMarker(hitElement, matchingDimension) outputDebugString("something hit the marker") if (matchingDimension and hitElement==getLocalPlayer()) then outputDebugString("you hit the marker") current = source end end local markers = getElementsByType("marker", getResourceRootElement(getThisResource())) local i = 1 outputDebugString("Markers count: "..#markers) for key, val in ipairs(markers) do local atype = getElementData(val, "atype") if (atype=="teleport") then outputDebugString("Found marker: "..i) i=i+1 addEventHandler("onClientMarkerHit", val, setAsCurrentMarker) addEventHandler("onClientMarkerLeave", val, disableCurrentMarker) end end Link to comment
dzek (varez) Posted October 5, 2010 Share Posted October 5, 2010 most recent one is TESTED and is working fine. if you cant run it - re-read server manual, and scripitng tutorial (you can find copies of these on google - type something like "Server manual" site:wiki.multitheftauto.com | site:wiki.multitheftauto.com and click small "Copy" text near result, then click: Text version on the top-right) Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 i doit as you say. Bet when i am staying on marker nothing happens and when presing enter_exit button too. Where is the problem? edit: i think there is problem with plugin, because it does not debug, when i am on marker, but how can i test it? Link to comment
dzek (varez) Posted October 5, 2010 Share Posted October 5, 2010 you did something wrong. i dont know why. login as administrator and type "debugscript 3" in console. try now. also maybe zip your resource and post here - i'll tell you what you did wrong Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 (edited) created zipfile, refresh in server consule, enterh resource loaded, BUT staying on marker there are no debug and nothing happens !!! enterh folder my meta.xml <meta> <script src="enterh_c.lua" type="client"/> </meta> my enterh_c.lua function tryToTeleport() outputDebugString("pressed enter_exit") local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then outputDebugString("in vehicle - cant teleport") return false end local tx=tonumber(getElementData(current, "TposX")) local ty=tonumber(getElementData(current, "TposY")) local tz=tonumber(getElementData(current, "TposZ")) local ti=tonumber(getElementData(current, "Tinterior")) local td=tonumber(getElementData(current, "Tdimension")) if (tx and ty and tz and ti and td) then setElementPosition(getLocalPlayer(),tx,ty,tz) setElementDimension(getLocalPlayer(), td) setElementInterior(getLocalPlayer(), ti) outputDebugString("teleported") return true -- the rest will not run end outputDebugString("failed to teleport - something wrong with marker in map file") end local keys = getBoundKeys('enter_exit') for key, state in pairs(keys) do outputDebugString("bound key: "..key) bindKey(key, "up", tryToTeleport) end current = nil function disableCurrentMarker(hitElement, matchingDimension) outputDebugString("something left the marker") if (matchingDimension and hitElement==getLocalPlayer()) then outputDebugString("you left the marker") current = nil end end function setAsCurrentMarker(hitElement, matchingDimension) outputDebugString("something hit the marker") if (matchingDimension and hitElement==getLocalPlayer()) then outputDebugString("you hit the marker") current = source end end local markers = getElementsByType("marker", getResourceRootElement(getThisResource())) local i = 1 outputDebugString("Markers count: "..#markers) for key, val in ipairs(markers) do local atype = getElementData(val, "atype") if (atype=="teleport") then outputDebugString("Found marker: "..i) i=i+1 addEventHandler("onClientMarkerHit", val, setAsCurrentMarker) addEventHandler("onClientMarkerLeave", val, disableCurrentMarker) end end enterhmaps folder meta.xml <meta> <map src="enterh.map" dimension="0" /> </meta> enterh.map <map> <marker posX="1482" posY="-1734.94" posZ="13" interior="0" dimension="0" type="cylinder" size="3" color="#ffffff" atype="teleport" TposX="1487.06" TposY="-1735.05" TposZ="13.38" Tinterior="0" Tdimension="0" /> </map> link to zip files http://www.failiem.lv/list.php?i=tsgopd meiby i need server side script too? Edited October 5, 2010 by Guest Link to comment
Castillo Posted October 5, 2010 Share Posted October 5, 2010 i think you failed at meta.xml? maybe this, <meta> <script src="enterh_c.lua" type="client"/> <map src="enterh.map" dimension="0" /> </meta> put all on SAME FOLDER Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 no, then are no markers visible. Link to comment
Castillo Posted October 5, 2010 Share Posted October 5, 2010 no, then are no markers visible. dude, this works all fine for me i have tested it i press F at marker and it teleports also when i hit it says "something hit the marker" RE-READ SERVER MANUAL AGAIN Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 all works, thank you guys Link to comment
Castillo Posted October 5, 2010 Share Posted October 5, 2010 all works, thank you guys before moderators close the topic can you tell us what was you doing WRONG? Link to comment
dzek (varez) Posted October 5, 2010 Share Posted October 5, 2010 Solid - its clearly said - he put this in 2 separate resources Link to comment
Castillo Posted October 5, 2010 Share Posted October 5, 2010 Solid - its clearly said - he put this in 2 separate resources then why he said it wasn't working first post i made O_o. anyway lets forgot about it, case close Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 i added <resource src="enterh" startup="1"/> to mtaconfig.conf hmm.. another problem, how can i make, when you are in marker zone the text appear in the center-bottom of screen? (dxDrawText) ..and make another, in map something like text="Welcome to the building 1", hope you understand me sorry for my good english Link to comment
Castillo Posted October 5, 2010 Share Posted October 5, 2010 i added <resource src="enterh" startup="1"/> to mtaconfig.conf hmm.. another problem, how can i make, when you are in marker zone the text appear in the center-bottom of screen? ..and make another, in map something like text="Welcome to the building 1", hope you understand me sorry for my good english hmm guiCreateLabel? Link to comment
dzek (varez) Posted October 5, 2010 Share Posted October 5, 2010 i gave you one big script. no more requests. learn lua by yourself. simply following my code will help you make this Link to comment
nydlv Posted October 5, 2010 Author Share Posted October 5, 2010 okey i will do it, but i found bug in script, when you are teleporting where interior is 3 and dimension is 1, it teleport you to that location but when i typed /getpos, there was typed, Interior: 0, Dimension: 0 wtf? 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