Jump to content

I have a Small problem


sckatchof

Recommended Posts

Try this:

function onPlayerDeath( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playerskin = getAccountData ( playeraccount, "skin" ) 
            if ( playerskin ) then 
                  setPedSkin ( source, playerskin ) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerWasted", getRootElement ( ), onPlayerDeath ) 

Link to comment
Try this:
function onPlayerDeath( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playerskin = getAccountData ( playeraccount, "skin" ) 
            if ( playerskin ) then 
                  setPedSkin ( source, playerskin ) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerWasted", getRootElement ( ), onPlayerDeath ) 

i try but doesn't work when i die my skin changer to cj skin

Link to comment

Just use the skin argument in spawnPlayer.

Like onPlayerWasted set a timer to spawn the player, and specify the skin argument with getElementModel.

Ex:

addEventHandler ( "onPlayerWasted" , root , 
    function ( ) 
        fadeCamera ( source , false , 3 ) 
        setTimer ( 
            function () 
                spawnPlayer ( source , 1178.9 , -1323.7143554688 , 15 , 270 , getElementModel ( source ) , 0 , 0 ) 
                fadeCamera ( source , true , 2 ) 
            end 
        , 5000 , 1) 
    end 
) 

Link to comment
Post your script where you respawn the player.

this is my script

spawnsHospitals = {{X,Y,Z,RZ}} 
spawnsHospitals[1] = {X=1177.4658203125,Y=-1323.8505859375,Z=14.072093963623,RZ=272.34698486328} 
spawnsHospitals[2] = {X=2033.337890625,Y=-1415.2353515625,Z=16.9921875,RZ=136.29571533203} 
spawnsHospitals[3] = {X=-2660.431640625,Y=633.8486328125,Z=14.453125,RZ=181.82925415039} 
spawnsHospitals[4] = {X=1578.947265625,Y=1768.3779296875,Z=10.8203125,RZ=93.712066650391} 
spawnsHospitals[5] = {X=1876.330078125,Y=2237.36328125,Z=11.125,RZ=5.7651672363281} 
spawnsHospitals[6] = {X=1244.9228515625,Y=332.85546875,Z=19.5546875,RZ=339.0514831543} 
spawnsHospitals[7] = {X=-321.7744140625,Y=1057.1728515625,Z=19.7421875,RZ=310.25588989258} 
spawnsHospitals[8] = {X=-1514.6015625,Y=2525.173828125,Z=55.780910491943,RZ=4.556640625} 
  
function playerKilled( ) 
    setTimer( respawnToNearestHospital, 5000, 1, source ) 
end 
addEventHandler("onPlayerWasted", getRootElement(), playerKilled ) 
  
function respawnToNearestHospital( thePlayer ) 
    local x, y, z = getElementPosition( thePlayer ) 
    tableDist = {{index,dist}} 
    for k,i in ipairs ( spawnsHospitals ) do 
        local x2 = spawnsHospitals[k]["X"] 
        local y2 = spawnsHospitals[k]["Y"] 
        local dis = getDistanceBetweenPoints2D( x, y, x2, y2 ) 
        tableDist[k] = {index=k,dist=dis} 
    end 
    local goodK = -1 
    for l,j in ipairs( tableDist ) do 
        if ( l == 1 ) then 
            goodK = 1 
        else 
            local DIST1 = tableDist[goodK]["dist"] 
            local DIST2 = tableDist[l]["dist"] 
            if ( DIST2 < DIST1 ) then 
                goodK = l 
            end 
        end 
    end 
    if ( goodK == -1 ) then return end 
    spawnPlayer( thePlayer, spawnsHospitals[goodK]["X"], spawnsHospitals[goodK]["Y"], spawnsHospitals[goodK]["Z"], math.random (0,288), 0, 0, spawnTeam) 
    setPedRotation( thePlayer, spawnsHospitals[goodK]["RZ"] ) 
    if(tonumber(skin) == 199) then 
    skin = math.random(0,200) 
    end 
end 

Link to comment
spawnsHospitals = {} 
spawnsHospitals[1] = {X=1177.4658203125,Y=-1323.8505859375,Z=14.072093963623,RZ=272.34698486328} 
spawnsHospitals[2] = {X=2033.337890625,Y=-1415.2353515625,Z=16.9921875,RZ=136.29571533203} 
spawnsHospitals[3] = {X=-2660.431640625,Y=633.8486328125,Z=14.453125,RZ=181.82925415039} 
spawnsHospitals[4] = {X=1578.947265625,Y=1768.3779296875,Z=10.8203125,RZ=93.712066650391} 
spawnsHospitals[5] = {X=1876.330078125,Y=2237.36328125,Z=11.125,RZ=5.7651672363281} 
spawnsHospitals[6] = {X=1244.9228515625,Y=332.85546875,Z=19.5546875,RZ=339.0514831543} 
spawnsHospitals[7] = {X=-321.7744140625,Y=1057.1728515625,Z=19.7421875,RZ=310.25588989258} 
spawnsHospitals[8] = {X=-1514.6015625,Y=2525.173828125,Z=55.780910491943,RZ=4.556640625} 
  
function playerKilled( ) 
    setTimer( respawnToNearestHospital, 5000, 1, source ) 
end 
addEventHandler("onPlayerWasted", getRootElement(), playerKilled ) 
  
function respawnToNearestHospital( thePlayer ) 
    local x, y, z = getElementPosition( thePlayer ) 
    tableDist = {{index,dist}} 
    for k,i in ipairs ( spawnsHospitals ) do 
        local x2 = spawnsHospitals[k]["X"] 
        local y2 = spawnsHospitals[k]["Y"] 
        local dis = getDistanceBetweenPoints2D( x, y, x2, y2 ) 
        tableDist[k] = {index=k,dist=dis} 
    end 
    local goodK = -1 
    for l,j in ipairs( tableDist ) do 
        if ( l == 1 ) then 
            goodK = 1 
        else 
            local DIST1 = tableDist[goodK]["dist"] 
            local DIST2 = tableDist[l]["dist"] 
            if ( DIST2 < DIST1 ) then 
                goodK = l 
            end 
        end 
    end 
    if ( goodK == -1 ) then return end 
    spawnPlayer( thePlayer, spawnsHospitals[goodK]["X"], spawnsHospitals[goodK]["Y"], spawnsHospitals[goodK]["Z"], math.random (0,288), getElementModel(thePlayer), 0, 0, spawnTeam) 
    setPedRotation( thePlayer, spawnsHospitals[goodK]["RZ"] ) 
    if(tonumber(skin) == 199) then 
    skin = math.random(0,200) 
    end 
end 

You should check the function arguments ;).

Link to comment
spawnsHospitals = {} 
spawnsHospitals[1] = {X=1177.4658203125,Y=-1323.8505859375,Z=14.072093963623,RZ=272.34698486328} 
spawnsHospitals[2] = {X=2033.337890625,Y=-1415.2353515625,Z=16.9921875,RZ=136.29571533203} 
spawnsHospitals[3] = {X=-2660.431640625,Y=633.8486328125,Z=14.453125,RZ=181.82925415039} 
spawnsHospitals[4] = {X=1578.947265625,Y=1768.3779296875,Z=10.8203125,RZ=93.712066650391} 
spawnsHospitals[5] = {X=1876.330078125,Y=2237.36328125,Z=11.125,RZ=5.7651672363281} 
spawnsHospitals[6] = {X=1244.9228515625,Y=332.85546875,Z=19.5546875,RZ=339.0514831543} 
spawnsHospitals[7] = {X=-321.7744140625,Y=1057.1728515625,Z=19.7421875,RZ=310.25588989258} 
spawnsHospitals[8] = {X=-1514.6015625,Y=2525.173828125,Z=55.780910491943,RZ=4.556640625} 
  
function playerKilled( ) 
    setTimer( respawnToNearestHospital, 5000, 1, source ) 
end 
addEventHandler("onPlayerWasted", getRootElement(), playerKilled ) 
  
function respawnToNearestHospital( thePlayer ) 
    local x, y, z = getElementPosition( thePlayer ) 
    tableDist = {{index,dist}} 
    for k,i in ipairs ( spawnsHospitals ) do 
        local x2 = spawnsHospitals[k]["X"] 
        local y2 = spawnsHospitals[k]["Y"] 
        local dis = getDistanceBetweenPoints2D( x, y, x2, y2 ) 
        tableDist[k] = {index=k,dist=dis} 
    end 
    local goodK = -1 
    for l,j in ipairs( tableDist ) do 
        if ( l == 1 ) then 
            goodK = 1 
        else 
            local DIST1 = tableDist[goodK]["dist"] 
            local DIST2 = tableDist[l]["dist"] 
            if ( DIST2 < DIST1 ) then 
                goodK = l 
            end 
        end 
    end 
    if ( goodK == -1 ) then return end 
    spawnPlayer( thePlayer, spawnsHospitals[goodK]["X"], spawnsHospitals[goodK]["Y"], spawnsHospitals[goodK]["Z"], math.random (0,288), getElementModel(thePlayer), 0, 0, spawnTeam) 
    setPedRotation( thePlayer, spawnsHospitals[goodK]["RZ"] ) 
    if(tonumber(skin) == 199) then 
    skin = math.random(0,200) 
    end 
end 

You should check the function arguments ;).

thanks snake its work :D

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