nasserdfdd Posted August 8, 2015 Share Posted August 8, 2015 hi all so i have ingame map editor i want u can only build on a specific object like by object id ok so any help if u did not understand i mean i want to be able to build like on a floor but i can build any object script local playerobj = {} local marker = {} objectid = {} maxobjects = 500 function playerLeave () setElementData ( source, "tempbuilder", false ) setElementData ( source, "permbuilder", false ) end function playerJoin () setElementData ( source, "tempbuilder", false ) setElementData ( source, "permbuilder", false ) local pname = getClientName(source) if (pname == "example") or (pname == "example2") then setElementData ( source, "permbuilder", true ) end end function thisResourceStart () local players = getElementsByType ( "player" ) for k,v in ipairs(players) do setElementData ( v, "tempbuilder", false ) setElementData ( v, "permbuilder", false ) local pname = getClientName(v) if (pname == "example") or (pname == "example2") then setElementData ( v, "permbuilder", true ) end end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), thisResourceStart ) addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) addEventHandler ( "onPlayerQuit", getRootElement(), playerLeave ) function guestBuildPlayer ( player, commandName, player2nick ) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) then local player2 = getPlayerFromNick ( player2nick ) local player2n = getClientName ( player2 ) if (getElementData ( player2, "tempbuilder" ) == false) then outputChatBox ( "#FFFF00"..player2n.." recieved map editor pass.", getRootElement(), 255, 255, 255, true ) setElementData ( player2, "tempbuilder" , true ) else outputChatBox ( "#FFFF00"..player2n.." map editor pass removed.", getRootElement(), 255, 255, 255, true ) setElementData ( player2, "tempbuilder" , false ) end else outputChatBox ( "You do not have permission to do that.", player ) end end addCommandHandler("guestb", guestBuildPlayer ) function createCurrentObject (player,cmd,objid) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then outputChatBox ( "You are already editing an object. Please save or delete to make another.", player ) else local x, y, z = getElementPosition(player) destroyMObj (player) playerobj[player] = createObject(tonumber(objid), x + 5, y + 5, z - 1) if marker[player] then destroyElement(marker[player]) end if playerobj[player] then marker[player] = createMarker ( x, y, z, "arrow", 5, 255, 255, 0, 255) attachElementToElement ( marker[player], playerobj[player], 0, 0, 10) else outputChatBox ( "" ..objid.. " does not appear to be a valid model ID.", player ) end end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "mcreate", createCurrentObject ) function cloneCurrentObject (player, cmd, addx, addy, addz, addrx, addry, addrz) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if addx then addx = tonumber(addx) else addx = 0 end if addy then addy = tonumber(addy) else addy = 0 end if addz then addz = tonumber(addz) else addz = 0 end if addrx then addrx = tonumber(addrx) else addrx = 0 end if addry then addry = tonumber(addry) else addry = 0 end if addrz then addrz = tonumber(addrz) else addrz = 0 end if playerobj[player] then local x, y, z = getElementPosition(playerobj[player]) local rx, ry, rz = getObjectRotation(playerobj[player]) local model = getObjectModel ( playerobj[player] ) saveObjID(player) playerobj[player] = createObject(model, x + addx, y + addy, z + addz, rx + addrx, ry + addry, rz + addrz) end if playerobj[player] then marker[player] = createMarker ( x, y, z, "arrow", 5, 255, 255, 0, 255) attachElementToElement ( marker[player], playerobj[player], 0, 0, 10) else outputChatBox ( "Failed to clone object. Make sure you have one selected.", player ) end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "mclone", cloneCurrentObject ) function stackCurrentObject (player, cmd, times, addx, addy, addz, addrx, addry, addrz) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if tonumber(times) < 50 and addx then times = tonumber(times) addx = tonumber(addx) if addy then addy = tonumber(addy) else addy = 0 end if addz then addz = tonumber(addz) else addz = 0 end if addrx then addrx = tonumber(addrx) else addrx = 0 end if addry then addry = tonumber(addry) else addry = 0 end if addrz then addrz = tonumber(addrz) else addrz = 0 end if playerobj[player] then for i=0,times do local x, y, z = getElementPosition(playerobj[player]) local rx, ry, rz = getObjectRotation(playerobj[player]) local model = getObjectModel ( playerobj[player] ) saveObjID(player) playerobj[player] = createObject(model, x + addx, y + addy, z + addz, rx + addrx, ry + addry, rz + addrz) end end if playerobj[player] then marker[player] = createMarker ( x, y, z, "arrow", 5, 255, 255, 0, 255) attachElementToElement ( marker[player], playerobj[player], 0, 0, 10) else outputChatBox ( "Failed to stack object. Make sure you have one selected.", player ) end else outputChatBox ( "Failed to stack object. You can only stack up to 50 items at once. Also make sure you at least specified an X value.", player ) end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "mstack", stackCurrentObject ) function loopCurrentObject (player, cmd, pieces, radi, offset, rotaxis, loops, rota) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then local angle local newi if loops then loops = tonumber(loops) else loops = 1 end if rota then rota = rota*(math.pi/180) else rota = 0 end if rotaxis == "x" or rotaxis == "-x" or rotaxis == "y" or rotaxis == "-y" then --do nothing else rotaxis = "x" end if radi and pieces and offset then radi = tonumber(radi) pieces = tonumber(pieces) offset = tonumber(offset) local spiralp = math.atan((offset/2)/(2*radi))/loops if playerobj[player] then local orx, ory, orz = getElementPosition(playerobj[player]) newi = -1 for i=0,pieces do local x, y, z = getElementPosition(playerobj[player]) local rx, ry, rz = getObjectRotation(playerobj[player]) local model = getObjectModel ( playerobj[player] ) saveObjID(player) local weight = 1-(1/(pieces/2))*math.abs((pieces/2)-i) local radians = (i/pieces)*(2*math.pi)*loops local newx = orx + radi*math.sin(radians)*math.cos(rota)+(offset/2)*math.cos(radians/(2*loops))*-math.sin(rota) local newy = ory +(offset/2)*math.cos(radians/(2*loops))*math.cos(rota)+radi*math.sin(radians)*math.sin(rota) local newz = orz + radi*-math.cos(radians) angle = (((360/pieces)* loops )* newi) if angle <= 359.9999999999999999999999999 then newi = newi + 1 end angle = (((360/pieces)* loops )* newi) if angle >= 360 then newi = -1 angle = (((360/pieces)* loops )* newi) end if rotaxis == "x" then newrotx = angle newroty = ry --+ ((radians)-math.cos(rota)*spiralp*weight) elseif rotaxis == "-x" then newrotx = -angle newroty = ry --+ ((radians)-math.cos(rota)*spiralp*weight) elseif rotaxis == "y" then newrotx = rx --+ ((radians)-math.cos(rota)*spiralp*weight) newroty = angle elseif rotaxis == "-y" then newrotx = rx --+ ((radians)-math.cos(rota)*spiralp*weight) newroty = -angle end playerobj[player] = createObject(model, newx, newy, newz, newrotx, newroty, rz) end end if playerobj[player] then marker[player] = createMarker ( x, y, z, "arrow", 5, 255, 255, 0, 255) attachElementToElement ( marker[player], playerobj[player], 0, 0, 10) else outputChatBox ( "Failed to stack object. Make sure you have one selected.", player ) end Link to comment
GTX Posted August 8, 2015 Share Posted August 8, 2015 Use processLineOfSight to check which object ID is below you or an object. Link to comment
nasserdfdd Posted August 9, 2015 Author Share Posted August 9, 2015 u did not understand me i mean i want that admin can not build anywhere except if they put the object on a id of a floor for example did u get it if yes pls tell me how Link to comment
GTX Posted August 10, 2015 Share Posted August 10, 2015 I did understand you and gave you function. I won't do it for you. For admin: isObjectInACLGroup 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