supergonkas Posted May 11, 2013 Share Posted May 11, 2013 i have this script ,thats funny hats (and has a dependecy of bone_attachments but i cant make to just one of the objects of the list a special scale,rotation xyz how can i make that ? (also how could i make the objcts be seen by everyone) local hRow = nil hWnd = guiCreateWindow( 0.1, 0.1, 0.2, 0.65, "Hats", true ); hButton_use = guiCreateButton( 0.1, 0.725, 0.5, 0.1, "Use", true, hWnd ); hButton_close = guiCreateButton( 0.1, 0.85, 0.5, 0.1, "Close", true, hWnd ); guiSetVisible(hWnd,false) showCursor(false) local aObjects = { { "Bottle", 1512 }, { "Flag", 2993 }, { "Model car", 2485 }, { "Pro Light", 2701 }, { "Missile", 345 }, { "Magnet", 3056 }, { "AirBomb", 3515 }, { "WW1 hat", 2052 }, { "Captain hat", 2054 }, { "WW2 hat", 2053 } -- you can objects, first add name to see it in gridList, then object ID }; hGrid = guiCreateGridList( 0.1, 0.10, 0.8, 0.60, true, hWnd ); guiGridListAddColumn( hGrid, "ZM hats", 0.85 ); for i,m_obj in ipairs( aObjects ) do hRow = guiGridListAddRow( hGrid ); -- guiGridListSetItemText ( hGrid, hRow, 1, tostring( m_obj [ 1 ] ), false, false ); guiGridListSetItemData ( hGrid, hRow, 1, tostring( m_obj [ 2 ] ) ); end function use ( ) local row, col = guiGridListGetSelectedItem ( hGrid ) if ( row and col and row ~= -1 and col ~= -1 ) then local model = tonumber ( guiGridListGetItemData ( hGrid, row, 1 ) ) if ( isElement ( object ) ) then destroyElement ( object ) end object = createObject ( model, 0, 0, 0 + 0.8, 0, 0, 0 ) exports.bone_attach:attachElementToBone(object, localPlayer,1,0,0,0.1,0,0,0) setobjectscale ( object , 0.5) if ( AirBomb ) then -- if it was created -- set the scale to half the normal scale setObjectScale ( AirBomb, 0.5) -- remove the collision setElementCollisionsEnabled (AirBomb, false) end end end addEventHandler ( "onClientGUIClick", hButton_use, use, false ) function bind_key() guiSetVisible(hWnd, true) showCursor(true) end bindKey("F6","down",bind_key) function close() if (source == hButton_close) then guiSetVisible(hWnd, false) showCursor(false) end end addEventHandler("onClientGUIClick", hButton_close, close) addEventHandler("onClientResourceStart", getRootElement(), function () setInteriorSoundsEnabled(false) end ); Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 You have to create the script server side and there's an optional arguments for the rotation . triggerServerEvent Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 can you show me an example pls its becase the my scrpit has a GUI (its client sided) Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 function use ( ) local row, col = guiGridListGetSelectedItem ( hGrid ) if ( row and col and row ~= -1 and col ~= -1 ) then local ID = guiGridListGetItemText( hRow , hGrid , 1 ) if ( ID ) then triggerServerEvent("CreateObject",localPlayer,ID) end end end addEventHandler ( "onClientGUIClick", hButton_use, use, false ) And complete the script on the server side and make the object as a table for each player . Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 can you help me pls ,i dont know that really much about scripting (started 2 days ago) can you show me how you do whith my script in the server side? pls Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 https://forum.multitheftauto.com/viewtopic.php?f=148&t=40809 If I did this for you, you will never learn anything! Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 i dont whant you to show me the whole scrpit just an example Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 object = { } addEvent("CreateObject",true) adddEventHandler("CreateObject",getRootElement(), function ( id ) if object[source] and isElement ( object[source] ) then destroyElement ( object[source] ) end local x,y,z = getElementPosition ( source ) object[source] = createObject ( id,x,y,z ) -- attach here and do what you want to do ! end ) Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 i modified as you sayd and now it doenst work help me server local hRow = nil hWnd = guiCreateWindow( 0.1, 0.1, 0.2, 0.65, "Hats", true ); hButton_use = guiCreateButton( 0.1, 0.725, 0.5, 0.1, "Use", true, hWnd ); hButton_close = guiCreateButton( 0.1, 0.85, 0.5, 0.1, "Close", true, hWnd ); guiSetVisible(hWnd,false) showCursor(false) local aObjects = { { "Bottle", 1512 }, { "Flag", 2993 }, { "Model car", 2485 }, { "Pro Light", 2701 }, { "Missile", 345 }, { "Magnet", 3056 }, { "AirBomb", 3515 }, { "AirBomb", 14608 }, { "WW1 hat", 2052 }, { "Captain hat", 2054 }, { "WW2 hat", 2053 } -- you can objects, first add name to see it in gridList, then object ID }; hGrid = guiCreateGridList( 0.1, 0.10, 0.8, 0.60, true, hWnd ); guiGridListAddColumn( hGrid, "ZM hats", 0.85 ); for i,m_obj in ipairs( aObjects ) do hRow = guiGridListAddRow( hGrid ); -- guiGridListSetItemText ( hGrid, hRow, 1, tostring( m_obj [ 1 ] ), false, false ); guiGridListSetItemData ( hGrid, hRow, 1, tostring( m_obj [ 2 ] ) ); object = { } addEvent("CreateObject",true) adddEventHandler("CreateObject",getRootElement(), function ( id ) if object[source] and isElement ( object[source] ) then destroyElement ( object[source] ) end local x,y,z = getElementPosition ( source ) object[source] = createObject ( id,x,y,z ) -- attach here and do what you want to do ! end ) exports.bone_attach:attachElementToBone(object, localPlayer,1,0,0,0.1,0,0,0) setobjectscale ( object , 0.5) end function bind_key() guiSetVisible(hWnd, true) showCursor(true) end bindKey("F6","down",bind_key) function close() if (source == hButton_close) then guiSetVisible(hWnd, false) showCursor(false) end end addEventHandler("onClientGUIClick", hButton_close, close) client function use ( ) local row, col = guiGridListGetSelectedItem ( hGrid ) if ( row and col and row ~= -1 and col ~= -1 ) then local ID = guiGridListGetItemText( hRow , hGrid , 1 ) if ( ID ) then triggerServerEvent("CreateObject",localPlayer,ID) end end end addEventHandler ( "onClientGUIClick", Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 pls i really need help it says attenpt to call guicreatwindow a nil value Link to comment
Castillo Posted May 11, 2013 Share Posted May 11, 2013 Check the meta.xml, you surely have the script set as server side, but it's a client side script. Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 i need help i made the changes that mr prestege sayd and it is ruin it doensent work no more Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 -- # Server Side object = { } addEvent("CreateTheObject",true) addEventHandler("CreateTheObject",getRootElement(), function ( Model ) if ( object[source] and isElement ( object[source] ) ) then destroyElement ( object[source] ) end local x,y,z = getElementPosition ( source ) object[source] = createObject ( Model , x , y , z ) setObjectScale ( object[source] , 0.5 ) exports.bone_attach:attachElementToBone(object[source],source,1,0,0,0.1,0,0,0) if getElementModel ( object[source] ) == 3515 then setElementCollisionsEnabled ( object[source],false ) end end ) -- # Client Side local hRow = nil hWnd = guiCreateWindow( 0.1, 0.1, 0.2, 0.65, "Hats", true ); hButton_use = guiCreateButton( 0.1, 0.725, 0.5, 0.1, "Use", true, hWnd ); hButton_close = guiCreateButton( 0.1, 0.85, 0.5, 0.1, "Close", true, hWnd ); guiSetVisible(hWnd,false) showCursor(false) local aObjects = { { "Bottle", 1512 }, { "Flag", 2993 }, { "Model car", 2485 }, { "Pro Light", 2701 }, { "Missile", 345 }, { "Magnet", 3056 }, { "AirBomb", 3515 }, { "WW1 hat", 2052 }, { "Captain hat", 2054 }, { "WW2 hat", 2053 } -- you can objects, first add name to see it in gridList, then object ID }; hGrid = guiCreateGridList( 0.1, 0.10, 0.8, 0.60, true, hWnd ); guiGridListAddColumn( hGrid, "ZM hats", 0.85 ); for i,m_obj in ipairs( aObjects ) do hRow = guiGridListAddRow( hGrid ); guiGridListSetItemText ( hGrid, hRow, 1, tostring( m_obj [ 1 ] ), false, false ); guiGridListSetItemData ( hGrid, hRow, 1, tostring( m_obj [ 2 ] ) ); end addEventHandler ( "onClientGUIClick",hButton_use, function ( ) local row, col = guiGridListGetSelectedItem ( hGrid ) if ( row and col and row ~= -1 and col ~= -1 ) then local model = tonumber ( guiGridListGetItemData ( hGrid, row, 1 ) ) triggerServerEvent("CreateTheObject",localPlayer,model) end end,false ) addEventHandler ( "onClientGUIClick",hButton_close, function ( ) guiSetVisible(hWnd, false) showCursor(false) end,false ) bindKey("F6","down", function ( ) guiSetVisible ( hWnd , not guiGetVisible ( hWnd ) ) showCursor ( guiGetVisible ( hWnd ) ) end ) Try it. Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 its working ,but just one more thing how can i set the position for a special object? (just explain that i think i can do ) Link to comment
iPrestege Posted May 11, 2013 Share Posted May 11, 2013 if getElementModel ( object[source] ) == ObjectID then -- Do what you want ! Change the object it to you're object id ! Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 thanks,that i know how to work with Link to comment
supergonkas Posted May 11, 2013 Author Share Posted May 11, 2013 one more thing how can i make costom objects instead of using ids ? i tried like example object = createMarker ( x , y , z, "cylinder", 1.5, 255, 255, 0, 170 ) and didnt worked how could i do that? Link to comment
iPrestege Posted May 12, 2013 Share Posted May 12, 2013 You are not make any sense with that. Link to comment
supergonkas Posted May 12, 2013 Author Share Posted May 12, 2013 so ,you say that is impossible to like markers to player head? Link to comment
iPrestege Posted May 12, 2013 Share Posted May 12, 2013 No i don't say that ! You can do that : createMarker attachElements Link to comment
supergonkas Posted May 12, 2013 Author Share Posted May 12, 2013 but how i add the markers to the GUI grid? Link to comment
iPrestege Posted May 12, 2013 Share Posted May 12, 2013 Hmmm..You can make the marker at the server side the same way i create the object with and to add the marker to the grid add it to the table. Link to comment
supergonkas Posted May 12, 2013 Author Share Posted May 12, 2013 but it isnt the way i showed? 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