FlorjanMTARP Posted July 28, 2014 Posted July 28, 2014 Well, I need some assistance. I've been recently doing a furniture system and I've done alot. But now the time comes when I want to make specific building areas where only owner of areas can build. For now I've only add a command to open GUI and add objects, delete objects command and cursor command. This are the scripts: GUI function handler(playerSource, commandName) spawn = true use = 0 local gui = getElementsByType("gui-window") for key,guiElement in ipairs(gui) do guiSetVisible ( guiElement, false ) end showCursor ( false ) row, column = guiGridListGetSelectedItem ( list ) name = guiGridListGetItemText ( list, row, 1 ) id = name playerSource = getLocalPlayer() if spawn == true then if id ~= "" then triggerServerEvent ( "addObjectserv", getRootElement(), playerSource, commandName, id ) end end end function startGui(gui) x,y = guiGetScreenSize () y = y / 2 - 235 x = x - 500 showCursor ( true ) GUIEditor_Window = {} buttonmain = {} GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} gui = guiCreateWindow(x,y,405,536,"MTARP - Furniture System",false) button = guiCreateButton(0.08780487626791,0.89552241563797,0.32682925462723,0.072761192917824,"Add",true,gui) button2 = guiCreateButton(0.51707315444946,0.89925372600555,0.32195121049881,0.067164182662964,"Quit",true,gui) list = guiCreateGridList(0.043902438133955,0.02985074557364,0.91219514608383,0.82276117801666,true,gui) addEventHandler ( "onClientGUIClick", button, handler ) addEventHandler ( "onClientGUIClick", button2, cancel ) guiGridListSetSelectionMode(list,2) guiGridListAddColumn(list,"ID",0.40) guiGridListAddColumn(list,"Name",0.9) node = xmlLoadFile("models.xml") for i = 0,24 do subnode = xmlFindSubNode(node,"model", i) id = xmlNodeGetAttribute(subnode,"id") name = xmlNodeGetAttribute(subnode, "name") row = guiGridListAddRow ( list ) guiGridListSetItemText ( list, row, 1, tostring(id), false, false ) guiGridListSetItemText ( list, row, 2, tostring(name), false, false ) end end addEvent("addObject", true) addEventHandler("addObject", getRootElement(), startGui, gui) Object placement use = 0 gui = 1 function delete(source) show = 1 showCursor ( source, true) end function obscurename(mouseButton, buttonState, playerWhoClicked,clickPosX,clickPosY,clickPosZ) if show == 1 then destroyElement(source) show = 0 showCursor ( playerWhoClicked, false) end end function cursorshow(source) show = 0 showCursor ( source, false) end function done(playerSource, key, keyState, id) unbindKey ( playerSource, "arrow_u") unbindKey ( playerSource, "arrow_d") unbindKey ( playerSource, "pgup") unbindKey ( playerSource, "pgdn") unbindKey ( playerSource, "arrow_r") unbindKey ( playerSource, "arrow_l") unbindKey ( playerSource, "mouse_wheel_down") unbindKey ( playerSource, "mouse_wheel_up") unbindKey ( playerSource, "enter") unbindKey ( playerSource, "delete") x,y,z = getElementPosition(object) rx,ry,rz = getObjectRotation(object) file = fileOpen ( "theobjects.lua" ) size = fileGetSize ( file ) fileSetPos(file, size - 98) fileWrite ( file, "\r\n createObject (" .. id .. " , " .. x .. ", " .. y .. " , " .. z .. " , " .. rx .. " , " .. ry .. ", " .. rz .. ") \r\nend \r\n\r\naddEventHandler ( 'onResourceStart', getResourceRootElement(getThisResource()), start )") fileClose ( file ) outputChatBox("Successfully added.", playerSource) use = 0 end function remove(playerSource) use = 0 destroyElement(object) outputChatBox("Object removed", playerSource) unbindKey ( playerSource, "i") unbindKey ( playerSource, "j") unbindKey ( playerSource, "pgup") unbindKey ( playerSource, "pgdn") unbindKey ( playerSource, "k") unbindKey ( playerSource, "l") unbindKey ( playerSource, "mouse_wheel_down") unbindKey ( playerSource, "mouse_wheel_up") unbindKey ( playerSource, "enter") unbindKey ( playerSource, "delete") end function movecar(source, key, keyState) if key == "arrow_u" then x,y,z = getElementPosition(object) setElementPosition ( object, x,y + .5,z ) end if key =="arrow_d" then x,y,z = getElementPosition(object) setElementPosition ( object, x - .5,y,z ) end if key =="arrow_r" then x,y,z = getElementPosition(object) setElementPosition ( object, x + .5,y,z ) end if key =="arrow_l" then x,y,z = getElementPosition(object) setElementPosition ( object, x,y - .5,z ) end if key =="pgup" then x,y,z = getElementPosition(object) setElementPosition ( object, x,y,z + .5 ) end if key =="pgdn" then x,y,z = getElementPosition(object) setElementPosition ( object, x,y ,z - .5 ) end -- rotation -- if key =="mouse_wheel_up" then rx,ry,rz = getObjectRotation(object) setObjectRotation ( object, rx,ry,rz - 5 ) end if key =="mouse_wheel_down" then rx,ry,rz = getObjectRotation(object) setObjectRotation ( object, rx,ry,rz + 5) end end function triggerGui(playerSource, commandName, id) if use == 0 then use = 1 triggerClientEvent (playerSource, "addObject", getRootElement(), playerSource, commandName) else outputChatBox("object currently being edited", playerSource) end end function carAdd(playerSource, commandName, id) id = id outputChatBox( "controls: Arrows.. mousewheel, pgup, pgdn | enter when done", playerSource, 0, 255) local x,y,z = getElementPosition(playerSource) object = createObject ( id, x + 3,y,z) bindKey(playerSource, "arrow_u", "down", movecar) bindKey(playerSource, "arrow_d", "down", movecar) bindKey(playerSource, "arrow_r", "down", movecar) bindKey(playerSource, "arrow_l", "down", movecar) bindKey(playerSource, "mouse_wheel_up", "down", movecar) bindKey(playerSource, "mouse_wheel_down", "down", movecar) bindKey(playerSource, "enter", "down", done, id) bindKey(playerSource, "delete", "down", remove, playerSource) bindKey(playerSource, "pgup", "down", movecar) bindKey(playerSource, "pgdn", "down", movecar) end addEvent("addObjectserv", true) addEventHandler("addObjectserv", getRootElement(), carAdd) addCommandHandler( "addobject", triggerGui) addCommandHandler( "del", delete) addCommandHandler( "imstupid", cursorshow) addEventHandler( "onElementClicked", getRootElement(), obscurename ) I won't post necessary files like meta,models. ALL I WANT TO MAKE IS AREAS WHERE PEOPLE CAN BUY THEM IF ITS NOT OWNED. IF THE OWNER IS IN HIS AREA HE CAN PLACE OBJECTS. I HAVE ONLY DONE IT SO EVERYONE CAN DELETE EVERYTHING OF ANOTHER PERSON AND PLACE WHEREVER. Please help :- )
Saml1er Posted July 28, 2014 Posted July 28, 2014 You SQL,MySql or Db functions to insert/retrieve owners.
FlorjanMTARP Posted July 29, 2014 Author Posted July 29, 2014 You SQL,MySql or Db functions to insert/retrieve owners. I have never tried that yet. Anyone else could give me any more information about such?
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