synskidz Posted April 18, 2020 Share Posted April 18, 2020 I edit it from resource called "Freeroam". There is a bookmark option for save player location but i want to change it to save player skin. What's wrong with my code. This is the client-side Lua local bookmarkList local bookmarks function initBookmarks () bookmarkList = wndBookmarks.controls[1].element if bookmarks then return end loadBookmarks () addEventHandler("onClientGUIDoubleClick",bookmarkList,gotoBookmark) end function loadBookmarks () bookmarks = {} local xml = xmlLoadFile("bookmarks.xml") if not xml then xml = xmlCreateFile("bookmarks.xml","catalog") end guiGridListClear(bookmarkList) for i,child in ipairs (xmlNodeGetChildren(xml) or {}) do local row = guiGridListAddRow(bookmarkList) guiGridListSetItemText(bookmarkList,row,1,tostring(xmlNodeGetAttribute(child,"name")),false,false) guiGridListSetItemText(bookmarkList,row,2,tostring(xmlNodeGetAttribute(child,"zone")),false,false) bookmarks[row+1] = {tonumber(xmlNodeGetAttribute(child,"x"))} end end function saveBookmarks () if fileExists("bookmarks.xml") then fileDelete("bookmarks.xml") end local xml = xmlCreateFile("bookmarks.xml","catalog") for row=0,(guiGridListGetRowCount(bookmarkList)-1) do local child = xmlCreateChild(xml,"bookmark") xmlNodeSetAttribute(child,"name",guiGridListGetItemText(bookmarkList,row,1)) xmlNodeSetAttribute(child,"zone",guiGridListGetItemText(bookmarkList,row,2)) xmlNodeSetAttribute(child,"x",tostring(bookmarks[row+1][1])) --xmlNodeSetAttribute(child,"y",tostring(bookmarks[row+1][2])) --xmlNodeSetAttribute(child,"z",tostring(bookmarks[row+1][3])) end xmlSaveFile(xml) xmlUnloadFile(xml) end function saveLocation () local name = getControlText(wndBookmarks,"bookmarkname") if name ~= "" then local x = getElementModel(g_Me) local zone = getZoneName(x,y,z,false) if x and y and z then local row = guiGridListAddRow(bookmarkList) guiGridListSetItemText(bookmarkList,row,1,name,false,false) guiGridListSetItemText(bookmarkList,row,2,zone,false,false) bookmarks[row+1] = {x} setControlText(wndBookmarks,"bookmarkname","") saveBookmarks() end else outputChatBox("Please enter a name for the bookmark") end end function deleteLocation () local row,column = guiGridListGetSelectedItem(bookmarkList) if row and row ~= -1 then table.remove(bookmarks,row+1) guiGridListRemoveRow(bookmarkList,row) saveBookmarks() end end function gotoBookmark () local row,column = guiGridListGetSelectedItem(bookmarkList) if row and row ~= -1 then fadeCamera(false) if isPedDead(g_Me) then setTimer(server.spawnMe,1000,1,unpack(bookmarks[row+1])) else setTimer(setElementModel,1000,1,g_Me,unpack(bookmarks[row+1])) --setElementModel(player, skin) --setTimer(setElementPosition,1000,1,g_Me,unpack(bookmarks[row+1])) end setTimer(function () fadeCamera(true) setCameraTarget(g_Me) end,2000,1) end end wndBookmarks = { 'wnd', text = 'Bookmarks', width = 400, x = -300, y = 0.2, controls = { { 'lst', id='bookmarklist', width=400, columns={ {text='Name', attr='name', width=0.3}, {text='Zone', attr='zone', width=0.6} } }, {'txt', id='bookmarkname', text='', width=225}, {'btn', id='save current location', onclick=saveLocation, width=150}, {'btn', id='delete selected location', onclick=deleteLocation, width=225}, {'btn', id='close', closeswindow=true, width=150} }, oncreate = initBookmarks } 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