-.Paradox.- Posted September 12, 2013 Share Posted September 12, 2013 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 Link to comment
Blaawee Posted September 13, 2013 Share Posted September 13, 2013 (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 September 15, 2013 by Guest Link to comment
-.Paradox.- Posted September 14, 2013 Author Share Posted September 14, 2013 Not working Link to comment
Castillo Posted September 14, 2013 Share Posted September 14, 2013 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. Link to comment
Blaawee Posted September 15, 2013 Share Posted September 15, 2013 @SolidSnake At line 31, should be if ( index [ player ] == 1 ) then @StevyDK Try again i edit it. Link to comment
Castillo Posted September 15, 2013 Share Posted September 15, 2013 Yeah, I forgot about that one. Link to comment
-.Paradox.- Posted September 15, 2013 Author Share Posted September 15, 2013 @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 Link to comment
Castillo Posted September 15, 2013 Share Posted September 15, 2013 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. Link to comment
-.Paradox.- Posted September 15, 2013 Author Share Posted September 15, 2013 Can you fix it please? Link to comment
Castillo Posted September 15, 2013 Share Posted September 15, 2013 Fix what? I already fixed the timers problem, just copy my code again. Link to comment
-.Paradox.- Posted September 15, 2013 Author Share Posted September 15, 2013 Okay gonna try i didn't saw that. Working thanks Link to comment
-.Paradox.- Posted September 15, 2013 Author Share Posted September 15, 2013 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 ) Link to comment
-.Paradox.- Posted September 15, 2013 Author Share Posted September 15, 2013 Oh nothing i fixed it sorry for that was a small bug. Link to comment
-.Paradox.- Posted March 14, 2014 Author Share Posted March 14, 2014 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 ) Link to comment
Moderators Citizen Posted March 15, 2014 Moderators Share Posted March 15, 2014 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 Link to comment
-.Paradox.- Posted March 15, 2014 Author Share Posted March 15, 2014 Do you mean that there is another resource make the player respawn two times instead of one? I can't understand Link to comment
Moderators Citizen Posted March 15, 2014 Moderators Share Posted March 15, 2014 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). Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 Sorry, but i didn't understand what you meant Link to comment
Saml1er Posted March 30, 2014 Share Posted March 30, 2014 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. Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 It's the only resource that Spawn Player after his death (i mean i'm using only this script, not play gamemode) 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