Jump to content

Skin selector


-.Paradox.-

Recommended Posts

Posted

Hello i found a skin selector script in community, and i want player select only betwen 4 skins 171, 172, 133, 149 Thanks for help.

function Selection(player) 
showCursor(player, true) 
bindKey(player,"rshift","down",Spawn) 
bindKey(player,"arrow_l","down",SwitchSkin) 
bindKey(player,"arrow_r","down",SwitchSkin) 
fadeCamera ( player, true ) 
end 
  
function Selection2(player) 
if(not isPedDead(player) == true) then 
outputChatBox(" ", player, 0, 255, 0) 
outputChatBox("You'll choose your skin again.", player, 0, 138, 138) 
outputChatBox("Press Arrow keys to switch skins and Right shift to spawn!", player, 0, 138, 138) 
killPed(player, player) 
end 
setTimer(Selection,1000,2,player) 
end 
  
function SwitchSkin( player, key ) 
local skin 
skin = getElementModel(player) 
if(key == "arrow_l" and skin ~= 0) then 
setElementModel(player,skin - 1) 
else 
setElementModel(player,skin + 1) 
end 
playSoundFrontEnd (player, 32 ) 
end 
  
function Spawn( player ) 
showCursor(player, false) 
playSoundFrontEnd (player, 44) 
outputChatBox("Done!", player, 0, 255, 138) 
unbindKey ( player, "rshift", "down", Spawn ) 
unbindKey ( player, "arrow_l", "down", SwitchSkin ) 
unbindKey ( player, "arrow_r", "down", SwitchSkin ) 
setCameraMode ( player, "player" ) 
end 
  
function GamemodeStart( res ) 
players = getElementsByType ( "player") 
for k,v in ipairs(players) do 
bindKey(v,"F4","down",Selection2) 
outputChatBox("< Press Arrow keys to switch skins and Right shift to spawn. >", v, 255, 138, 0) 
setTimer(SpawnPlayer,1000,2,v) 
setTimer(Selection,1000,2,v) 
fadeCamera ( v, true ) 
end 
end 
  
function GamemodeEnd( res ) 
players = getElementsByType ( "player") 
for k,v in ipairs(players) do 
unbindKey(v,"F4","down",Selection2) 
end 
end 
  
function PlayerDeath() 
setTimer(SpawnPlayer,1000,2,source) 
end 
  
function SpawnPlayer(source) 
spawnPlayer(source, -2026.5035, 156.7506, 29.0391, 269.1424, 167) 
end 
  
function PlayerJoin() 
bindKey(source,"F4","down",Selection2) 
outputChatBox("< Press Arrow Keys to switch skins and Right shift to spawn. >", source, 255, 255, 0) 
setTimer(SpawnPlayer,1000,2,source) 
fadeCamera (source, true ) 
setTimer(Selection,1500,2,source) 
end 
  
addEventHandler("onResourceStart", getRootElement(),GamemodeStart) 
addEventHandler("onResourceStop", getRootElement(),GamemodeEnd) 
addEventHandler("onPlayerJoin", getRootElement(),PlayerJoin) 
  

I will run a Zombie server Resident evil mod and i want player choose btw Leon and Alice and Claire And Chris

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted (edited)
local mySkins =  
{ 
    [ 1 ] = { ID = 171 }, 
    [ 2 ] = { ID = 172 }, 
    [ 3 ] = { ID = 133 }, 
    [ 4 ] = { ID = 149 } 
}; 
local i = 1 
  
-- 
  
function Selection( player ) 
showCursor(player, true) 
bindKey(player,"rshift","down",Spawn) 
bindKey(player,"arrow_l","down",SwitchSkin) 
bindKey(player,"arrow_r","down",SwitchSkin) 
fadeCamera ( player, true ) 
end 
  
function Selection2(player) 
if(not isPedDead(player) == true) then 
outputChatBox(" ", player, 0, 255, 0) 
outputChatBox("You'll choose your skin again.", player, 0, 138, 138) 
outputChatBox("Press Arrow keys to switch skins and Right shift to spawn!", player, 0, 138, 138) 
killPed(player, player) 
end 
setTimer(Selection,1000,2,player) 
end 
  
-- 
function SwitchSkin( player, key ) 
    if( key == "arrow_l" ) then 
        if ( i == 1 ) then 
            i = #mySkins 
        else 
            i = i - 1; 
        end 
    else 
        if ( i == #mySkins ) then 
            i = 1; 
        else 
            i = i + 1; 
        end 
    end 
    setElementModel( player, mySkins[ i ].ID ); 
    playSoundFrontEnd ( player, 32 ); 
end 
-- 
  
function Spawn( player ) 
showCursor(player, false) 
playSoundFrontEnd (player, 44) 
outputChatBox("Done!", player, 0, 255, 138) 
unbindKey ( player, "rshift", "down", Spawn ) 
unbindKey ( player, "arrow_l", "down", SwitchSkin ) 
unbindKey ( player, "arrow_r", "down", SwitchSkin ) 
setCameraMode ( player, "player" ) 
end 
  
function GamemodeStart( res ) 
players = getElementsByType ( "player") 
for k,v in ipairs(players) do 
bindKey(v,"F4","down",Selection2) 
outputChatBox("< Press Arrow keys to switch skins and Right shift to spawn. >", v, 255, 138, 0) 
setTimer(SpawnPlayer,1000,2,v) 
setTimer(Selection,1000,2,v) 
fadeCamera ( v, true ) 
end 
end 
  
function GamemodeEnd( res ) 
players = getElementsByType ( "player") 
for k,v in ipairs(players) do 
unbindKey(v,"F4","down",Selection2) 
end 
end 
  
function PlayerDeath() 
setTimer(SpawnPlayer,1000,2,source) 
end 
  
function SpawnPlayer(source) 
spawnPlayer(source, -2026.5035, 156.7506, 29.0391, 269.1424, 167) 
end 
  
function PlayerJoin() 
bindKey(source,"F4","down",Selection2) 
outputChatBox("< Press Arrow Keys to switch skins and Right shift to spawn. >", source, 255, 255, 0) 
setTimer(SpawnPlayer,1000,2,source) 
fadeCamera (source, true ) 
setTimer(Selection,1500,2,source) 
end 
  
addEventHandler("onResourceStart", getRootElement(),GamemodeStart) 
addEventHandler("onResourceStop", getRootElement(),GamemodeEnd) 
addEventHandler("onPlayerJoin", getRootElement(),PlayerJoin) 

Edited by Guest
Posted
local mySkins = 
    { 
        171, 
        172, 
        133, 
        149 
    } 
local index = { } 
  
function Selection ( player ) 
    showCursor ( player, true ) 
    bindKey ( player, "rshift", "down", Spawn ) 
    bindKey ( player, "arrow_l", "down", SwitchSkin ) 
    bindKey ( player, "arrow_r", "down", SwitchSkin ) 
    fadeCamera ( player, true ) 
    index [ player ] = 1 
end 
  
function Selection2 ( player ) 
    if ( not isPedDead ( player ) ) then 
        outputChatBox ( " ", player, 0, 255, 0 ) 
        outputChatBox ( "You'll choose your skin again.", player, 0, 138, 138 ) 
        outputChatBox ( "Press Arrow keys to switch skins and Right shift to spawn!", player, 0, 138, 138 ) 
        killPed ( player, player ) 
    end 
    setTimer ( Selection, 1000, 1, player ) 
end 
  
function SwitchSkin ( player, key ) 
    if ( key == "arrow_l" ) then 
        if ( index [ player ] == 1 ) then 
            index [ player ] = #mySkins 
        else 
            index [ player ] = ( index [ player ] - 1 ) 
        end 
    else 
        if ( index [ player ] == #mySkins ) then 
            index [ player ] = 1 
        else 
            index [ player ] = ( index [ player ] + 1 ) 
        end 
    end 
    outputChatBox ( index [ player ] ) 
    setElementModel ( player, mySkins [ index [ player ] ] ) 
    playSoundFrontEnd ( player, 32 ) 
end 
  
function Spawn ( player ) 
    showCursor ( player, false ) 
    playSoundFrontEnd ( player, 44 ) 
    outputChatBox("Done!", player, 0, 255, 138) 
    unbindKey ( player, "rshift", "down", Spawn ) 
    unbindKey ( player, "arrow_l", "down", SwitchSkin ) 
    unbindKey ( player, "arrow_r", "down", SwitchSkin ) 
    setCameraTarget ( player, player ) 
end 
  
function GamemodeStart ( res ) 
    local players = getElementsByType ( "player" ) 
    for _, v in ipairs ( players ) do 
        bindKey ( v, "F4", "down", Selection2 ) 
        outputChatBox ( "< Press Arrow keys to switch skins and Right shift to spawn. >", v, 255, 138, 0 ) 
        setTimer ( SpawnPlayer, 1000, 1, v ) 
        setTimer ( Selection, 1000, 1, v ) 
        fadeCamera ( v, true ) 
    end 
end 
  
function GamemodeEnd ( res ) 
    local players = getElementsByType ( "player") 
    for _, v in ipairs ( players ) do 
        unbindKey ( v, "F4", "down", Selection2 ) 
    end 
end 
  
function PlayerDeath ( ) 
    setTimer ( SpawnPlayer, 1000, 1, source ) 
end 
  
function SpawnPlayer ( source ) 
    spawnPlayer ( source, -2026.5035, 156.7506, 29.0391, 269.1424, 167 ) 
end 
  
function PlayerJoin ( ) 
    bindKey ( source, "F4", "down", Selection2 ) 
    outputChatBox ( "< Press Arrow Keys to switch skins and Right shift to spawn. >", source, 255, 255, 0 ) 
    setTimer ( SpawnPlayer, 1000, 1, source ) 
    fadeCamera (source, true ) 
    setTimer ( Selection, 1500, 1, source ) 
end 
  
addEventHandler ( "onResourceStart", resourceRoot, GamemodeStart ) 
addEventHandler ( "onResourceStop", resourceRoot, GamemodeEnd ) 
addEventHandler ( "onPlayerJoin", getRootElement(), PlayerJoin ) 

Try that.

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

Yeah, I forgot about that one.

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

@Blaawee i tried the last one but that let me chose betwen 171 and 133

@Solidsnake same bug I can selecto only 171 and 133

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Found your problem, you were binding the keys twice, you put the timers to repeat two times instead of just one.

P.S: The skin 149 is not valid.

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

Can you fix it please?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Fix what? I already fixed the timers problem, just copy my code again.

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

Okay gonna try i didn't saw that.

Working thanks

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Got another problem when player die he spawn with 172 skin Idk how to fix that

here is the code

local mySkins = 
    { 
        284, 
        40, 
        18, 
        172, 
    } 
local index = { } 
  
function Selection ( player ) 
    showCursor ( player, true ) 
    bindKey ( player, "rshift", "down", Spawn ) 
    bindKey ( player, "arrow_l", "down", SwitchSkin ) 
    bindKey ( player, "arrow_r", "down", SwitchSkin ) 
    fadeCamera ( player, true ) 
    index [ player ] = 1 
end 
  
function Selection2 ( player ) 
    if ( not isPedDead ( player ) ) then 
        outputChatBox ( " ", player, 0, 255, 0 ) 
        outputChatBox ( "You'll choose your skin again.", player, 0, 138, 138 ) 
        outputChatBox ( "Press Arrow keys to switch skins and Right shift to spawn!", player, 0, 138, 138 ) 
        killPed ( player, player ) 
    end 
    setTimer ( Selection, 1000, 1, player ) 
end 
  
function SwitchSkin ( player, key ) 
    if ( key == "arrow_l" ) then 
        if ( index [ player ] == 1 ) then 
            index [ player ] = #mySkins 
        else 
            index [ player ] = ( index [ player ] - 1 ) 
        end 
    else 
        if ( index [ player ] == #mySkins ) then 
            index [ player ] = 1 
        else 
            index [ player ] = ( index [ player ] + 1 ) 
        end 
    end 
    outputChatBox ( index [ player ] ) 
    setElementModel ( player, mySkins [ index [ player ] ] ) 
    playSoundFrontEnd ( player, 32 ) 
end 
  
function Spawn ( player ) 
    showCursor ( player, false ) 
    playSoundFrontEnd ( player, 44 ) 
    outputChatBox("Done!", player, 0, 255, 138) 
    unbindKey ( player, "rshift", "down", Spawn ) 
    unbindKey ( player, "arrow_l", "down", SwitchSkin ) 
    unbindKey ( player, "arrow_r", "down", SwitchSkin ) 
    setCameraTarget ( player, player ) 
end 
  
function GamemodeStart ( res ) 
    local players = getElementsByType ( "player" ) 
    for _, v in ipairs ( players ) do 
        bindKey ( v, "F4", "down", Selection2 ) 
        outputChatBox ( "< Press Arrow keys to switch skins and Right shift to spawn. >", v, 255, 138, 0 ) 
        setTimer ( SpawnPlayer, 1000, 1, v ) 
        setTimer ( Selection, 1000, 1, v ) 
        fadeCamera ( v, true ) 
    end 
end 
  
function GamemodeEnd ( res ) 
    local players = getElementsByType ( "player") 
    for _, v in ipairs ( players ) do 
        unbindKey ( v, "F4", "down", Selection2 ) 
    end 
end 
  
function PlayerDeath ( ) 
    setTimer ( SpawnPlayer, 1000, 1, source ) 
end 
  
function SpawnPlayer ( source ) 
    spawnPlayer ( source, -1643.89941, 652.95648, -4.90625, 269.1424, 172 ) 
  
end 
  
function PlayerJoin ( ) 
    bindKey ( source, "F4", "down", Selection2 ) 
    outputChatBox ( "< Press Arrow Keys to switch skins and Right shift to spawn. >", source, 255, 255, 0 ) 
    setTimer ( SpawnPlayer, 1000, 1, source ) 
    fadeCamera (source, true ) 
    setTimer ( Selection, 1500, 1, source ) 
end 
  
addEventHandler("onPlayerWasted", getRootElement(),PlayerDeath) 
addEventHandler ( "onResourceStart", resourceRoot, GamemodeStart ) 
addEventHandler ( "onResourceStop", resourceRoot, GamemodeEnd ) 
addEventHandler ( "onPlayerJoin", getRootElement(), PlayerJoin ) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Oh nothing i fixed it sorry for that was a small bug. :)

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

  • 5 months later...
Posted

I just noticed that there is one problem, when i die i want to save my weapons (i'm using you're script for saving weapons when die) but the first time i die i can see my weapons but after 1 or 2 seconds i respawn again without my weapons, thanks for help.

local playerWeapons = { } 
  
addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        if ( not playerWeapons [ source ] ) then 
            playerWeapons [ source ] = { } 
        end 
        for slot = 0, 12 do 
            local weapon = getPedWeapon ( source, slot ) 
            if ( weapon > 0 ) then 
                local ammo = getPedTotalAmmo ( source, slot ) 
                if ( ammo > 0 ) then 
                    playerWeapons [ source ] [ weapon ] = ammo 
                end 
            end 
        end 
    end 
) 
  
addEventHandler ( "onPlayerSpawn", root, 
    function ( ) 
        if ( playerWeapons [ source ] ) then 
            for weapon, ammo in pairs ( playerWeapons [ source ] ) do 
                giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) 
            end 
        end 
  
        playerWeapons [ source ] = nil 
    end 
) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

  • Moderators
Posted
I just noticed that there is one problem, when i die i want to save my weapons (i'm using you're script for saving weapons when die) but the first time i die i can see my weapons but after 1 or 2 seconds i respawn again without my weapons, thanks for help.
local playerWeapons = { } 
  
addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        if ( not playerWeapons [ source ] ) then 
            playerWeapons [ source ] = { } 
        end 
        for slot = 0, 12 do 
            local weapon = getPedWeapon ( source, slot ) 
            if ( weapon > 0 ) then 
                local ammo = getPedTotalAmmo ( source, slot ) 
                if ( ammo > 0 ) then 
                    playerWeapons [ source ] [ weapon ] = ammo 
                end 
            end 
        end 
    end 
) 
  
addEventHandler ( "onPlayerSpawn", root, 
    function ( ) 
        if ( playerWeapons [ source ] ) then 
            for weapon, ammo in pairs ( playerWeapons [ source ] ) do 
                giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) 
            end 
        end 
  
        playerWeapons [ source ] = nil 
    end 
) 

So when you die, you are respawning twice right ?

If yes then you have to find out which resources or parts of your resource that uses spawnPlayer function with a timer in a onPlayerWasted event

The rEvolution is coming ...

Posted

Do you mean that there is another resource make the player respawn two times instead of one? I can't understand

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

  • Moderators
Posted
Do you mean that there is another resource make the player respawn two times instead of one? I can't understand

No I meant there are 2 resources that are respawning the player after his death.

So there is your script which does that:

function PlayerDeath ( ) 
    setTimer ( SpawnPlayer, 1000, 1, source ) 
end 
  
function SpawnPlayer ( source ) 
    spawnPlayer ( source, -1643.89941, 652.95648, -4.90625, 269.1424, 172 ) 
end 

but there is another resource (or another part of your script) which respawn dead players too.

So you have to find which resource does that (by stopping resources 1 by 1 untill the problem disapear).

The rEvolution is coming ...

  • 2 weeks later...
Posted

Sorry, but i didn't understand what you meant

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
Sorry, but i didn't understand what you meant

Suppose you have 2 resources named R1 and R2. R1 contains a script that spawns a player when he dies and R2 has the same script so the player is being spawned by 2 resources when he dies, thats what he meant.

Posted

It's the only resource that Spawn Player after his death (i mean i'm using only this script, not play gamemode)

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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