Anulesked Posted January 29, 2014 Share Posted January 29, 2014 Help me please, guys: local playerDataTable = { {"torso"} } function saveSkin(player,clothesType) local account = getPlayerAccount(player) local tex, mod = getPedClothes(player, clothesType) for i, data in ipairs(playerDataTable) do setAccountData(account, data[1], "\""..tex.."\",\""..mod.."\"") outputChatBox("saved #"..i..": "..getAccountData(account, data[1])) end end addCommandHandler("s", saveSkin) function loadSkin(player) local account = getPlayerAccount(player) for i, data in ipairs(playerDataTable) do local account = getPlayerAccount(player) addPedClothes (player, getAccountData(account, data[1]), 0) outputChatBox("saved #"..i..": "..getAccountData(account, data[1])) end end addCommandHandler("x", loadSkin) Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 local playerDataTable = { {"torso"} } --too: local playerDataTable = { "torso"--, --"stuff" } setAccountData(account, data[1], "\""..tex.."\",\""..mod.."\"") --Too: setAccountData(account, data, tex..",".. mod .. "," .. clothesType) addPedClothes (player, getAccountData(account, data[1]), 0) --Too: local clothing = getAccountData(account, data) if clothing and getElementModel(player) == 0 then local table = split(clothing,",") addPedClothes (player,table[1] , table[2],tonumber(table[3])) end And don't forget this function: isGuestAccount Link to comment
Anulesked Posted January 29, 2014 Author Share Posted January 29, 2014 IIYAMA, very thank for ur reply! but in my full script table is that: local playerDataTable = { {"torso"}, {"something"}, {"yet something"}, ... } what i must rewrite in ur code with that table? I'm very sorry for my bad english. Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 It is useless to index a table inside a table with just 1 item and that multiply by all items. So yes, you better rewrite the table. Next to that you must know what you are doing. But it seems you are only editing other people their property. Sorry, but I am not going to edit other players their scripts without permission of the owner........... Link to comment
Anulesked Posted January 29, 2014 Author Share Posted January 29, 2014 IIYAMA, but it's my work... from "a" to "z"... Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 ok, sorry, my bad. Did my changes made progress? Link to comment
Anulesked Posted January 29, 2014 Author Share Posted January 29, 2014 (edited) IIYAMA, i get "bad argument @ addPedClothes" as before. local playerDataTable = {"torso"} function saveSkin(player,clothesType) local account = getPlayerAccount(player) local tex, mod = getPedClothes(player, clothesType) for i, data in ipairs(playerDataTable) do setAccountData(account, data, tex..",".. mod .. "," .. clothesType) --outputChatBox("saved #"..i..": "..getAccountData(account, data[1])) end end addCommandHandler("s", saveSkin) function loadSkin(player) local account = getPlayerAccount(player) for i, data in ipairs(playerDataTable) do local account = getPlayerAccount(player) local clothing = getAccountData(account, data) if clothing and getElementModel(player) == 0 then local table = split(clothing,",") addPedClothes (player,table[1] , table[2],tonumber(table[3])) end --outputChatBox("saved #"..i..": "..getAccountData(account, data[1])) end end addCommandHandler("x", loadSkin) and yet i don't know must i get player account before cycle or after. Edited January 29, 2014 by Guest Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 Your skin is 0 ? (because it is only working with cj. Link to comment
Anulesked Posted January 29, 2014 Author Share Posted January 29, 2014 IIYAMA, naturally Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 function saveSkin(player,clothesType) local account = getPlayerAccount(player) if not isGuestAccount(account) and getElementModel(player) == 0 and clothesType then for i, data in ipairs(playerDataTable) do local tex, mod = getPedClothes(player, clothesType) if tex and mod then setAccountData(account, data, tex..",".. mod .. "," .. clothesType) --outputChatBox("saved #"..i..": "..getAccountData(account, data[1])) else outputChatBox("no tex and mod") end end end end addCommandHandler("s", saveSkin) /s 0 function loadSkin(player) local account = getPlayerAccount(player) if not isGuestAccount(account) and getElementModel(player) == 0 then for i, data in ipairs(playerDataTable) do local clothing = getAccountData(account, data) if clothing then local table = split(clothing,",") if table then outputChatBox(tostring(table[1]) .. " " .. tostring(table[2]) .. " " .. tostring(table[3])) addPedClothes (player,table[1] , table[2],tonumber(table[3])) end end --outputChatBox("saved #"..i..": "..getAccountData(account, data[1])) end end end addCommandHandler("x", loadSkin) Well debug it. Sorry (can't use tabs because I am running mac at the moment) Link to comment
Anulesked Posted January 29, 2014 Author Share Posted January 29, 2014 IIYAMA, look: Step #1 Step #2 Step #3 Step #4 Code: (your without edits) I always get it error. Link to comment
TAPL Posted January 29, 2014 Share Posted January 29, 2014 Look here: function saveSkin(player,clothesType) As you're using addCommandHandler, the second parameter is the command name, so it should be: function saveSkin(player, cmd, clothesType) Link to comment
Anulesked Posted January 29, 2014 Author Share Posted January 29, 2014 TAPL, with function saveSkin(player, cmd, clothesType) i get: join.lua:7: Bad argument @ 'getPedClothes' Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 local tex, mod = getPedClothes(player, tonumber(clothesType)) Link to comment
Anulesked Posted January 29, 2014 Author Share Posted January 29, 2014 IIYAMA, local tex, mod = getPedClothes(player, tonumber(clothesType)) i get: join.lua:7: Bad argument @ 'getPedClothes' I'm so sad Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 well debug it..... > outputChatBox That is the best way to solve it. Link to comment
TAPL Posted January 29, 2014 Share Posted January 29, 2014 Have you used the command correctly? /s clothesType /s [0-17] Link to comment
Anulesked Posted January 29, 2014 Author Share Posted January 29, 2014 TAPL, i'm sad and tired. i'll theft others' resources because my is failed. Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 if you debug your script for every step you take, you hardly can make mistakes. It is learning from your mistakes, retry, debug again till you got the problem. You can't fix a problem caused by a problem when you don't see it. 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