Cronoss Posted January 30, 2022 Share Posted January 30, 2022 Hello, I'm trying to make a skin selection system using a table and GUI buttons, but I don't know how to make the skin in "player's vision" change, and he can look himself with the skin selected, wich script or command would help with this? -----Client Side------- local tablaSkinsHombre = {1, 2, 7, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 43, 44, 45, 46, 47, 48, 49, 51, 52, 57, 58, 59, 60, 62, 66, 67, 68, 70, 72, 73, 78, 79, 80, 81, 82, 83, 84, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 132, 133, 134, 135, 136, 137, 142, 143, 144, 146, 147, 154, 155, 156, 158, 159, 160, 161, 163, 164, 165, 166, 167, 168, 170, 171, 173, 174, 175, 176. 177, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 200, 202, 203, 204, 206, 209, 210, 212, 213, 217, 220, 221,222, 223, 227, 228, 229, 230, 234, 235, 236, 239, 240, 241, 242, 247, 248, 249, 250, 252, 253, 254, 255, 258, 259, 261, 262, 264, 269, 270, 271, 272, 290, 291, 292, 293, 294, 295, 297, 299, 300, 301, 302, 303, 306, 307, 308, 310, 311, 312} function skinsHombres() ventanaElegirSkinsH = guiCreateWindow(784, 920, 401, 82, "Elegir apariencia", false) guiWindowSetSizable(ventanaElegirSkinsH, false) btnAnteriorSkin = guiCreateButton(22, 32, 112, 33, "Anterior", false, ventanaElegirSkinsH) btnSiguienteSkin = guiCreateButton(144, 32, 112, 33, "Siguiente", false, ventanaElegirSkinsH) btnSeleccionar = guiCreateButton(266, 32, 112, 33, "Seleccionar", false, ventanaElegirSkinsH) Also, I'm trying to make a variable so if you select being woman, the table will be another one: (this is in another GUIpanel wich saves the name who the player typed and the gender they choose) addEventHandler("onClientGUIClick", btnContinuar, function() NombrePersonaje = guiGetText(nombreYapellido) sexo = guiRadioButtonGetSelected(masculino) -----if I try to put the variable (if (sexo==true) here, the script doesn't work and crash------- triggerServerEvent("definirName", getLocalPlayer(), NombrePersonaje) end) (Client side too) I need an explanation about this, Link to comment
Moderators IIYAMA Posted January 30, 2022 Moderators Share Posted January 30, 2022 13 minutes ago, Cronoss said: "player's vision" change With: https://wiki.multitheftauto.com/wiki/SetCameraMatrix or https://wiki.multitheftauto.com/wiki/GetCamera + https://wiki.multitheftauto.com/wiki/SetElementPosition (https://wiki.multitheftauto.com/wiki/SetElementRotation) See also this useful function for getting the gender of a current skin/model or ped/player. https://wiki.multitheftauto.com/wiki/GetPedGender Link to comment
Cronoss Posted January 30, 2022 Author Share Posted January 30, 2022 Sorry for the misunderstanding, but I didn't meant that, I was talking about "how to make the skin change" so the player can see wich skins he is selecting, the cameraMatrix part it's not a problem Link to comment
βurak Posted January 30, 2022 Share Posted January 30, 2022 (edited) https://wiki.multitheftauto.com/wiki/SetElementModel use: setElementModel (element theElement, int model) Edited January 30, 2022 by Burak5312 1 Link to comment
Cronoss Posted January 31, 2022 Author Share Posted January 31, 2022 Thank you Burak, Is there any command like "set next element in table" or something similar? Link to comment
βurak Posted January 31, 2022 Share Posted January 31, 2022 set next element in table? 1 Link to comment
Cronoss Posted January 31, 2022 Author Share Posted January 31, 2022 (edited) I mean, a Command that would help when I click in the GUIbutton assigned as "next skin", an action that could set the skin on the player while he press the "next skin" button example: "table = {1,2,3} addEventHandler("onClientGUIClick", buttonNextSkin, function() ......." and when the player presses the button, the skin goes from 1 to 3 Edited January 31, 2022 by Cronoss Link to comment
βurak Posted January 31, 2022 Share Posted January 31, 2022 (edited) I haven't tested the code but it could be something like this when the player sees all the skins in the table it will come back to the beginning local currentTableID = 1 addEventHandler("onClientGUIClick", btnContinuar, function() if(currentTableID > #tableSkinsHombre) then currentTableID = 1 end setElementModel(localPlayer, tableSkinsHombre[currentTableID]) currentTableID = currentTableID + 1 end) Edited January 31, 2022 by Burak5312 1 1 Link to comment
๖ۣۜζ͜͡RapGod Posted January 31, 2022 Share Posted January 31, 2022 (edited) 21 minutes ago, Cronoss said: I mean, a Command that would help when I click in the GUIbutton assigned as "next skin", an action that could set the skin on the player while he press the "next skin" button example: "table = {1,2,3} addEventHandler("onClientGUIClick", buttonNextSkin, function() ......." and when the player presses the button, the skin goes from 1 to 3 Well that's easy. You can do this: local skins = {1,2,3} --"nextSkin" is the created button in your window. function setSkin(button) local i = 1 if button == "left" then --if you left clicked the button. if i > #skins then --if it's bigger than the total skin number i= 1 -- set it back to 1. --do whatever u want here. else i = i+1 -- if i is not bigger than the table amount, then increment it. end end addEventHandler("onClientGUIClick",nextSkin,setSkin,false) Edited January 31, 2022 by ๖ۣۜζ͜͡RapGod 1 1 Link to comment
Cronoss Posted January 31, 2022 Author Share Posted January 31, 2022 Thank you both, I solved it, but now I have a bug when I click on the window, the script acts like I pressed "continue", Is there any way to prevent this? Link to comment
βurak Posted January 31, 2022 Share Posted January 31, 2022 (edited) Put false at the end of the onClientGUIClick event so it will only do things when you press the button example: addEventHandler("onClientGUIClick", btnContinuar, function() NombrePersonaje = guiGetText(nombreYapellido) sexo = guiRadioButtonGetSelected(masculino) -----if I try to put the variable (if (sexo==true) here, the script doesn't work and crash------- triggerServerEvent("definirName", getLocalPlayer(), NombrePersonaje) end, false) -- this Edited January 31, 2022 by Burak5312 1 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