Jump to content

big help


nydlv

Recommended Posts

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

Link to comment

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

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

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

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

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

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 by Guest
Link to comment

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 :D

sorry for my good english :D

Link to comment
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 :D

sorry for my good english :D

hmm

guiCreateLabel?

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