Jump to content

Skins Simple Problem


NextGenRP

Recommended Posts

Hey guys, I've created some GUI buttons so a player can select their skin but the problem is i have done it like this:

When they press the "Back Skin" button it does it like this:

  
setElementModel(getLocalPlayer(),skin -1) 
  

And the same with "Next Skin", But when the skin gets to 2 it stops changing the skins, I think its because there is no skin 3 so how can i "skip" the ones that are not there?

Link to comment

I just can't get my head around this man,

  
  
function onSkinbackBtun(button) 
    if(button == "left") then 
        if(source == backSkinButton) then 
        local skin = getElementModel(getLocalPlayer()) 
        if(skin ~= 0) then 
        local allskins = getValidPedModels ( ) 
        for key, newskin in ipairs( allSkins ) do 
        if newskin == tonumber( skin -1 ) then 
        setElementModel(getLocalPlayer(),skin -1) 
        guiSetText(skinIDLabel,"ID: "..getElementModel(getLocalPlayer())) 
else 
outputChatBox("You can't go back any more!", 255,255,0) 
end 
playSoundFrontEnd ( 32 ) 
            end 
        end 
end 
end         
end 
  

But how do i make it if the skin is not valid to set it to the next available skin?

Link to comment

Try this:

local skin = 0 
  
function onSkinbackBtun ( button ) 
    if ( button == "left" ) then 
        if ( source == backSkinButton ) then 
            local allSkins = getValidPedModels ( ) 
            skin = skin - 1 
            if ( allSkins [ skin ] ) then 
                setElementModel ( localPlayer, allSkins [ skin ] ) 
                guiSetText ( skinIDLabel,"ID: ".. getElementModel ( localPlayer ) ) 
            else 
                outputChatBox("You can't go back any more!", 255,255,0) 
            end 
            playSoundFrontEnd ( 32 ) 
        end 
    end        
end 

Link to comment

So i still need to set it server side? Also (didn't want to start a new thread) if im doing this:

  
triggerServerEvent("createNewChar", getLocalPlayer(), firstname, lastname, age, descript, weight, muscle) 
  

How do i start the server function?

  
function createChar(firstname, lastname, age, descript, weight, muscle) 
  

Like that or this:

  
function createChar(source, firstname, lastname, age, descript, weight, muscle) 
  

Don't worry about telling me about the events and stuff i got that covered (I think) ;)

Link to comment

Thanks guys :D can you see where the error is here:

  
closeWindowbut = guiCreateButton(168,368,114,34,"Close",false,jobWindow) 
  
addEventHandler("onClientGUIClick", closeWindowbut, closeWindow, false) 
  
function closeWindow(button) 
if button == "left" then 
if source == closeWindowbut then 
guiSetVisible(jobWindow, false) 
showCursor(false) 
end 
end 
end 
  

It doesn't seem to do anything when i click the button.

Link to comment

You're adding the event before creating the function.

closeWindowbut = guiCreateButton(168,368,114,34,"Close",false,jobWindow) 
   
function closeWindow ( button ) 
    if ( button == "left" ) then 
        if ( source == closeWindowbut) then 
            guiSetVisible(jobWindow, false) 
            showCursor(false) 
        end 
    end 
end 
addEventHandler ( "onClientGUIClick", closeWindowbut, closeWindow, false ) 

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...