Hallo Community
Nach langer zeit brauche ich eure Hilfe
Ich habe das Gate Script
Code
Editor = {}
Gate = {}
Gate2 = {}
Precision = {}
status = {}
coll = {}
coll2 = {}
coll3 = {}
coll4 = {}
-- this script mod is (no longer) PRIVATE
-- - Deject3d
function startBuilding(playerSource, commandName, objectid)
if not objectid then
outputChatBox("usage: /addgate objectid teamname", playerSource)
end
team = getTeamName(getPlayerTeam(playerSource))
if team == false then
team = ""
end
for i = 1,20 do
if Editor[i] == playerSource then
destroyElement(Gate[i])
Gate[i] = null
Editor[i] = null
Precision[i] = null
end
if Editor[i] == null then
Editor[i] = playerSource -- set Editor[i] to who made the object
--creating object -v
local x,y,z = getElementPosition(playerSource)
object = createObject ( objectid, x + 3,y + 3,z)
interior = getElementInterior ( playerSource )
setElementInterior(object,interior)
--created object -^
Gate[i] = object -- added object identifier to the array, corresponds to who created it
Precision[i] = .5 -- default precision
bindKey(playerSource, "i", "down", moveIt)
bindKey(playerSource, "j", "down", moveIt)
bindKey(playerSource, "k", "down", moveIt)
bindKey(playerSource, "l", "down", moveIt)
bindKey(playerSource, "mouse_wheel_up", "down", moveIt)
bindKey(playerSource, "mouse_wheel_down", "down", moveIt)
bindKey(playerSource, "pgup", "down", moveIt)
bindKey(playerSource, "pgdn", "down", moveIt)
bindKey(playerSource, "u", "down", moveIt)
bindKey(playerSource, "o", "down", moveIt)
bindKey(playerSource, "[", "down", moveIt)
bindKey(playerSource, "]", "down", moveIt)
bindKey(playerSource, "enter", "down", nextPosition ,objectid, team)
bindKey(playerSource, "delete", "down", removeIt, playerSource)
break -- done adding our object and who created it to the arrays... stop the loop
end
end
end
function nextPosition(playerSource, key, keyState, objectid, team)
unbindKey ( playerSource, "i" )
unbindKey ( playerSource, "j" )
unbindKey ( playerSource, "k" )
unbindKey ( playerSource, "l" )
unbindKey ( playerSource, "pgup" )
unbindKey ( playerSource, "pgdn" )
unbindKey ( playerSource, "mouse_wheel_down")
unbindKey ( playerSource, "mouse_wheel_up" )
unbindKey ( playerSource, "enter" )
unbindKey ( playerSource, "delete" )
unbindKey ( playerSource, "u" )
unbindKey ( playerSource, "o" )
unbindKey ( playerSource, "[" )
unbindKey ( playerSource, "]" )
outputDebugString("object 1 set. object 2 controlled. ID: " .. objectid .." team: " .. team .. "")
for i = 1,20 do
if Editor[i] == playerSource then
--creating object -v
local x,y,z = getElementPosition(Gate[i])
local rx,ry,rz= getObjectRotation(Gate[i])
object = createObject ( objectid, x,y,z,rx,ry,rz)
interior = getElementInterior ( playerSource )
setElementInterior(object,interior)
--created object -^
Gate2[i] = object -- added object identifier to the array, corresponds to who created it
Precision[i] = .5 -- default precision
bindKey(playerSource, "i", "down", moveIt2)
bindKey(playerSource, "j", "down", moveIt2)
bindKey(playerSource, "k", "down", moveIt2)
bindKey(playerSource, "l", "down", moveIt2)
bindKey(playerSource, "mouse_wheel_up", "down", moveIt2)
bindKey(playerSource, "mouse_wheel_down", "down", moveIt2)
bindKey(playerSource, "pgup", "down", moveIt2)
bindKey(playerSource, "pgdn", "down", moveIt2)
bindKey(playerSource, "u", "down", moveIt2)
bindKey(playerSource, "o", "down", moveIt2)
bindKey(playerSource, "[", "down", moveIt2)
bindKey(playerSource, "]", "down", moveIt2)
bindKey(playerSource, "enter", "down", collisionObject, team, objectID)
bindKey(playerSource, "delete", "down", removeIt, playerSource)
break -- done adding our object and who created it to the arrays... stop the loop
end
end
end
function changePrecision(playerSource,commandName,value)
if value then
for i = 1,20 do
if Editor[i] == playerSource then
Precision[i] = value
outputChatBox("Sensitivity set to: " .. value .. "", playerSource)
break
end
end
end
end
function moveIt(source, key, keyState)
for i = 1,20 do
if Editor[i] == source then
object = Gate[i]
prec = Precision[i]
break
end
end
if key == "i" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x,y + prec,z )
end
if key =="j" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x - prec,y,z )
end
if key =="l" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x + prec,y,z )
end
if key =="k" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x,y - prec,z )
end
if key =="pgup" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x,y,z + prec )
end
if key =="pgdn" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x,y ,z - prec )
end
-- rotation --
if key =="mouse_wheel_up" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx,ry,rz - prec * 5)
end
if key =="mouse_wheel_down" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx,ry,rz + prec * 5)
end
if key =="u" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx,ry - prec*10,rz)
end
if key =="o" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx,ry + prec*10,rz)
end
if key =="[" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx- prec*10,ry,rz)
end
if key =="]" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx+ prec*10,ry,rz)
end
end
function moveIt2(source, key, keyState)
for i = 1,20 do
if Editor[i] == source then
object = Gate2[i]
prec = Precision[i]
break
end
end
if key == "i" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x,y + prec,z )
end
if key =="j" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x - prec,y,z )
end
if key =="l" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x + prec,y,z )
end
if key =="k" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x,y - prec,z )
end
if key =="pgup" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x,y,z + prec )
end
if key =="pgdn" then
x,y,z = getElementPosition(object)
setElementPosition ( object, x,y ,z - prec )
end
-- rotation --
if key =="mouse_wheel_up" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx,ry,rz - prec * 5)
end
if key =="mouse_wheel_down" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx,ry,rz + prec * 5)
end
if key =="u" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx,ry - prec*10,rz)
end
if key =="o" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx,ry + prec*10,rz)
end
if key =="[" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx- prec*10,ry,rz)
end
if key =="]" then
rx,ry,rz = getObjectRotation(object)
setObjectRotation ( object, rx+ prec*10,ry,rz)
end
end
function removeIt(playerSource)
for i = 1,20 do
if Editor[i] == playerSource then
destroyElement(Gate[i])
destroyElement(Gate2[i])
destroyElement(coll[i])
Gate[i] = null
Editor[i] = null
Gate2[i] = null
Precision[i] = null
coll[i] = null
unbindKey ( playerSource, "i" )
unbindKey ( playerSource, "j" )
unbindKey ( playerSource, "k" )
unbindKey ( playerSource, "l" )
unbindKey ( playerSource, "pgup" )
unbindKey ( playerSource, "pgdn" )
unbindKey ( playerSource, "mouse_wheel_down")
unbindKey ( playerSource, "mouse_wheel_up" )
unbindKey ( playerSource, "enter" )
unbindKey ( playerSource, "delete" )
unbindKey ( playerSource, "u" )
unbindKey ( playerSource, "o" )
unbindKey ( playerSource, "[" )
unbindKey ( playerSource, "]" )
end
end
end
function collisionObject(playerSource, key, keyState, team, objID)
unbindKey ( playerSource, "i" )
unbindKey ( playerSource, "j" )
unbindKey ( playerSource, "k" )
unbindKey ( playerSource, "l" )
unbindKey ( playerSource, "pgup" )
unbindKey ( playerSource, "pgdn" )
unbindKey ( playerSource, "mouse_wheel_down")
unbindKey ( playerSource, "mouse_wheel_up" )
unbindKey ( playerSource, "enter" )
unbindKey ( playerSource, "delete" )
unbindKey ( playerSource, "u" )
unbindKey ( playerSource, "o" )
unbindKey ( playerSource, "[" )
unbindKey ( playerSource, "]" )
local x,y,z = getElementPosition(playerSource)
object = createMarker ( x,y,z+2 , "arrow", 3, 255,0,0,100 )
object2 = createMarker ( x+10,y,z+2 , "arrow", 3, 255,0,0,100 )
object3 = createMarker ( x,y+10,z+2 , "arrow", 3, 255,0,0,100 )
object4 = createMarker ( x+10,y+10,z+2, "arrow", 3, 255,0,0,100 )
setElementInterior(object, getElementInterior(playerSource))
setElementInterior(object2, getElementInterior(playerSource))
setElementInterior(object3, getElementInterior(playerSource))
setElementInterior(object4, getElementInterior(playerSource))
outputDebugString("created gates")
for i = 1,20 do
if Editor[i] == playerSource then
coll[i] = object
coll2[i] = object2
coll3[i] = object3
coll4[i] = object4
break
end
end
bindKey(playerSource, "i", "down", moveColl)
bindKey(playerSource, "j", "down", moveColl)
bindKey(playerSource, "k", "down", moveColl)
bindKey(playerSource, "l", "down", moveColl)
bindKey(playerSource, "mouse_wheel_up", "down", moveColl)
bindKey(playerSource, "mouse_wheel_down", "down", moveColl)
bindKey(playerSource, "pgup", "down", moveColl)
bindKey(playerSource, "pgdn", "down", moveColl)
bindKey(playerSource, "u", "down", moveColl)
bindKey(playerSource, "o", "down", moveColl)
bindKey(playerSource, "[", "down", moveColl)
bindKey(playerSource, "]", "down", moveColl)
bindKey(playerSource, "enter", "down", saveIt, team, objID)
bindKey(playerSource, "delete", "down", removeIt, playerSource)
end
function moveColl(source, key, keyState)
for i = 1,20 do
if Editor[i] == source then
object = coll[i]
object2 = coll2[i]
object3 = coll3[i]
object4 = coll4[i]
prec = Precision[i]
break
end
end
if key == "i" then
x,y,z = getElementPosition(object)
x2,y2,z2 = getElementPosition(object2)
x3,y3,z3 = getElementPosition(object3)
x4,y4,z4 = getElementPosition(object4)
setElementPosition ( object, x,y + prec,z )
setElementPosition ( object2, x2,y2 + prec,z2 )
setElementPosition ( object3, x3,y3 + prec,z3 )
setElementPosition ( object4, x4,y4 + prec,z4 )
end
if key =="j" then
x,y,z = getElementPosition(object)
x2,y2,z2 = getElementPosition(object2)
x3,y3,z3 = getElementPosition(object3)
x4,y4,z4 = getElementPosition(object4)
setElementPosition ( object, x - prec,y,z )
setElementPosition ( object2, x2 - prec,y2,z2 )
setElementPosition ( object3, x3 - prec,y3,z3 )
setElementPosition ( object4, x4 - prec,y4,z4 )
end
if key =="l" then
x,y,z = getElementPosition(object)
x2,y2,z2 = getElementPosition(object2)
x3,y3,z3 = getElementPosition(object3)
x4,y4,z4 = getElementPosition(object4)
setElementPosition ( object, x + prec,y,z )
setElementPosition ( object2, x2 + prec,y2,z2 )
setElementPosition ( object3, x3 + prec,y3,z3 )
setElementPosition ( object4, x4 + prec,y4,z4 )
end
if key =="k" then
x,y,z = getElementPosition(object)
x2,y2,z2 = getElementPosition(object2)
x3,y3,z3 = getElementPosition(object3)
x4,y4,z4 = getElementPosition(object4)
setElementPosition ( object, x,y - prec,z )
setElementPosition ( object2, x2,y2 - prec,z2 )
setElementPosition ( object3, x3,y3 - prec,z3 )
setElementPosition ( object4, x4,y4 - prec,z4 )
end
if key =="pgup" then
x,y,z = getElementPosition(object)
x2,y2,z2 = getElementPosition(object2)
x3,y3,z3 = getElementPosition(object3)
x4,y4,z4 = getElementPosition(object4)
setElementPosition ( object, x,y,z + prec )
setElementPosition ( object2, x2,y2,z2 + prec )
setElementPosition ( object3, x3,y3,z3 + prec )
setElementPosition ( object4, x4,y4,z4 + prec )
end
if key =="pgdn" then
x,y,z = getElementPosition(object)
x2,y2,z2 = getElementPosition(object2)
x3,y3,z3 = getElementPosition(object3)
x4,y4,z4 = getElementPosition(object4)
setElementPosition ( object, x,y ,z - prec )
setElementPosition ( object2, x2,y2 ,z2 - prec )
setElementPosition ( object3, x3,y3 ,z3 - prec )
setElementPosition ( object4, x4,y4 ,z4 - prec )
end
-- rotation --
if key =="mouse_wheel_up" then
x,y,z = getElementPosition(object)
x2,y2,z2 = getElementPosition(object2)
x3,y3,z3 = getElementPosition(object3)
x4,y4,z4 = getElementPosition(object4)
setElementPosition ( object, x, y , z )
setElementPosition ( object2, x2+prec,y2 ,z2 )
setElementPosition ( object3, x3,y3+prec ,z3 )
setElementPosition ( object4, x4+prec,y4+prec ,z4 )
end
if key =="mouse_wheel_down" then
x,y,z = getElementPosition(object)
x2,y2,z2 = getElementPosition(object2)
x3,y3,z3 = getElementPosition(object3)
x4,y4,z4 = getElementPosition(object4)
setElementPosition ( object, x, y , z )
setElementPosition ( object2, x2-prec,y2 ,z2 )
setElementPosition ( object3, x3,y3-prec ,z3 )
setElementPosition ( object4, x4-prec,y4-prec ,z4 )
end
if key =="u" then
rx,ry,rz = getObjectRotation(object)
rx2,ry2,rz2 = getObjectRotation(object2)
rx3,ry3,rz3 = getObjectRotation(object3)
rx4,ry3,rz3 = getObjectRotation(object4)
setObjectRotation ( object, rx,ry - prec*10,rz)
setObjectRotation ( object2, rx2,ry2 - prec*10,rz2)
setObjectRotation ( object3, rx3,ry3 - prec*10,rz3)
setObjectRotation ( object4, rx4,ry4 - prec*10,rz4)
end
if key =="o" then
rx,ry,rz = getObjectRotation(object)
rx2,ry2,rz2 = getObjectRotation(object)
rx3,ry3,rz3 = getObjectRotation(object)
rx4,ry3,rz3 = getObjectRotation(object)
setObjectRotation ( object, rx,ry + prec*10,rz)
setObjectRotation ( object2, rx2,ry2 + prec*10,rz2)
setObjectRotation ( object3, rx3,ry3 + prec*10,rz3)
setObjectRotation ( object4, rx4,ry4 + prec*10,rz4)
end
if key =="[" then
rx,ry,rz = getObjectRotation(object)
rx2,ry2,rz2 = getObjectRotation(object2)
rx3,ry3,rz3 = getObjectRotation(object3)
rx4,ry3,rz3 = getObjectRotation(object4)
setObjectRotation ( object, rx- prec*10,ry,rz)
setObjectRotation ( object2, rx2- prec*10,ry2,rz2)
setObjectRotation ( object3, rx3- prec*10,ry3,rz3)
setObjectRotation ( object4, rx4- prec*10,ry4,rz4)
end
if key =="]" then
rx,ry,rz = getObjectRotation(object)
rx2,ry2,rz2 = getObjectRotation(object2)
rx3,ry3,rz3 = getObjectRotation(object3)
rx4,ry3,rz3 = getObjectRotation(object4)
setObjectRotation ( object, rx+ prec*10,ry,rz)
setObjectRotation ( object2, rx2+ prec*10,ry2,rz2)
setObjectRotation ( object3, rx3+ prec*10,ry3,rz3)
setObjectRotation ( object4, rx4+ prec*10,ry4,rz4)
end
end
function saveIt(playerSource, key, keyState, team, objID)
for i = 1,20 do
if Editor[i] == playerSource then
object = Gate[i]
object2= Gate2[i]
collShape = coll[i]
col2 = coll2[i]
col3 = coll3[i]
col4 = coll4[i]
xtest,y,z = getElementPosition(collShape)
xtest2,y,z= getElementPosition(col4)
colSize = math.abs(xtest-xtest2)
break
end
end
if(team == "") then
team = "false"
end
interior = getElementInterior(playerSource)
unbindKey ( playerSource, "i" )
unbindKey ( playerSource, "j" )
unbindKey ( playerSource, "k" )
unbindKey ( playerSource, "l" )
unbindKey ( playerSource, "pgup" )
unbindKey ( playerSource, "pgdn" )
unbindKey ( playerSource, "mouse_wheel_down")
unbindKey ( playerSource, "mouse_wheel_up" )
unbindKey ( playerSource, "enter" )
unbindKey ( playerSource, "delete" )
unbindKey ( playerSource, "u" )
unbindKey ( playerSource, "o" )
unbindKey ( playerSource, "[" )
unbindKey ( playerSource, "]" )
local x,y,z = getElementPosition(object)
local rx,ry,rz = getObjectRotation(object)
local x2,y2,z2 = getElementPosition(object2)
local rx2,ry2,rz2 = getObjectRotation(object2)
local colx, coly, colz = getElementPosition(collShape)
gates = xmlLoadFile("gates.xml")
-- count = xmlNodeGetChildren(gates)
newGate = xmlCreateChild ( gates, "gate" )
-- xmlNodeSetAttribute ( newGate, "id" , #count+1 )
xmlNodeSetAttribute ( newGate, "x" , x )
xmlNodeSetAttribute ( newGate, "y" , y )
xmlNodeSetAttribute ( newGate, "z" , z )
xmlNodeSetAttribute ( newGate, "rx" , rx )
xmlNodeSetAttribute ( newGate, "ry" , ry )
xmlNodeSetAttribute ( newGate, "rz" , rz )
xmlNodeSetAttribute ( newGate, "x2" , x2 )
xmlNodeSetAttribute ( newGate, "y2" , y2 )
xmlNodeSetAttribute ( newGate, "z2" , z2 )
xmlNodeSetAttribute ( newGate, "rx2", rx2 )
xmlNodeSetAttribute ( newGate, "ry2", ry2 )
xmlNodeSetAttribute ( newGate, "rz2", rz2 )
xmlNodeSetAttribute ( newGate, "objectID" , getElementModel(object))
xmlNodeSetAttribute ( newGate, "team" , team )
xmlNodeSetAttribute ( newGate, "collisionx", colx )
xmlNodeSetAttribute ( newGate, "collisionY", coly )
xmlNodeSetAttribute ( newGate, "collisionZ", colz )
xmlNodeSetAttribute ( newGate, "collisionSize", colSize )
xmlNodeSetAttribute ( newGate, "raising" , 0 )
xmlNodeSetAttribute ( newGate, "interiorID", interior )
destroyElement(object)
destroyElement(object2)
destroyElement(collShape)
destroyElement(col2)
destroyElement(col3)
destroyElement(col4)
for i = 1,20 do
if Editor[i] == playerSource then
Editor[i] = null
Gate[i] = null
Gate2[i] = null
Precision[i] = null
coll[i] = null
coll2[i] = null
coll3[i] = null
coll4[i] = null
end
end
xmlSaveFile(gates)
xmlUnloadFile(gates)
outputDebugString("saved!")
end
function halp(playerSource)
outputChatBox("- usage: /addgate objectID teamName\r\n",playerSource,255,255,240)
outputChatBox("- use the I, J, K and L keys to move the gate, along with the U, O, [ and ] keys for rotational axes\r\n",playerSource, 255,255,0)
outputChatBox("- move the gate where you want it to always be, then hit enter\r\n",playerSource,255,240,0 )
outputChatBox("- now you will be in control of a second object. this is where you want the gate to be moved to once a player gets near it.\r\n",playerSource, 255,0,0)
outputChatBox("- move it with the same keys above, then hit enter again.",playerSource, 240,0,0)
outputChatBox("- at any time, press delete to clear all un-saved objects and start fresh.\r\n",playerSource, 240,0,0)
end
addCommandHandler("addgate", startBuilding)
addCommandHandler("gatehelp", halp)
addCommandHandler("s", changePrecision)
-- <gate x="" y=" z=" rx="" ry="" rz="" x2="" y=2"" z2= "" rx2="" ry2="" rz2="" objectID="" team="" collisionx="" collisionY="" collisionZ="" collisionSize="" raising=""/>
Alles anzeigen
Nun ist meine Frage wie kann ich das machen das ich nur dem User das Tor erstellen kann, und wenn er kurz davor ist es aufgeht und wenn er weg ist es wieder zugeht?
Danke im Voraus