Annas Posted May 12, 2015 Share Posted May 12, 2015 when i changed skin number 0 (CJ) then Execute Command Handler ("loadClothes") i try to make this .. but idk why it's not work HELP function changeSkin(oldModel, newModel) if (getElementType(source) == "player") then if (newModel == 0) then executeCommandHandler ("loadClothes", source) end end addEventHandler("onElementModelChange", root, changeSkin) Link to comment
TAPL Posted May 12, 2015 Share Posted May 12, 2015 Make sure you have the script server side in the meta. Does the command "loadClothes" work when you use it in F8? The command is in server side or client side? Link to comment
Annas Posted May 13, 2015 Author Share Posted May 13, 2015 Make sure you have the script server side in the meta.Does the command "loadClothes" work when you use it in F8? The command is in server side or client side? Make sure you have the script server side in the meta. : (it's SERVER SIDE) Does the command "loadClothes" work when you use it in F8? : (yes, working it load the last clothes ..) The command is in server side or client side? : (it's in SERVER SIDE) server.lua = function loadClothes(player) local account = getPlayerAccount(player) if ( not isGuestAccount(account) ) then local textureString = getAccountData(account, "Clothessaver:Texture") local modelString = getAccountData(account, "Clothessaver:Model") local textures = split(textureString, 44) local models = split(modelString, 44) for i=0, 17, 1 do if ( textures[i+1] ~= " " ) then addPedClothes(player, textures[i+1], models[i+1], i) end end exports.CSTtexts:output("Your CJ Clothes were added Back", 0, 255, 0, true) textures = {} models = {} else outputChatBox("Please login!", player, 255, 0, 0) end end addCommandHandler("loadClothes", loadClothes) HELP .. Link to comment
Annas Posted May 13, 2015 Author Share Posted May 13, 2015 help me please ! i need anyone Fix my code pls ! function changeSkin(oldModel, newModel) if (getElementType(source) == "player") then if (newModel == 0) then executeCommandHandler ("loadClothes", source) end end addEventHandler("onElementModelChange", root, changeSkin) Link to comment
Walid Posted May 13, 2015 Share Posted May 13, 2015 help me please !i need anyone Fix my code pls ! Try this it should work function changeSkin(oldModel, newModel) if (getElementType(source) == "player") then if (newModel == 0) then executeCommandHandler ("loadClothes", source) end end end addEventHandler("onElementModelChange", root, changeSkin) Link to comment
Annas Posted May 13, 2015 Author Share Posted May 13, 2015 help me please !i need anyone Fix my code pls ! Try this it should work function changeSkin(oldModel, newModel) if (getElementType(source) == "player") then if (newModel == 0) then executeCommandHandler ("loadClothes", source) end end end addEventHandler("onElementModelChange", root, changeSkin) when i try it .. Not work i swear ... complete files !! Server.lua (SERVER SIDE) --[[ original script by iannas (iannas ben ahmed) --]] function saveClothes() local account = getPlayerAccount(source) if ( not isGuestAccount(account) ) and ( getElementModel(source) == 0 ) then local texture = {} local model = {} for i=0, 17, 1 do local clothesTexture, clothesModel = getPedClothes(source, i) if ( clothesTexture ~= false ) then table.insert(texture, clothesTexture) table.insert(model, clothesModel) else table.insert(texture, " ") table.insert(model, " ") end end local allTextures = table.concat(texture, ",") local allModels = table.concat(model, ",") outputDebugString("Clothessaver: Saved clothes") setAccountData(account, "Clothessaver:Texture", allTextures) setAccountData(account, "Clothessaver:Model", allModels) texture = {} model = {} end end addEventHandler("onPlayerQuit", getRootElement(), saveClothes) function setClothes() local account = getPlayerAccount(source) if ( not isGuestAccount(account) ) then local textureString = getAccountData(account, "Clothessaver:Texture") local modelString = getAccountData(account, "Clothessaver:Model") local textures = split(textureString, 44) local models = split(modelString, 44) for i=0, 17, 1 do if ( textures[i+1] ~= " " ) then addPedClothes(source, textures[i+1], models[i+1], i) end end exports.CSTtexts:output("Your CJ Clothes were added Back", source, 0, 255, 0, true) textures = {} models = {} end end addEventHandler("onPlayerLogin", getRootElement(), setClothes) function loadClothes(player) local account = getPlayerAccount(player) if ( not isGuestAccount(account) ) then local textureString = getAccountData(account, "Clothessaver:Texture") local modelString = getAccountData(account, "Clothessaver:Model") local textures = split(textureString, 44) local models = split(modelString, 44) for i=0, 17, 1 do if ( textures[i+1] ~= " " ) then addPedClothes(player, textures[i+1], models[i+1], i) end end exports.CSTtexts:output("Your CJ Clothes were added Back", player, 0, 255, 0, true) textures = {} models = {} else outputChatBox("Please login!", player, 255, 0, 0) end end addCommandHandler("loadClothes", loadClothes) function saveClothes(player) local account = getPlayerAccount(player) if ( not isGuestAccount(account) ) then if ( getElementModel(player) == 0 ) then local texture = {} local model = {} for i=0, 17, 1 do local clothesTexture, clothesModel = getPedClothes(player, i) if ( clothesTexture ~= false ) then table.insert(texture, clothesTexture) table.insert(model, clothesModel) else table.insert(texture, " ") table.insert(model, " ") end end local allTextures = table.concat(texture, ",") local allModels = table.concat(model, ",") outputDebugString("Clothessaver: Saved clothes") setAccountData(account, "Clothessaver:Texture", allTextures) setAccountData(account, "Clothessaver:Model", allModels) texture = {} model = {} else exports.CSTtexts:output("Your skin must be skin 0 (CJ Skin)", player, 255, 0, 0, true) end else outputChatBox("Please login!", player, 255, 0, 0) end end addCommandHandler("saveClothes", saveClothes) function changeSkin(oldModel, newModel) if (getElementType(source) == "player") then if (newModel == 0) then executeCommandHandler ("loadClothes", source) end end end addEventHandler("onElementModelChange", root, changeSkin) META.xml "iAnnAs" version="1.1" type="script" name="clothes saver" description="This resources saves the ped's clothes" /> when i reconnect with any other skin number and back the CJ (clothes not saved) but when i click ./loadClothes , clothes will back to the CJ skin when i wear it .. Link to comment
Walid Posted May 13, 2015 Share Posted May 13, 2015 Try this one function changeSkin(oldModel, newModel) if (getElementType(source) == "player") then if (newModel == 0) then loadClothes(source) end end end addEventHandler("onElementModelChange", root, changeSkin) Link to comment
Recommended Posts