Jump to content

Skins Simple Problem


NextGenRP

Recommended Posts

Posted

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?

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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?

Posted

getValidPedModels returns a table, so you can do this:

getValidPedModels ( ) [ 1 ] -- Returns 0 
getValidPedModels ( ) [ 2 ] -- Returns 1 
getValidPedModels ( ) [ 3 ] -- Returns 2 

If you get what I mean.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

This this sync only for localPlayer ..

You should trigger to server and use setElementModel.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

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) ;)

Posted

Remove "source" from the function name.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

Posted

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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