Jump to content

[Help] Walking Style Changing GUI


Recommended Posts

hello guys this is my first Gui project and i am pretty noob so can u please tell me whats wrong :)

local player = getLocalPlayer ()
GUIEditor = {
    gridlist = {},
    window = {},
    button = {},
    label = {}
}
   function Panel()
        name = guiCreateWindow(856, 143, 264, 388, "Walking Style", false)
        guiWindowSetSizable(name, false)

        local label = guiCreateLabel(6, 1, 254, 15, "", false, GUIEditor.window[1])
        GUIEditor.gridlist[1] = guiCreateGridList(28, 44, 209, 308, false, GUIEditor.window[1])

        local Default = guiCreateButton(10, 14, 189, 30, "Default", false, GUIEditor.gridlist[1])
        local Drunk = guiCreateButton(10, 54, 189, 30, "Drunk Man", false, GUIEditor.gridlist[1])
        local Sneak = guiCreateButton(10, 94, 189, 30, "Sneaking", false, GUIEditor.gridlist[1])
        local Blind = guiCreateButton(10, 134, 189, 30, "Blind Man", false, GUIEditor.gridlist[1])
        local Gangstar = guiCreateButton(10, 174, 189, 30, "Gangstar", false, GUIEditor.gridlist[1])
        local Sexy = guiCreateButton(10, 214, 189, 30, "Sexy", false, GUIEditor.gridlist[1])
        local fat =  guiCreateButton(10, 254, 189, 30, "Fat man", false, GUIEditor.gridlist[1])

        local Close = guiCreateButton(104, 357, 58, 17, "Done", false, GUIEditor.window[1])    
        showCursor ( true )
    end
addCommandHandler("ws", panel)
    function Reset() 
setPedWalkingStyle ( player, 0 )
end
function Drunk() 
setPedWalkingStyle ( player, 126 )
end
function Sneak() 
setPedWalkingStyle ( player, 69 )
end
function Blind() 
setPedWalkingStyle ( player, 127 )
end
function Gangstar() 
setPedWalkingStyle ( player, 121 )
end
function Sexy() 
setPedWalkingStyle ( player, 132 )
end
function Fat() 
setPedWalkingStyle ( player, 124 )
end
function Close()
guiSetVisible ( name, false )
showCursor ( false )
end

addEventHandler ( "onClientGUIClick", Default, Reset, false )
addEventHandler ( "onClientGUIClick", Drunk, Drunk, false )
addEventHandler ( "onClientGUIClick", Sneak, Sneak, false )
addEventHandler ( "onClientGUIClick", Blind, Blind, false )
addEventHandler ( "onClientGUIClick", Gangstar, Gangstar, false )
addEventHandler ( "onClientGUIClick", Sexy, Sexy, false )
addEventHandler ( "onClientGUIClick", Fat, Fat, false )
addEventHandler ( "onClientGUIClick", close, close, false )

Link to comment
local player = getLocalPlayer ()
GUIEditor = {
    gridlist = {},
    window = {},
    button = {},
    label = {}
}
   function Panel()
        name = guiCreateWindow(856, 143, 264, 388, "Walking Style", false)
        guiWindowSetSizable(name, false)

        local label = guiCreateLabel(6, 1, 254, 15, "", false, GUIEditor.window[1])
        GUIEditor.gridlist[1] = guiCreateGridList(28, 44, 209, 308, false, GUIEditor.window[1])

        local Default = guiCreateButton(10, 14, 189, 30, "Default", false, GUIEditor.gridlist[1])
        local Drunk = guiCreateButton(10, 54, 189, 30, "Drunk Man", false, GUIEditor.gridlist[1])
        local Sneak = guiCreateButton(10, 94, 189, 30, "Sneaking", false, GUIEditor.gridlist[1])
        local Blind = guiCreateButton(10, 134, 189, 30, "Blind Man", false, GUIEditor.gridlist[1])
        local Gangstar = guiCreateButton(10, 174, 189, 30, "Gangstar", false, GUIEditor.gridlist[1])
        local Sexy = guiCreateButton(10, 214, 189, 30, "Sexy", false, GUIEditor.gridlist[1])
        local fat =  guiCreateButton(10, 254, 189, 30, "Fat man", false, GUIEditor.gridlist[1])

        local Close = guiCreateButton(104, 357, 58, 17, "Done", false, GUIEditor.window[1])    
        showCursor ( true )
    end
addCommandHandler("ws", panel)
function Reset() 
    setPedWalkingStyle ( player, 0 )
end
function Drunk() 
    setPedWalkingStyle ( player, 126 )
end
function Sneak() 
    setPedWalkingStyle ( player, 69 )
end
function Blind() 
    setPedWalkingStyle ( player, 127 )
end
function Gangstar() 
    setPedWalkingStyle ( player, 121 )
end
function Sexy() 
    setPedWalkingStyle ( player, 132 )
end
function Fat() 
    setPedWalkingStyle ( player, 124 )
end
function Close()
    guiSetVisible ( name, false )
    showCursor ( false )
end

addEventHandler ( "onClientGUIClick", Default, Reset, false )
addEventHandler ( "onClientGUIClick", Drunk, Drunk, false )
addEventHandler ( "onClientGUIClick", Sneak, Sneak, false )
addEventHandler ( "onClientGUIClick", Blind, Blind, false )
addEventHandler ( "onClientGUIClick", Gangstar, Gangstar, false )
addEventHandler ( "onClientGUIClick", Sexy, Sexy, false )
addEventHandler ( "onClientGUIClick", Fat, Fat, false )
addEventHandler ( "onClientGUIClick", close, close, false )

What is you're problem? What happen when you write /ws     it open the Panel or not? you need to say what is happening with you so we can help.

Try this: 

walkStyles = {
            {"Default", 0 },
            {"Default Fat", 55 },
            {"Default Muscular", 56 },
            {"Sneak", 69 },
            {"Man", 118 },     
            {"Fat Man", 124 },     
            {"Jogger Man", 125 },
            {"Old Man", 120 },
            {"Old Fat Man", 123 },
            {"SWAT Moves", 128 },
            {"Gangster 1", 121 },
            {"Gangster 2", 122 },
            {"Pro Sexy Woman", 133 },
            {"Fat Woman", 135 },
            {"Jogger Woman", 136 },
            {"Old Woman", 134 },  
            {"Old Fat Woman", 137 },  
            {"Drinking", 126 },
            {"Shuffle", 119 },
            {"Blind Man", 127 } ,
            {"Woman", 129 },     
            {"Busy Woman", 131 },
            {"Sexy Woman", 132 },
}
GUIEditor = {
    gridlist = {},
    window = {},
    button = {},
    label = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        GUIEditor.window[1] = guiCreateWindow(352, 131, 513, 415, "", false)
        guiWindowSetSizable(GUIEditor.window[1], false)
        guiSetVisible(GUIEditor.window[1], false)
        GUIEditor.gridlist[1] = guiCreateGridList(10, 24, 296, 381, false, GUIEditor.window[1])
        guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.5)
        guiGridListAddColumn(GUIEditor.gridlist[1], "ID", 0.4)
        GUIEditor.label[1] = guiCreateLabel(0.61, 0.07, 0.36, 0.11, "Select a walking style from the gridlist and click have style or cancel.", true, GUIEditor.window[1])
        guiSetFont(GUIEditor.label[1], "clear-normal")
        guiLabelSetHorizontalAlign(GUIEditor.label[1], "left", true)
        GUIEditor.label[2] = guiCreateLabel(313, 98, 184, 142, "Many walk styles don't allow you to run fast so use those walking styles at your loss. Some walking style have special abilities too, so try them out.", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.label[2], "clear-normal")
        guiLabelSetHorizontalAlign(GUIEditor.label[2], "left", true)
        GUIEditor.button[1] = guiCreateButton(312, 368, 95, 37, "Have Style", false, GUIEditor.window[1])
        GUIEditor.button[2] = guiCreateButton(412, 369, 91, 36, "Cancel", false, GUIEditor.window[1])   
for ind,n in ipairs(walkStyles) do
        row = guiGridListAddRow(GUIEditor.gridlist[1])
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, n[1], false, false)
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 2, tostring(n[2]), false, false)
end        
    addEventHandler("onClientGUIClick", GUIEditor.button[1], select)
    addEventHandler("onClientGUIClick", GUIEditor.button[2], close)
    end
)

local marker1 = createMarker( 773.5, -1, 999.7, 'Cylinder', 1.5, 255, 0, 0, 170 )
local marker2 = createMarker( 665, -1864, 4.5, 'Cylinder', 1.5, 255, 0, 0, 170 )
setElementInterior(marker1, 5)
local marker3 = createMarker( 774, -71, 999.5, 'Cylinder', 1.5, 255, 0, 0, 170 )
setElementInterior(marker3, 7)

 function markerhit(hitElement)
            if getElementType(hitElement) == "player" and (hitElement == localPlayer) then
                  if not guiGetVisible(GUIEditor.window[1]) then
                       guiSetVisible(GUIEditor.window[1], true)
                       showCursor(true)
                  end
            end
     end

    function close()
        guiSetVisible(GUIEditor.window[1],false)
        showCursor(false)
    end
    function select()
        local row, col = guiGridListGetSelectedItem(GUIEditor.gridlist[1])  
            if (row and col and row ~= -1 and col ~= -1) then
            local models = tonumber(guiGridListGetItemText(GUIEditor.gridlist[1], row, 2))
                if model ~= "" then
                triggerServerEvent("walking", localPlayer, models)
                setPedWalkingStyle(localPlayer, models)
                guiSetVisible(GUIEditor.window[1],false)
                showCursor(false)
                end
            end
        end

addEventHandler("onClientMarkerHit", marker1, markerhit)
addEventHandler("onClientMarkerHit", marker2, markerhit)
addEventHandler("onClientMarkerHit", marker3, markerhit)

addCommandHandler( "walkstyle",
    function ()
        if ( guiGetVisible( GUIEditor.window[1] ) ) then
            guiSetVisible( GUIEditor.window[1], false )
            showCursor( false )
        else
            guiSetVisible( GUIEditor.window[1], true )
            showCursor( true )
        end
    end
)

 

Edited by SSKE
  • Haha 1
Link to comment

sorry about less explanation, my bad xD ,  i get no error, i mean nothing happens, the gui doesnt bother to show. I made the Gui panel using Gui editor script in the resources section.

and thank you @SSKE for the script but there are a lot of other walking style changing GUi's around but i want my gui to work , so hope fully i could know what went wrong :)

here is how it looks like https://pasteboard.co/HneLYd0.jpg

Edited by TheGrimReaper
Link to comment

GUIEditor = {
    gridlist = {},
    window = {},
    button = {},
    label = {}
}

addEventHandler("onClientResourceStart", resourceRoot,
	function ()
        name = guiCreateWindow(856, 143, 264, 388, "Walking Style", false)
        guiWindowSetSizable(name, false)

         label = guiCreateLabel(6, 1, 254, 15, "", false, GUIEditor.window[1])
        GUIEditor.gridlist[1] = guiCreateGridList(28, 44, 209, 308, false, GUIEditor.window[1])

         Default = guiCreateButton(10, 14, 189, 30, "Default", false, GUIEditor.gridlist[1])
         Drunk = guiCreateButton(10, 54, 189, 30, "Drunk Man", false, GUIEditor.gridlist[1])
         Sneak = guiCreateButton(10, 94, 189, 30, "Sneaking", false, GUIEditor.gridlist[1])
         Blind = guiCreateButton(10, 134, 189, 30, "Blind Man", false, GUIEditor.gridlist[1])
         Gangstar = guiCreateButton(10, 174, 189, 30, "Gangstar", false, GUIEditor.gridlist[1])
         Sexy = guiCreateButton(10, 214, 189, 30, "Sexy", false, GUIEditor.gridlist[1])
         fat =  guiCreateButton(10, 254, 189, 30, "Fat man", false, GUIEditor.gridlist[1])

         Close = guiCreateButton(104, 357, 58, 17, "Done", false, GUIEditor.window[1])
		
		guiSetVisible(name, false)
		
		addEventHandler ( "onClientGUIClick", guiRoot, setWalkingStyle )
	end
)

addCommandHandler("ws", function()
	guiSetVisible( name, true )
	showCursor( true )
end)

function setWalkingStyle()
	if source == Default then
		setPedWalkingStyle ( localPlayer, 0 )
	elseif source == Drunk then
		setPedWalkingStyle ( localPlayer, 126 )
	elseif source == Sneak then
		setPedWalkingStyle ( localPlayer, 69 )
	elseif source == Blind then
		setPedWalkingStyle ( localPlayer, 127 )
	elseif source == Gangstar then
		setPedWalkingStyle ( localPlayer, 121 )
	elseif source == Sexy then
		setPedWalkingStyle ( localPlayer, 132 )
	elseif source == fat then
		setPedWalkingStyle ( localPlayer, 124 )
	elseif source == Close then
		guiSetVisible( name, false )
		showCursor( false )
	end
end

Try it.

Link to comment

<script> 


GUIEditor = {
    gridlist = {},
    window = {},
    button = {},
    label = {}
}

addEventHandler("onClientResourceStart", resourceRoot,
    function ()
        GUIEditor.window[1] = guiCreateWindow(856, 143, 264, 388, "Walking Style", false)
        guiWindowSetSizable(name, false)

         label = guiCreateLabel(6, 1, 254, 15, "", false, GUIEditor.window[1])
        GUIEditor.gridlist[1] = guiCreateGridList(28, 44, 209, 308, false, GUIEditor.window[1])

         Default = guiCreateButton(10, 14, 189, 30, "Default", false, GUIEditor.gridlist[1])
         Drunk = guiCreateButton(10, 54, 189, 30, "Drunk Man", false, GUIEditor.gridlist[1])
         Sneak = guiCreateButton(10, 94, 189, 30, "Sneaking", false, GUIEditor.gridlist[1])
         Blind = guiCreateButton(10, 134, 189, 30, "Blind Man", false, GUIEditor.gridlist[1])
         Gangstar = guiCreateButton(10, 174, 189, 30, "Gangstar", false, GUIEditor.gridlist[1])
         Sexy = guiCreateButton(10, 214, 189, 30, "Sexy", false, GUIEditor.gridlist[1])
         fat =  guiCreateButton(10, 254, 189, 30, "Fat man", false, GUIEditor.gridlist[1])

         Close = guiCreateButton(104, 357, 58, 17, "Done", false, GUIEditor.window[1])
        
        guiSetVisible(GUIEditor.window[1], false)
        guiSetVisible(Default, false)
        guiSetVisible(Drunk, false)
        guiSetVisible(Sneak, false)
        guiSetVisible(Blind, false)
        guiSetVisible(Gangstar, false)
        guiSetVisible(Sexy, false)
        guiSetVisible(fat, false)
        guiSetVisible(Close, false)
        guiSetVisible(GUIEditor.gridlist[1], false)
        
        addEventHandler ( "onClientGUIClick", guiRoot, setWalkingStyle )
    end
)

addCommandHandler("ws", function()
    guiSetVisible( GUIEditor.window[1], true )
    guiSetVisible(Default, true)
    guiSetVisible(Drunk, true)
    guiSetVisible(Sneak, true)
    guiSetVisible(Blind, true)
    guiSetVisible(Gangstar, true)
    guiSetVisible(Sexy, true)
    guiSetVisible(fat, true)
    guiSetVisible(Close, true)
    guiSetVisible(GUIEditor.gridlist[1], true)
        
    showCursor( true )
end)

function setWalkingStyle()
    if source == Default then
        setPedWalkingStyle ( localPlayer, 0 )
    elseif source == Drunk then
        setPedWalkingStyle ( localPlayer, 126 )
    elseif source == Sneak then
        setPedWalkingStyle ( localPlayer, 69 )
    elseif source == Blind then
        setPedWalkingStyle ( localPlayer, 127 )
    elseif source == Gangstar then
        setPedWalkingStyle ( localPlayer, 121 )
    elseif source == Sexy then
        setPedWalkingStyle ( localPlayer, 132 )
    elseif source == fat then
        setPedWalkingStyle ( localPlayer, 124 )
    elseif source == Close then
        guiSetVisible( GUIEditor.window[1], false )
        guiSetVisible(Default, false)
        guiSetVisible(Drunk, false)
        guiSetVisible(Sneak, false)
        guiSetVisible(Blind, false)
        guiSetVisible(Gangstar, false)
        guiSetVisible(Sexy, false)
        guiSetVisible(fat, false)
        guiSetVisible(Close, false)
        guiSetVisible(GUIEditor.gridlist[1], false)    
        showCursor( false )
    end
end

</script>

finally done <3 thanks all for ur help

and yes i know there is a nunch of useless things in there i was just too lazy to remove it xD

Link to comment

You don't have to hide each GUI element, just use the parent element. The parent elements, in this case, are the window and the gridList.

guiSetVisible( GUIEditor.window[1], bool )
guiSetVisible(GUIEditor.gridlist[1], bool)

That is enough.

Edit: Hide only the window, gridList is the window's child. But the problem was the window's variable 'name' that wasn't being used on the other elements, instead it was 'GUIEditor.window [1]'. And in your last code, replace 'name' with GUIEditor.window[1] in guiWindowSetSizable.

Edited by DNL291
  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...