MarvelSK Posted April 8, 2020 Share Posted April 8, 2020 Hello, I am trying to do creating character with dgsScrollBars (age, weight, heigt, day of born) but it is not uploading new value of scrollbar ... can you help me please ? file c_create_character.Lua = function newCharacter_updateScrollBars() loadstring(exports.dgs:dgsImportFunction())() local gui = {} local curskin = 1 local dummyPed = nil local languageselected = 1 local selectedMonth1 = "Leden" local scrDay = 1 local postavy = getElementData(localPlayer, "account:characters") function newCharacter_init(button, state) guiSetInputEnabled(true) removeEventHandler("onClientPreRender", root, updateCamPosition) setCameraInterior(0) setCameraMatrix(1686.0541992188,-2251.4375,14.441599845886,1686.0384521484,-2250.4411621094,14.356546401978 ) dummyPed = createPed(270, 1686.0166015625, -2247.369140625, 13.542483329773 ) setElementInterior(dummyPed, 0) setElementInterior(getLocalPlayer(), 0) setPedRotation(dummyPed, 180) setElementDimension(dummyPed, getElementDimension(getLocalPlayer())) fadeCamera ( true , 1, 0,0,0 ) local screenX, screenY = guiGetScreenSize() local sWidth,sHeight = guiGetScreenSize() local Width,Height = 318,425 local bgX = (sWidth/2) - (Width/2) local bgY = (sHeight/2) - (Height/2) dxDrawImage(0, 5, 318, 425, "/login-panel/ss.png" , 0, 0, 0, tocolor(255, 255, 255, 255), true) gui["_root"] = dgsCreateWindow(10, screenY/2-300, 300, 620, "Vytvoření postavy", false) dgsWindowSetCloseButtonEnabled(gui["_root"], false) dgsWindowSetSizable(gui["_root"], false) dgsWindowSetMovable(gui["_root"], false) gui["lblCharName"] = dgsCreateLabel(30, 25, 91, 16, "Jméno:", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblCharName"], "left", false) dgsLabelSetVerticalAlign(gui["lblCharName"], "center") gui["txtCharName"] = dgsCreateEdit(90, 24, 180, 22, "", false, gui["_root"]) dgsEditSetMaxLength(gui["txtCharName"], 30) gui["lblCharNameExplanation"] = dgsCreateLabel(30, 40, 240, 80,"Jméno musí být v následujícím formátu \nJméno Příjmení\nPro příklad: Taylor Jackson.\nNesmíš používat známé jména.", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblCharNameExplanation"], "left", false) dgsLabelSetVerticalAlign(gui["lblCharNameExplanation"], "center") --[[ gui["lblCharDesc"] = dgsCreateLabel(10, 125, 230, 100, "When you first spawn type /editlook and describe your character in more detail.", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblCharDesc"], "left", false) dgsLabelSetVerticalAlign(gui["lblCharDesc"], "center")]]-- --[[ gui["memCharDesc"] = guiCreateMemo(10, 145, 231,100, "", false, gui["_root"]) gui["lblCharDescExplanation"] = dgsCreateLabel(10, 245, 231, 61, "Fill in an description of your character, for \nexample how your character looks and\nother special remarks. There is a minimum\nof 50 characters.", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblCharDescExplanation"], "left", false) dgsLabelSetVerticalAlign(gui["lblCharDescExplanation"], "center")]] gui["lblGender"] = dgsCreateLabel(30, 180, 46, 13, "Pohlaví:", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblGender"], "left", false) dgsLabelSetVerticalAlign(gui["lblGender"], "center") gui["rbMale"] = dgsCreateRadioButton(120, 180, 51, 13, "Muž", false, gui["_root"]) gui["rbFemale"] = dgsCreateRadioButton(190, 180, 82, 13, "Žena", false, gui["_root"]) dgsRadioButtonSetSelected ( gui["rbMale"], true) addEventHandler("onDgsMouseClick", gui["rbMale"], newCharacter_updateGender, false) addEventHandler("onDgsMouseClick", gui["rbFemale"], newCharacter_updateGender, false) gui["lblSkin"] = dgsCreateLabel(30, 230, 80, 16, "Skin:", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblSkin"], "left", false) dgsLabelSetVerticalAlign(gui["lblSkin"], "center") gui["btnPrevSkin"] = dgsCreateButton(80, 225, 90, 25, "Předchozí", false, gui["_root"]) addEventHandler("onDgsMouseClick", gui["btnPrevSkin"], newCharacter_updateGender, false) gui["btnNextSkin"] = dgsCreateButton(180, 225, 90, 25, "Další", false, gui["_root"]) addEventHandler("onDgsMouseClick", gui["btnNextSkin"], newCharacter_updateGender, false) gui["lblRace"] = dgsCreateLabel(30, 280, 111, 16, "Rasa:", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblRace"], "left", false) dgsLabelSetVerticalAlign(gui["lblRace"], "center") gui["chkBlack"] = dgsCreateCheckBox ( 80, 280, 55, 16, "Černá", true, false, gui["_root"] ) addEventHandler("onDgsMouseClick", gui["chkBlack"] , newCharacter_raceFix, false) gui["chkWhite"] = dgsCreateCheckBox ( 150, 280, 55, 16, "Bílá", false, false, gui["_root"] ) addEventHandler("onDgsMouseClick", gui["chkWhite"] , newCharacter_raceFix, false) gui["chkAsian"] = dgsCreateCheckBox ( 210, 280, 55, 16, "Žlutá", false, false, gui["_root"] ) addEventHandler("onDgsMouseClick", gui["chkAsian"] , newCharacter_raceFix, false) gui["lblHeight"] = dgsCreateLabel(30, 330, 111, 17, "Výška :", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblHeight"], "left", false) dgsLabelSetVerticalAlign(gui["lblHeight"], "center") gui["scrHeight"] = dgsCreateScrollBar ( 140, 330, 130, 17, true, false, gui["_root"]) addEventHandler("onDgsScrollBarScrollPositionChange", gui["scrHeight"], newCharacter_updateScrollBars, false) dgsSetProperty(gui["scrHeight"], "StepSize", "0.02") gui["lblWeight"] = dgsCreateLabel(30, 360, 130, 17, "Váha :", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblWeight"], "left", false) dgsLabelSetVerticalAlign(gui["lblWeight"], "center") gui["scrWeight"] = dgsCreateScrollBar (140, 360, 130, 17, true, false, gui["_root"]) addEventHandler("onDgsScrollBarScrollPositionChange", gui["scrWeight"], newCharacter_updateScrollBars, false) dgsSetProperty(gui["scrWeight"], "StepSize", "0.01") gui["lblAge"] = dgsCreateLabel(30, 390, 280, 16, "Věk :", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblAge"], "left", false) dgsLabelSetVerticalAlign(gui["lblAge"], "center") gui["scrAge"] = dgsCreateScrollBar ( 140, 390, 130, 17, true, false, gui["_root"]) addEventHandler("onDgsScrollBarScrollPositionChange", gui["scrAge"], newCharacter_updateScrollBars, false) dgsSetProperty(gui["scrAge"], "StepSize", "0.0120") gui["lblDay"] = dgsCreateLabel(30, 420, 111, 16, "Den narození :", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblDay"], "left", false) dgsLabelSetVerticalAlign(gui["lblDay"], "center") gui["scrDay"] = dgsCreateScrollBar ( 140, 420, 130, 16, true, false, gui["_root"]) addEventHandler("onDgsScrollBarScrollPositionChange", gui["scrDay"], newCharacter_updateScrollBars, false) dgsSetProperty(gui["scrDay"], "StepSize", "0.0125") gui["lblMonth"] = dgsCreateLabel(30, 450, 320, 16, "Měsíc narození", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblDay"], "left", false) dgsLabelSetVerticalAlign(gui["lblDay"], "center") gui["drpMonth"] = dgsCreateComboBox ( 140, 450, 130, 16, "Leden", false, gui["_root"]) --guiComboBoxAdjustHeight(gui["drpMonth"], 15) dgsComboBoxAddItem(gui["drpMonth"], "Leden") dgsComboBoxAddItem(gui["drpMonth"], "Únor") dgsComboBoxAddItem(gui["drpMonth"], "Březen") dgsComboBoxAddItem(gui["drpMonth"], "Duben") dgsComboBoxAddItem(gui["drpMonth"], "Květen") dgsComboBoxAddItem(gui["drpMonth"], "Červen") dgsComboBoxAddItem(gui["drpMonth"], "Červenec") dgsComboBoxAddItem(gui["drpMonth"], "Srpen") dgsComboBoxAddItem(gui["drpMonth"], "Září") dgsComboBoxAddItem(gui["drpMonth"], "Říjen") dgsComboBoxAddItem(gui["drpMonth"], "Listopad") dgsComboBoxAddItem(gui["drpMonth"], "Prosinec") addEventHandler ( "onClientGUIComboBoxAccepted", root, function ( comboBox ) if ( comboBox == gui["drpMonth"] ) then local item = dgsComboBoxGetSelected ( gui["drpMonth"] ) selectedMonth1 = tostring ( dgsComboBoxGetItemText ( gui["drpMonth"] , item ) ) end end, true) gui["lblLanguage"] = dgsCreateLabel(30, 500, 111, 16, "Jazyk:", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblLanguage"], "left", false) dgsLabelSetVerticalAlign(gui["lblLanguage"], "center") gui["btnLanguagePrev"] = dgsCreateButton(140, 500, 16, 16, "<", false, gui["_root"]) gui["lblLanguageDisplay"] = dgsCreateLabel(156, 500, 98, 16, "Slovenčina", false, gui["_root"]) dgsLabelSetHorizontalAlign(gui["lblLanguageDisplay"], "center", true) dgsLabelSetVerticalAlign(gui["lblLanguageDisplay"], "center", true) gui["btnLanguageNext"] = dgsCreateButton(254, 500, 16, 16, ">", false, gui["_root"]) addEventHandler("onDgsMouseClick", gui["btnLanguagePrev"] , newCharacter_updateLanguage, false) addEventHandler("onDgsMouseClick", gui["btnLanguageNext"] , newCharacter_updateLanguage, false) gui["btnCancel"] = dgsCreateButton(30, 550, 110, 26, "Zrušit", false, gui["_root"]) addEventHandler("onDgsMouseClick", gui["btnCancel"], newCharacter_cancel, false) gui["btnCreateChar"] = dgsCreateButton(160,550, 110, 26, "Vytvořit", false, gui["_root"]) addEventHandler("onDgsMouseClick", gui["btnCreateChar"], newCharacter_attemptCreateCharacter, false) newCharacter_changeSkin() newCharacter_updateScrollBars() end function newCharacter_raceFix() dgsCheckBoxSetSelected ( gui["chkAsian"], false ) dgsCheckBoxSetSelected ( gui["chkWhite"], false ) dgsCheckBoxSetSelected ( gui["chkBlack"], false ) if (source == gui["chkBlack"]) then dgsCheckBoxSetSelected ( gui["chkBlack"], true ) elseif (source == gui["chkWhite"]) then dgsCheckBoxSetSelected ( gui["chkWhite"], true ) elseif (source == gui["chkAsian"]) then dgsCheckBoxSetSelected ( gui["chkAsian"], true ) end curskin = 1 newCharacter_changeSkin(0) end function newCharacter_updateGender(button, state) if button == "left" and state == "up" then local diff = 0 if (source == gui["btnPrevSkin"]) then diff = -1 elseif (source == gui["btnNextSkin"]) then diff = 1 else curskin = 1 end newCharacter_changeSkin(diff) end end function newCharacter_updateLanguage(button, state) if button == "left" and state == "up" then if source == gui["btnLanguagePrev"] then if languageselected == 1 then languageselected = call( getResourceFromName( "language-system" ), "getLanguageCount" ) else languageselected = languageselected - 1 end elseif source == gui["btnLanguageNext"] then if languageselected == call( getResourceFromName( "language-system" ), "getLanguageCount" ) then languageselected = 1 else languageselected = languageselected + 1 end end dgsSetText(gui["lblLanguageDisplay"], tostring(call( getResourceFromName( "language-system" ), "getLanguageName", languageselected ))) end end function newCharacter_updateScrollBars() local scrollHeight = dgsScrollBarGetScrollPosition(gui["scrHeight"]) scrollHeight = math.floor((scrollHeight / 2) + 160) dgsSetText(gui["lblHeight"], "Výška (cm) : "..scrollHeight.." ") local scrWeight = dgsScrollBarGetScrollPosition(gui["scrWeight"]) scrWeight = math.floor(scrWeight + 50) dgsSetText(gui["lblWeight"], "Váha (kg) : "..scrWeight.." ") local scrAge = dgsScrollBarGetScrollPosition( gui["scrAge"] ) scrAge = math.floor( (scrAge * 0.8 ) + 18 ) dgsSetText(gui["lblAge"], "Věk (rokov) : "..scrAge.." ") local year = getBirthday(tonumber(scrAge)) selectedMonth = monthToNumber(selectedMonth1) --outputDebugString(selectedMonth) local dayCap = daysInMonth(selectedMonth, year) or 31 scrDay = (tonumber(dgsScrollBarGetScrollPosition(gui["scrDay"]))+1)/100 scrDay = math.floor( scrDay*dayCap ) if scrDay == 0 then scrDay = 1 end dgsSetText(gui["lblDay"], "Den narození: "..(scrDay or "1")) end function newCharacter_changeSkin(diff) local array = newCharacters_getSkinArray() local skin = 0 if (diff ~= nil) then curskin = curskin + diff end if (curskin > #array or curskin < 1) then curskin = 1 skin = array[1] else curskin = curskin skin = array[curskin] end if skin ~= nil then setElementModel(dummyPed, tonumber(skin)) end end function newCharacters_getSkinArray() local array = { } if (dgsCheckBoxGetSelected( gui["chkBlack"] )) then -- BLACK if (dgsRadioButtonGetSelected( gui["rbMale"] )) then -- BLACK MALE array = blackMales elseif (dgsRadioButtonGetSelected( gui["rbFemale"] )) then -- BLACK FEMALE array = blackFemales else outputChatBox("Vyber si pohlaví!", 0, 255, 0) end elseif ( dgsCheckBoxGetSelected( gui["chkWhite"] ) ) then -- WHITE if ( dgsRadioButtonGetSelected( gui["rbMale"] ) ) then -- WHITE MALE array = whiteMales elseif ( dgsRadioButtonGetSelected( gui["rbFemale"] ) ) then -- WHITE FEMALE array = whiteFemales else outputChatBox("Vyber si pohlaví!", 0, 255, 0) end elseif ( dgsCheckBoxGetSelected( gui["chkAsian"] ) ) then -- ASIAN if ( dgsRadioButtonGetSelected( gui["rbMale"] ) ) then -- ASIAN MALE array = asianMales elseif ( dgsRadioButtonGetSelected( gui["rbFemale"] ) ) then -- ASIAN FEMALE array = asianFemales else outputChatBox("Vyber si pohlaví!", 0, 255, 0) end end return array end function newCharacter_cancel(hideSelection) guiSetInputEnabled(false) destroyElement(dummyPed) destroyElement(gui["_root"]) gui = {} curskin = 1 dummyPed = nil languageselected = 1 if hideSelection ~= true then Characters_showSelection() end clearChat() end function newCharacter_attemptCreateCharacter() local characterName = dgsGetText(gui["txtCharName"]) local nameCheckPassed, nameCheckError = checkValidCharacterName(characterName) if not nameCheckPassed then LoginScreen_showWarningMessage( "Error processing your character name:\n".. nameCheckError ) return end --[[ local characterDescription = dgsGetText(gui["memCharDesc"]) if #characterDescription < 50 then LoginScreen_showWarningMessage( "Error processing your character\ndescription: Not long enough." ) return elseif #characterDescription > 128 then LoginScreen_showWarningMessage( "Error processing your character\ndescription: Too long." ) return end]] local race = 0 if (dgsCheckBoxGetSelected(gui["chkBlack"])) then race = 0 elseif (dgsCheckBoxGetSelected(gui["chkWhite"])) then race = 1 elseif (dgsCheckBoxGetSelected(gui["chkAsian"])) then race = 2 else LoginScreen_showWarningMessage( "Error processing your character race:\nNone selected." ) return end local gender = 0 if (dgsRadioButtonGetSelected( gui["rbMale"] )) then gender = 0 elseif (dgsRadioButtonGetSelected( gui["rbFemale"] )) then gender = 1 else LoginScreen_showWarningMessage( "Error processing your character gender:\nNone selected." ) return end local skin = getElementModel( dummyPed ) if not skin then LoginScreen_showWarningMessage( "Error processing your character skin:\nNone selected." ) return end local scrollHeight = dgsScrollBarGetScrollPosition(gui["scrHeight"]) scrollHeight = math.floor((scrollHeight / 2) + 150) local scrWeight = dgsScrollBarGetScrollPosition(gui["scrWeight"]) scrWeight = math.floor(scrWeight + 50) local scrAge = dgsScrollBarGetScrollPosition(gui["scrAge"]) scrAge = math.floor( (scrAge * 0.8 ) + 16 ) if languageselected == nil then LoginScreen_showWarningMessage( "Error processing your character language:\nNone selected." ) return end dgsSetEnabled(gui["btnCancel"], false) dgsSetEnabled(gui["btnCreateChar"], false) dgsSetEnabled(gui["_root"], false) fadeCamera(false, 1) setTimer(function () selectStartPointGUI(characterName, characterDescription, race, gender, skin, scrollHeight, scrWeight, scrAge, languageselected, selectedMonth, scrDay) --This is the correct place. /MAXIME end, 1000, 1) end function newCharacter_response(statusID, statusSubID) if (statusID == 1) then LoginScreen_showWarningMessage( "Oops, something went wrong. Try again\nor contact an administrator.\nError ACC"..tostring(statusSubID) ) elseif (statusID == 2) then if (statusSubID == 1) then LoginScreen_showWarningMessage( "This charactername is already in\nuse, sorry :(!" ) else LoginScreen_showWarningMessage( "Oops, something went wrong. Try again\nor contact an administrator.\nError ACD"..tostring(statusSubID) ) end elseif (statusID == 3) then newCharacter_cancel(true) triggerServerEvent("accounts:characters:spawn", getLocalPlayer(), statusSubID) triggerServerEvent("updateCharacters", getLocalPlayer()) --selectStartPointGUI(statusSubID) --Turned out this not where we should have started LOL /Max return end dgsSetEnabled(gui["btnCancel"], true) dgsSetEnabled(gui["btnCreateChar"], true) dgsSetEnabled(gui["_root"], true) end addEventHandler("accounts:characters:new", getRootElement(), newCharacter_response) local wSelectStartPoint = nil function selectStartPointGUI(characterName, characterDescription, race, gender, skin, scrollHeight, scrWeight, scrAge, languageselected, selectedMonth, scrDay ) closeSelectStartPoint() -- Make sure the GUI won't get duplicated and stuck on client's screen at any case. showCursor(true) guiSetInputEnabled(true) --config local locations = { -- x, y, z, rot int, dim Location Name ["default"] = { 1922.9072265625, -1760.6982421875, 13.546875, 0, 0, 0, "A bus stop next to IGS"}, ["bus"] = {1749.509765625, -1860.5087890625, 13.578649520874, 359.0744, 0, 0, "Unity Bus Station"}, ["metro"] = {808.88671875, -1354.6513671875, -0.5078125, 139.5092, 0, 0, "Metro Station"}, ["air"] = {1691.6455078125, -2334.001953125, 13.546875, 0.10711, 0, 0, "Los Santos International Airport"}, ["boat"] = {2809.66015625, -2436.7236328125, 13.628322601318, 90.8995, 0, 0, "Santa Maria Dock"}, } wSelectStartPoint = dgsCreateWindow(0,0, 300, 250, "How do you arrive in Los Santos?", false) exports.global:centerWindow(wSelectStartPoint) local busButton = dgsCreateButton(40, 40, 100, 60, "Bus", false, wSelectStartPoint) addEventHandler("onDgsMouseClick", busButton, function () newCharacter_cancel(true) triggerServerEvent("accounts:characters:new", getLocalPlayer(), characterName, characterDescription, race, gender, skin, scrollHeight, scrWeight, scrAge, languageselected, selectedMonth, scrDay, locations.bus) closeSelectStartPoint() end) local metroButton = dgsCreateButton(40, 120, 100, 60, "Metro", false, wSelectStartPoint) addEventHandler("onDgsMouseClick", metroButton, function() newCharacter_cancel(true) triggerServerEvent("accounts:characters:new", getLocalPlayer(), characterName, characterDescription, race, gender, skin, scrollHeight, scrWeight, scrAge, languageselected, selectedMonth, scrDay, locations.metro) closeSelectStartPoint() end) local airButton = dgsCreateButton(160, 40, 100, 60, "Airplane", false, wSelectStartPoint) addEventHandler("onDgsMouseClick", airButton, function() newCharacter_cancel(true) triggerServerEvent("accounts:characters:new", getLocalPlayer(), characterName, characterDescription, race, gender, skin, scrollHeight, scrWeight, scrAge, languageselected, selectedMonth, scrDay, locations.air) closeSelectStartPoint() end) local boatButton = dgsCreateButton(160, 120, 100, 60, "Boat", false, wSelectStartPoint) addEventHandler("onDgsMouseClick", boatButton, function() newCharacter_cancel(true) triggerServerEvent("accounts:characters:new", getLocalPlayer(), characterName, characterDescription, race, gender, skin, scrollHeight, scrWeight, scrAge, languageselected, selectedMonth, scrDay, locations.boat) closeSelectStartPoint() end) --Temporarily disabled new character spawnpoint selector until we set up all the spawnpoint's shops and locations properly. /Maxime triggerServerEvent("accounts:characters:new", getLocalPlayer(), characterName, characterDescription, race, gender, skin, scrollHeight, scrWeight, scrAge, languageselected, selectedMonth, scrDay, locations.default) closeSelectStartPoint() -- end of the disability end function closeSelectStartPoint() if wSelectStartPoint and isElement(wSelectStartPoint) then destroyElement(wSelectStartPoint) showCursor(false) guiSetInputEnabled(false) end end function isThisYearLeap(year) if (tonumber(year)%4) == 0 then return true else return false end end function monthToNumber(monthName) if not monthName then return 1 else if monthName == "Leden" then return 1 elseif monthName == "Únor" then return 2 elseif monthName == "Březen" then return 3 elseif monthName == "Duben" then return 4 elseif monthName == "Květen" then return 5 elseif monthName == "Červen" then return 6 elseif monthName == "Červenec" then return 7 elseif monthName == "Srpen" then return 8 elseif monthName == "Září" then return 9 elseif monthName == "Říjen" then return 10 elseif monthName == "Listopad" then return 11 elseif monthName == "Prosinec" then return 12 else return 1 end end end function monthNumberToName(monthNumber) if not monthNumber or not tonumber(monthNumber) then return "Leden" else monthNumber = tonumber(monthNumber) if monthNumber == 1 then return "Leden" elseif monthNumber == 2 then return "Únor" elseif monthNumber == 3 then return "Březen" elseif monthNumber == 4 then return "Duben" elseif monthNumber == 5 then return "Květen" elseif monthNumber == 6 then return "Červen" elseif monthNumber == 7 then return "Červenec" elseif monthNumber == 8 then return "Srpen" elseif monthNumber == 9 then return "Září" elseif monthNumber == 10 then return "Říjen" elseif monthNumber == 11 then return "Listopad" elseif monthNumber == 12 then return "Prosinec" else return "Leden" end end end function daysInMonth(month, year) if not month or not year or not tonumber(month) or not tonumber(year) then return 31 else month = tonumber(month) year = tonumber(year) end if month == 1 then return 31 elseif month == 2 then if isThisYearLeap(year) then return 29 else return 28 end elseif month == 3 then return 31 elseif month == 4 then return 30 elseif month == 5 then return 31 elseif month == 6 then return 30 elseif month == 7 then return 31 elseif month == 8 then return 31 elseif month == 9 then return 30 elseif month == 10 then return 31 elseif month == 11 then return 30 elseif month == 12 then return 31 else return 31 end end function getBirthday(age) if not age or not tonumber(age) then return 2015 else age = tonumber(age) end local time = getRealTime() time.year = time.year + 1900 return (time.year - age) end function getBetterDay(day) if not day or not tonumber(day) then return "1st" else day = tonumber(day) if day == 1 or day == 21 or day == 31 then return day.."st" elseif day == 2 or day == 22 then return day.."nd" elseif day == 3 or day == 23 then return day.."rd" else return day.."th" end end end local mysql = exports.mysql function newCharacter_create(characterName, characterDescription, race, gender, skin, height, weight, age, languageselected, month, day, location) if not (checkValidCharacterName(characterName)) then triggerClientEvent(client, "accounts:characters:new", client, 1, 1) -- State 1:1: error validating data return end if not (race > -1 and race < 3) then triggerClientEvent(client, "accounts:characters:new", client, 1, 2) -- State 1:2: error validating data return end if not (gender == 0 or gender == 1) then triggerClientEvent(client, "accounts:characters:new", client, 1, 3) -- State 1:3: error validating data return end if not skin then triggerClientEvent(client, "accounts:characters:new", client, 1, 4) -- State 1:4: error validating data return end if not (height < 201 and height > 149) then triggerClientEvent(client, "accounts:characters:new", client, 1, 5) -- State 1:5: error validating data return end if not (weight < 200 and weight > 49) then triggerClientEvent(client, "accounts:characters:new", client, 1, 6) -- State 1:6: error validating data return end if not (age > 15 and age < 101) then triggerClientEvent(client, "accounts:characters:new", client, 1, 7) -- State 1:7: error validating data return end if not tonumber(languageselected) then triggerClientEvent(client, "accounts:characters:new", client, 1, 8) -- State 1:8: error validating data return end characterName = string.gsub(tostring(characterName), " ", "_") --[[if #characterDescription < 50 or #characterDescription > 128 then triggerClientEvent(client, "accounts:characters:new", client, 1, 9) -- State 1:9: error validating data return end characterDescription = mysql:escape_string(characterDescription)]] local mQuery1 = mysql:query("SELECT charactername FROM characters WHERE charactername='" .. mysql:escape_string(characterName) .. "'") if (mysql:num_rows(mQuery1)>0) then mysql:free_result(mQuery1) triggerClientEvent(client, "accounts:characters:new", client, 2, 1) -- State 2:1: Name already in use return end mysql:free_result(mQuery1) local accountID = getElementData(client, "account:id") local accountUsername = getElementData(client, "account:username") local fingerprint = md5(mysql:escape_string(characterName) .. accountID .. race .. gender .. age) if month == "January" then month = 1 end local walkingstyle = 128 if gender == 1 then walkingstyle = 129 end local id = mysql:query_insert_free("INSERT INTO `characters` SET `charactername`='" .. mysql:escape_string(characterName).. "', `x`='"..location[1].."', `y`='"..location[2].."', `z`='"..location[3].."', `rotation`='"..location[4].."', `interior_id`='"..location[5].."', `dimension_id`='"..location[6].."', `lastarea`='"..exports.global:toSQL(location[7]).."', `gender`='" .. mysql:escape_string(gender) .. "', `skincolor`='" .. mysql:escape_string(race) .. "', `weight`='" .. mysql:escape_string(weight) .. "', `height`='" .. mysql:escape_string(height) .. "', `description`='', `account`='" .. mysql:escape_string(accountID) .. "', `skin`='" .. mysql:escape_string(skin) .. "', `age`='" .. mysql:escape_string(age) .. "', `fingerprint`='" .. mysql:escape_string(fingerprint) .. "', `lang1`='" .. mysql:escape_string(languageselected) .. "', `lang1skill`='100', `currLang`='1' , `month`='" .. mysql:escape_string(month or math.random(1,12)) .. "', `day`='" .. mysql:escape_string(day or math.random(1,27)).."', `walkingstyle`='" .. mysql:escape_string(walkingstyle).."' " ) if (id) then -- exports.logs:dbLog("ac"..tostring(accountID), 27, { "ac"..tostring(accountID), "ch" .. id } , "Created" ) exports.anticheat:changeProtectedElementDataEx(client, "dbid", id, false) exports.global:giveItem( client, 16, skin ) exports.global:giveItem( client, 17, 1 ) -- ID CARD exports.global:giveItem( client, 152, characterName..";"..(gender==0 and "Male" or "Female")..";"..exports.global:numberToMonth(month or 1).." "..exports.global:formatDate(day or 1)..", "..exports.global:getBirthYearFromAge(age)..";"..fingerprint) -- Briefcase if exports.global:giveItem( client, 160, 1 ) then triggerEvent("artifacts:toggle", client, client, "briefcase") end --Make a new phone and give it to player / maxime local attempts = 0 local itemValue = 1 while true do -- generate a larger phone number if we're totally out of numbers and/or too lazy to perform more than 20+ checks. attempts = attempts + 1 itemValue = math.random(311111, attempts < 20 and 899999 or 8999999) local mysqlQ = mysql:query("SELECT `phonenumber` FROM `phones` WHERE `phonenumber` = '" .. itemValue .. "'") if mysql:num_rows(mysqlQ) == 0 then mysql:free_result(mysqlQ) break end mysql:free_result(mysqlQ) end --exports.global:giveItem( client, 2, itemValue ) exports.anticheat:changeProtectedElementDataEx(client, "dbid") triggerClientEvent(client, "accounts:characters:new", client, 3, tonumber(id)) -- State 3:<var>: Spic win! else triggerClientEvent(client, "accounts:characters:new", client, 2, 2) -- State 2:2: Failed to update database end end addEventHandler("accounts:characters:new", getRootElement(), newCharacter_create) Link to comment
MarvelSK Posted April 8, 2020 Author Share Posted April 8, 2020 LOCK ... Moving to another forum cattegory. Link to comment
MarvelSK Posted April 8, 2020 Author Share Posted April 8, 2020 Or not ... Staying here .. please help Link to comment
Scripting Moderators thisdp Posted April 10, 2020 Scripting Moderators Share Posted April 10, 2020 use https://wiki.multitheftauto.com/wiki/OnDgsElementScroll instead, https://wiki.multitheftauto.com/wiki/onDgsScrollBarScrollPositionChange has already been removed for a long time btw, change "onClientGUIComboBoxAccepted" to https://wiki.multitheftauto.com/wiki/OnDgsComboBoxSelect Link to comment
MarvelSK Posted April 10, 2020 Author Share Posted April 10, 2020 8 hours ago, thisdp said: use https://wiki.multitheftauto.com/wiki/OnDgsElementScroll instead, https://wiki.multitheftauto.com/wiki/onDgsScrollBarScrollPositionChange has already been removed for a long time btw, change "onClientGUIComboBoxAccepted" to https://wiki.multitheftauto.com/wiki/OnDgsComboBoxSelect I have replaced "onClientGUIComboBoxAccepted" to https://wiki.multitheftauto.com/wiki/OnDgsComboBoxSelect but how to replace "dgsScrollBarGetScrollPosition" ? With what ? I did try OnGDgsElementScroll but it is not working... If I create character then Day of born and month are not set ( not working ) .... and when I am creating character then I can move with scrollbars ( they will upload new value ) but they will just set new value, but they don´t write it in dgs label Link to comment
Scripting Moderators thisdp Posted April 11, 2020 Scripting Moderators Share Posted April 11, 2020 19 hours ago, MarvelSK said: I have replaced "onClientGUIComboBoxAccepted" to https://wiki.multitheftauto.com/wiki/OnDgsComboBoxSelect but how to replace "dgsScrollBarGetScrollPosition" ? With what ? I did try OnGDgsElementScroll but it is not working... If I create character then Day of born and month are not set ( not working ) .... and when I am creating character then I can move with scrollbars ( they will upload new value ) but they will just set new value, but they don´t write it in dgs label did you updatedgs to the latest version? Link to comment
MarvelSK Posted April 11, 2020 Author Share Posted April 11, 2020 yes 3 hours ago, thisdp said: did you updatedgs to the latest version? yes 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