Jump to content

Gamemode Help


Recommended Posts

I have This game-mode that spawns you with a random skin and re-spawns you with the cj skin, is there any way to make

it spawn with the skin you last had?, here are the spawn and re-spawn scripts:

respawn:

local uTimers = { } 
  
local hospitalSpawns = 
{ 
    { 2027.77, -1420.52, 17.1, }, 
    { 1180.85, -1325.57, 14.0, }, 
    { 1244.437, 331.2261, 20.0, }, 
    { -2199.719, -2308.075, 31.0, }, 
    { -2670.285, 616.4364, 14.6, }, 
    { -316.3832, 1056.045, 20.0, }, 
    { -1514.823, 2527.119, 56.0, }, 
    { 1578.446, 1770.682, 11.0, } 
} 
  
function respawn( player, skin ) 
    if not isElement( player ) then 
        return 
    end 
    local myX, myY, myZ = getElementPosition( player ) 
    local mySp, myDis   = 1, 99999 
    for i, sp in ipairs( hospitalSpawns ) do 
        local dis = getDistanceBetweenPoints3D( sp[ 1 ], sp[ 2 ], sp[ 3 ], myX, myY, myZ ) 
        if dis < myDis then 
            myDis = dis 
            mySp  = i 
        end 
    end 
    repeat until spawnPlayer ( player, hospitalSpawns[ mySp ][ 1 ], hospitalSpawns[ mySp ][ 2 ], hospitalSpawns[ mySp ][ 3 ] ) 
    fadeCamera( player, true ) 
    setCameraTarget( player, player ) 
    showChat( player, true ) 
end 
  
addEventHandler( "onPlayerWasted", root,     
    function( ) 
        uTimers[ source ] = setTimer( respawn,1000,1,source,getElementModel( source ) ) 
    end 
)   
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        uTimers[ source ] = nil 
    end 
)   
    
addEventHandler( "onResourceStart", resourceRoot, 
    function( ) 
        resetMapInfo( ) 
        for i,player in pairs( getElementsByType 'player' ) do 
            respawn( player ) 
        end 
    end 
) 
  
--End Of script, Adding More Later. 
--Tarek632 

spawn script:

function objectsLoad () 
--SF_CrackFactory 
removeWorldModel(11088, 1000, -2185.49, -215.55, 34.31) 
removeWorldModel(11282, 1000, -2185.49, -215.55, 34.31) 
createObject ( 11085, -2164.44921875, -237.619140625, 41.4, 0, 0, 0 ) 
createObject ( 11086, -2164.5, -237.6, 43.4, 0, 0, 0 ) 
--samolet 
createObject ( 14553, 0, 0, 2000, 0, 0, 0 ) 
createObject ( 14548, 0, 3.6500000953674, 1999.7299804688, 0, 0, 0 ) 
--Particles & FX 
end 
addEventHandler ( "onResourceStart", getRootElement(), objectsLoad ) 
  
    function spawn(player) 
        if not isElement(player) then return end 
        repeat until spawnPlayer ( player, 0.0+math.random(-1,1), -5.0+math.random(-6,0), 2002.0+math.random(0,1), 0.0, math.random(312), 0, 0) 
        fadeCamera(player, true) 
        setCameraTarget(player, player) 
        showChat(player, true) 
    end 
     
        addEventHandler("onPlayerJoin", root, 
        function() 
            spawn(source) 
        end 
    ) 
     
    function isValidSkin( thePlayer, command, specifiedSkin )  -- Define the function 
    if ( 0 ) then -- If skin specified 
        allSkins = getValidPedModels ( ) -- Get valid skin IDs 
        result = true -- Define result, it is currently false 
        for key, skin in ipairs( allSkins ) do -- Check all skins 
            if skin == tonumber( specifiedSkin ) then -- If skin equals specified one, it is valid 
                result = skin -- So set it as result 
                break --stop looping through a table after we found the skin 
            end 
        end 
        if ( result ) then -- If we got results 
            outputChatBox( tostring( skin ) .. " is a valid skin ID.", thePlayer, 0, 255, 0 ) -- It is valid, output it 
        else -- If we didn't get results 
            outputChatBox( specifiedSkin .. " is not a valid skin ID.", thePlayer, 0, 255, 0 ) -- No result, it is not valid 
        end 
    else -- If no skin specified 
        outputChatBox( "Please specify a skin ID to check!", thePlayer, 255, 0, 0 ) -- Tell it to the player 
    end 
end 
addCommandHandler("checkskin",isValidSkin) -- bind 'checkskin' command to 'isValidSkin' function 

Link to comment
    local uTimers = { } 
      
    local hospitalSpawns = 
    { 
        { 2027.77, -1420.52, 17.1, }, 
        { 1180.85, -1325.57, 14.0, }, 
        { 1244.437, 331.2261, 20.0, }, 
        { -2199.719, -2308.075, 31.0, }, 
        { -2670.285, 616.4364, 14.6, }, 
        { -316.3832, 1056.045, 20.0, }, 
        { -1514.823, 2527.119, 56.0, }, 
        { 1578.446, 1770.682, 11.0, } 
    } 
      
    function respawn( player, skin ) 
        if not isElement( player ) then 
            return 
        end 
        local myX, myY, myZ = getElementPosition( player ) 
        local mySp, myDis   = 1, 99999 
        for i, sp in ipairs( hospitalSpawns ) do 
            local dis = getDistanceBetweenPoints3D( sp[ 1 ], sp[ 2 ], sp[ 3 ], myX, myY, myZ ) 
            if dis < myDis then 
                myDis = dis 
                mySp  = i 
            end 
        end 
        repeat until spawnPlayer ( player, hospitalSpawns[ mySp ][ 1 ], hospitalSpawns[ mySp ][ 2 ], hospitalSpawns[ mySp ][ 3 ], 0, skin ) 
        fadeCamera( player, true ) 
        setCameraTarget( player, player ) 
        showChat( player, true ) 
    end 
      
    addEventHandler( "onPlayerWasted", root,     
        function( ) 
            uTimers[ source ] = setTimer( respawn,1000,1,source,getElementModel( source ) ) 
        end 
    )   
      
    addEventHandler( 'onPlayerQuit',root, 
        function( ) 
            uTimers[ source ] = nil 
        end 
    )   
        
    addEventHandler( "onResourceStart", resourceRoot, 
        function( ) 
            resetMapInfo( ) 
            for i,player in pairs( getElementsByType 'player' ) do 
                respawn( player ) 
            end 
        end 
    ) 
      
    --End Of script, Adding More Later. 
    --Tarek632 

Line 28, there was a missing "skin" argument that's why you get CJ's skin

Link to comment
    local uTimers = { } 
      
    local hospitalSpawns = 
    { 
        { 2027.77, -1420.52, 17.1, }, 
        { 1180.85, -1325.57, 14.0, }, 
        { 1244.437, 331.2261, 20.0, }, 
        { -2199.719, -2308.075, 31.0, }, 
        { -2670.285, 616.4364, 14.6, }, 
        { -316.3832, 1056.045, 20.0, }, 
        { -1514.823, 2527.119, 56.0, }, 
        { 1578.446, 1770.682, 11.0, } 
    } 
      
    function respawn( player, skin ) 
        if not isElement( player ) then 
            return 
        end 
        local myX, myY, myZ = getElementPosition( player ) 
        local mySp, myDis   = 1, 99999 
        for i, sp in ipairs( hospitalSpawns ) do 
            local dis = getDistanceBetweenPoints3D( sp[ 1 ], sp[ 2 ], sp[ 3 ], myX, myY, myZ ) 
            if dis < myDis then 
                myDis = dis 
                mySp  = i 
            end 
        end 
        repeat until spawnPlayer ( player, hospitalSpawns[ mySp ][ 1 ], hospitalSpawns[ mySp ][ 2 ], hospitalSpawns[ mySp ][ 3 ], 0, skin ) 
        fadeCamera( player, true ) 
        setCameraTarget( player, player ) 
        showChat( player, true ) 
    end 
      
    addEventHandler( "onPlayerWasted", root,     
        function( ) 
            uTimers[ source ] = setTimer( respawn,1000,1,source,getElementModel( source ) ) 
        end 
    )   
      
    addEventHandler( 'onPlayerQuit',root, 
        function( ) 
            uTimers[ source ] = nil 
        end 
    )   
        
    addEventHandler( "onResourceStart", resourceRoot, 
        function( ) 
            resetMapInfo( ) 
            for i,player in pairs( getElementsByType 'player' ) do 
                respawn( player ) 
            end 
        end 
    ) 
      
    --End Of script, Adding More Later. 
    --Tarek632 

Line 28, there was a missing "skin" argument that's why you get CJ's skin

now its not showing on my maps when I used that script, i just want to spawn with the same script i died with

Link to comment

I don't know what your problem really is. I tested it myself and everything seems to work just fine. Can you explain your problem thoroughly, what do you mean by 'it's not showing on your maps'.

Could you also post your meta.xml please.

Link to comment

Alright, have you replaced the original code from "altern8_play_respawn_s.lua" with one I posted? If yes, there shouldn't be any problems, your other resources might be causing troubles or there's something you haven't done right.

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