Jump to content

Skin onplayerdeath


Recommended Posts

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

addEventHandler ( "onPlayerWasted", root,  
    function ( ) 
        local x,y,z = 0,0,0 -- your position to spawn player 
        spawnPlayer( source, x, y, z, 0, 137 ) 
        outputChatBox ( "You are now a Zombie.", source, 255, 0, 0 ) 
    end  
) 

Link to comment

Your gamemode is simple, just make two teams named humans and zombies or whatever and use the setPlayerTeam to assign new player to humans when he/she dies then onPlayerWasted is called, so just change the team on zombies, make a table containing the weapons and skins for each team and assign them inside onPlayerSpawn checking the team with getPlayerTeam, to make a round system just make a function named endRound and set the timer to call it after some time. You don't need a map for that, if you want to disallow zombies picking some pickup just use cancelEvent in OnPickupHit also using getPlayerTeam. It's all possible with just few functions. Don't go off the deep end, it's hard to make own gamemode if it's your first language ever.

Link to comment

this map is for the gamemode "aa"

Download : https://community.multitheftauto.com/in ... ils&id=478

In this gamemode there is one team "Survivals" and a weapons for this team, but i have modified this gamamode and I put two teams "Survivals" and "Zombies".

how do I put weapons for zombies?

Thnx

Gamemode aa CODE :

local aa_root = getRootElement()

teamSurvivor = createTeam ( "Humans", 0, 255, 0 )

teamZombies = createTeam ( "Zombies", 255, 0, 0 )

function loadmap(startmap, player)

mapRoot = getResourceRootElement(startmap)

local plrs = getElementsByType( "player" );

for i, plr in pairs( plrs ) do

setElementData( plr, "Deaths", 0 )

-- ////////////////// MISION \\\\\\\\\\\\\\\\\\

local total_markers = getElementChildrenCount(

getElementByID( "markers" ) )

local num = math.random( 0, total_markers - 1 )

local marker_spawn = getElementChild ( getElementByID(

"markers" ), num)

local mx = getElementData ( marker_spawn, "posX" )

local my = getElementData ( marker_spawn, "posY" )

local mz = getElementData ( marker_spawn, "posZ" )

setPlayerTeam ( plr, teamSurvivor )

objectiveMarker = createMarker(mx, my, mz)

-- ///////////////// SPAWN \\\\\\\\\\\\\\\\\\\\

local total_spawns = getElementChildrenCount(

getElementByID( "spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local spawn_random = getElementChild ( getElementByID(

"spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setTimer( setPedSkin , 500 , 1 , plr, math.random(9,288))

spawnPlayer( plr, x, y, z, rot);

setCameraTarget ( plr, plr );

fadeCamera( plr, true );

for k,v in ipairs( getElementChildren( getElementByID(

"armas" ) ) ) do

giveWeapon( plr, tonumber( getElementData( v,

"id" ) ), getElementData( v, "ammo" ) )

end

end

end

addEventHandler("onGamemodeMapStart", aa_root, loadmap)

function aa_onResourceStart( resourcename, res )

setTeamFriendlyFire(teamSurvivor , false )

if ( resourcename == getThisResource () ) then

local plrs = getElementsByType( "player" );

for i, plr in pairs( plrs ) do

setElementData( plr, "Deaths", 0 )

end

setTimer( call, 1000, 1, getResourceFromName

("scoreboard"), "addScoreboardColumn", "Deaths" )

end

if resourceName == 'mapmanager' then

mapmanager = createResourceCallInterface

('mapmanager')

end

end

addEventHandler( "onResourceStart", aa_root, aa_onResourceStart )

function joinHandler()

local total_spawns = getElementChildrenCount(

getElementByID( "spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local spawn_random = getElementChild ( getElementByID(

"spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setElementData( source, "inmarker", false );

setPlayerTeam ( source, teamSurvivor )

spawnPlayer( source, x, y, z, rot )

setTimer( setPedSkin , 500 , 1 , source, math.random

(9,288))

outputChatBox("< Welcome To Against All By CHAOS_IS_ME>",

source, 255, 138, 0, true)

outputChatBox("< Current Version: #00FF00 1.0>", source, 255,

138, 0, true)

setCameraTarget ( source, source )

setElementData( source, "Deaths", 0 )

fadeCamera(source, true)

for k,v in ipairs( getElementChildren( getElementByID(

"armas" ) ) ) do

giveWeapon( source, tonumber( getElementData( v,

"id" ) ), getElementData( v, "ammo" ) )

end

end

addEventHandler("onPlayerJoin", aa_root, joinHandler)

function aa_playerWasted( totalAmmo, killer )

local playerdeaths = getElementData ( source, "Deaths" )

setElementData ( source, "Deaths", playerdeaths+1 )

local total_spawns = getElementChildrenCount( getElementByID(

"spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local skin = math.random(9,288)

local spawn_random = getElementChild ( getElementByID(

"spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setPlayerTeam ( source, teamSurvivor )

setTimer( spawnPlayer , 5000 , 1 , source, x, y, z, rot)

setTimer( setPedSkin , 5000 , 1 , source, math.random

(128,161))

setCameraTarget ( source, source )

fadeCamera(source, true)

for k,v in ipairs( getElementChildren( getElementByID(

"armas" ) ) ) do

setTimer( giveWeapon, 5000 , 1 , source,

tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo"

) )

end

end

addEventHandler ( "onPlayerWasted", aa_root, aa_playerWasted )

local localPlayerName = getPlayerName(aa_root)

-- misiones

function MarkerHit1 ( hitPlayer, matchingDimension )

local plrs = getElementsByType( "player" );

for i, plr in pairs( plrs ) do

WinDisplay = textCreateDisplay ()

setTimer( textDisplayAddText, 800, 1, WinDisplay, WinText

)

-- textDisplayAddText ( WinDisplay, WinText )

WinText = textCreateTextItem ( getPlayerName(hitPlayer)

.. " WIN! Next Map In 10 Seconds", 0.5, 0.5, "low", 255, 0, 0,

255, 2, "center" )

textDisplayAddObserver ( WinDisplay, plr)

setElementData( hitPlayer, "inmarker", true )

setTimer( textDestroyTextItem, 5000, 1, WinText )

setTimer(StartNextMap,10000,1)

setPedFrozen ( aa_root, true )

setTimer( setPedFrozen, 10000, 1, aa_root, false )

end

end

addEventHandler("onMarkerHit", aa_root, MarkerHit1)

function StartNextMap ()

exports.mapmanager:changeGamemode( getResourceFromName

('aa') )

end

--[[function unassignTeam2 ( source, commandName )

-- this player is on a team, so we can remove

them from it

setPlayerTeam ( source, teamHuwmans ) -- remove the player

from the current team

end

addCommandHandler ( "team3", unassignTeam2 )

function unassignTeam1 ( source, commandName )

-- this player is on a team, so we can remove

them from it

setPlayerTeam ( source, "Survivors" ) -- remove the player

from the current team

end

addCommandHandler ( "team2", unassignTeam1 )

function unassignTeam ( source, commandName )

-- this player is on a team, so we can remove

them from it

setPlayerTeam ( source, Survivors ) -- remove the player

from the current team

end

addCommandHandler ( "team1", unassignTeam )

]]--

-- misiones

addEventHandler ( "onPlayerWasted", root, function ( )

local humans = getTeamFromName ( "Humans" )

if ( getTeamName ( getPlayerTeam ( source ) ) == "Humans" )

then

setPlayerTeam ( source, getTeamFromName ( "Zombies" ) )

else return end

end )

addEventHandler ( "onPlayerWasted", root, function ( )

setPedSkin ( source, 137 )

setPedHeadless ( source, true )

outputChatBox ( "You are now a Zombie.", source, 255, 0,

0 )

end )

addEventHandler ( "onPlayerDamage", getRootElement(),

rewardOnWasted )

infection = createPickup (-1, 1, 3.11, 3, 1275, 15000 )

function infected ( thePlayer )

setPlayerTeam ( thePlayer, teamZombies )

setPedSkin ( thePlayer, 13 )

setPedHeadless ( thePlayer, true )

end

addEventHandler ( "onPickupUse", infection, infected )

Link to comment

There is a loop in this code which gives weapons to elements with id "armas", the id of those elements was set with setElementID, so just set the id and make same loop. That could be done easier, the code of this gamemode is ugly.

Link to comment

Sets a skin and gives knife.

addEventHandler("onPlayerSpawn", root, 
    function() 
        if(getPlayerTeam(source) == teamZombies) then 
            local weaponsToGive = { 
                { id = 4, ammo = 30, setAsCurrent = true }, -- your knife 
            } 
            for _, v in ipairs(weaponsToGive) do 
                giveWeapon(source, v.id, v.ammo, v.setAsCurrent) 
            end 
            setElementModel(source, 137) 
        end 
    end 
) 

Link to comment

Now I'll show you the code that you think should work:

local aa_root = getRootElement()

teamSurvivor = createTeam ( "Humans", 0, 255, 0 )

teamZombies = createTeam ( "Zombies", 255, 0, 0 )

function loadmap(startmap, player)

mapRoot = getResourceRootElement(startmap)

local plrs = getElementsByType( "player" );

for i, plr in pairs( plrs ) do

setElementData( plr, "Deaths", 0 )

-- ////////////////// MISION \\\\\\\\\\\\\\\\\\

local total_markers = getElementChildrenCount( getElementByID( "markers" ) )

local num = math.random( 0, total_markers - 1 )

local marker_spawn = getElementChild ( getElementByID( "markers" ), num)

local mx = getElementData ( marker_spawn, "posX" )

local my = getElementData ( marker_spawn, "posY" )

local mz = getElementData ( marker_spawn, "posZ" )

setPlayerTeam ( plr, teamSurvivor )

objectiveMarker = createMarker(mx, my, mz)

-- ///////////////// SPAWN \\\\\\\\\\\\\\\\\\\\

local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local spawn_random = getElementChild ( getElementByID( "spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setTimer( setPedSkin , 500 , 1 , plr, math.random(9,288))

spawnPlayer( plr, x, y, z, rot);

setCameraTarget ( plr, plr );

fadeCamera( plr, true );

for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do

giveWeapon( plr, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) )

end

end

end

addEventHandler("onGamemodeMapStart", aa_root, loadmap)

function aa_onResourceStart( resourcename, res )

setTeamFriendlyFire(teamSurvivor , false )

if ( resourcename == getThisResource () ) then

local plrs = getElementsByType( "player" );

for i, plr in pairs( plrs ) do

setElementData( plr, "Deaths", 0 )

end

setTimer( call, 1000, 1, getResourceFromName("scoreboard"), "addScoreboardColumn", "Deaths" )

end

if resourceName == 'mapmanager' then

mapmanager = createResourceCallInterface('mapmanager')

end

end

addEventHandler( "onResourceStart", aa_root, aa_onResourceStart )

function joinHandler()

local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local spawn_random = getElementChild ( getElementByID( "spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setElementData( source, "inmarker", false );

setPlayerTeam ( source, teamSurvivor )

spawnPlayer( source, x, y, z, rot )

setTimer( setPedSkin , 500 , 1 , source, math.random(9,288))

outputChatBox("< Welcome To Against All By CHAOS_IS_ME>", source, 255, 138, 0, true)

outputChatBox("< Current Version: #00FF00 1.0>", source, 255, 138, 0, true)

setCameraTarget ( source, source )

setElementData( source, "Deaths", 0 )

fadeCamera(source, true)

for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do

giveWeapon( source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) )

end

end

addEventHandler("onPlayerJoin", aa_root, joinHandler)

function aa_playerWasted( totalAmmo, killer )

local playerdeaths = getElementData ( source, "Deaths" )

setElementData ( source, "Deaths", playerdeaths+1 )

local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) )

local num = math.random( 0, total_spawns - 1 )

local skin = math.random(9,288)

local spawn_random = getElementChild ( getElementByID( "spawns" ), num )

local x = getElementData ( spawn_random, "posX" )

local y = getElementData ( spawn_random, "posY" )

local z = getElementData ( spawn_random, "posZ" )

local rot = getElementData ( spawn_random, "rot" )

setPlayerTeam ( source, teamSurvivor )

setTimer( spawnPlayer , 5000 , 1 , source, x, y, z, rot)

setTimer( setPedSkin , 5000 , 1 , source, math.random(128,161))

setCameraTarget ( source, source )

fadeCamera(source, true)

for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do

setTimer( giveWeapon, 5000 , 1 , source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) )

end

end

addEventHandler ( "onPlayerWasted", aa_root, aa_playerWasted )

local localPlayerName = getPlayerName(aa_root)

-- misiones

function MarkerHit1 ( hitPlayer, matchingDimension )

local plrs = getElementsByType( "player" );

for i, plr in pairs( plrs ) do

WinDisplay = textCreateDisplay ()

setTimer( textDisplayAddText, 800, 1, WinDisplay, WinText )

-- textDisplayAddText ( WinDisplay, WinText )

WinText = textCreateTextItem ( getPlayerName(hitPlayer) .. " WIN! Next Map In 10 Seconds", 0.5, 0.5, "low", 255, 0, 0, 255, 2, "center" )

textDisplayAddObserver ( WinDisplay, plr)

setElementData( hitPlayer, "inmarker", true )

setTimer( textDestroyTextItem, 5000, 1, WinText )

setTimer(StartNextMap,10000,1)

setPedFrozen ( aa_root, true )

setTimer( setElementFrozen, 10000, 1, aa_root, false )

end

end

addEventHandler("onMarkerHit", aa_root, MarkerHit1)

function StartNextMap ()

exports.mapmanager:changeGamemode( getResourceFromName('aa') )

end

--[[function unassignTeam2 ( source, commandName )

-- this player is on a team, so we can remove them from it

setPlayerTeam ( source, teamHuwmans ) -- remove the player from the current team

end

addCommandHandler ( "team3", unassignTeam2 )

function unassignTeam1 ( source, commandName )

-- this player is on a team, so we can remove them from it

setPlayerTeam ( source, "Survivors" ) -- remove the player from the current team

end

addCommandHandler ( "team2", unassignTeam1 )

function unassignTeam ( source, commandName )

-- this player is on a team, so we can remove them from it

setPlayerTeam ( source, Survivors ) -- remove the player from the current team

end

addCommandHandler ( "team1", unassignTeam )

]]--

-- misiones

addEventHandler ( "onPlayerWasted", root, function ( )

local humans = getTeamFromName ( "Humans" )

if ( getTeamName ( getPlayerTeam ( source ) ) == "Humans" ) then

setPlayerTeam ( source, getTeamFromName ( "Zombies" ) )

else return end

end )

addEventHandler ( "onPlayerWasted", root, function ( )

setPedSkin ( source, 137 )

setPedHeadless ( source, true )

outputChatBox ( "You are now a Zombie.", source, 255, 0, 0 )

end )

addEventHandler ( "onPlayerDamage", getRootElement(), rewardOnWasted )

infection = createPickup (-1, 1, 3.11, 3, 1275, 15000 )

function infected ( thePlayer )

setPlayerTeam ( thePlayer, teamZombies )

setPedSkin ( thePlayer, 13 )

setPedHeadless ( thePlayer, true )

end

addEventHandler ( "onPickupUse", infection, infected )

addEventHandler("onPlayerSpawn", root,

function()

if(getPlayerTeam(source) == teamZombies) then

local weaponsToGive = {

{ id = 4, ammo = 30, setAsCurrent = true }, -- your knife

}

for _, v in ipairs(weaponsToGive) do

giveWeapon(source, v.id, v.ammo, v.setAsCurrent)

end

setElementModel(source, 137)

end

end

)

I do not work, why?

Link to comment

You haven't even set zombie team, why do you expect it to work?

Now when you die, you are zombie and after 5 seconds you get spawned with the knife and new skin. If it doesn't work just check error logs, I just modified few lines.

local aa_root = getRootElement() 
  
teamSurvivor = createTeam ( "Humans", 0, 255, 0 ) 
teamZombies = createTeam ( "Zombies", 255, 0, 0 ) 
  
function loadmap(startmap, player) 
    mapRoot = getResourceRootElement(startmap) 
    local plrs = getElementsByType( "player" ); 
    for i, plr in pairs( plrs ) do 
    setElementData( plr, "Deaths", 0 ) 
    -- ////////////////// MISION \\\\\\\\\\\\\\\\\\ 
    local total_markers = getElementChildrenCount( getElementByID( "markers" ) ) 
    local num = math.random( 0, total_markers - 1 ) 
    local marker_spawn = getElementChild ( getElementByID( "markers" ), num) 
    local mx = getElementData ( marker_spawn, "posX" ) 
    local my = getElementData ( marker_spawn, "posY" ) 
    local mz = getElementData ( marker_spawn, "posZ" ) 
    setPlayerTeam ( plr, teamSurvivor ) 
    objectiveMarker = createMarker(mx, my, mz) 
    -- ///////////////// SPAWN \\\\\\\\\\\\\\\\\\\\ 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setTimer( setPedSkin , 500 , 1 , plr, math.random(9,288)) 
    spawnPlayer( plr, x, y, z, rot); 
    setCameraTarget ( plr, plr ); 
    fadeCamera( plr, true ); 
        for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
            giveWeapon( plr, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
        end 
    end 
end 
addEventHandler("onGamemodeMapStart", aa_root, loadmap) 
  
function aa_onResourceStart( resourcename, res ) 
    setTeamFriendlyFire(teamSurvivor , false ) 
    if ( resourcename == getThisResource () ) then 
        local plrs = getElementsByType( "player" ); 
        for i, plr in pairs( plrs ) do 
            setElementData( plr, "Deaths", 0 ) 
        end 
        setTimer( call, 1000, 1, getResourceFromName("scoreboard"), "addScoreboardColumn", "Deaths" ) 
    end 
    if resourceName == 'mapmanager' then 
        mapmanager = createResourceCallInterface('mapmanager') 
    end 
end 
addEventHandler( "onResourceStart", aa_root, aa_onResourceStart ) 
  
function joinHandler() 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setElementData( source, "inmarker", false ); 
    setPlayerTeam ( source, teamSurvivor ) 
    spawnPlayer( source, x, y, z, rot ) 
    setTimer( setPedSkin , 500 , 1 , source, math.random(9,288)) 
    outputChatBox("< Welcome To Against All By CHAOS_IS_ME>", source, 255, 138, 0, true) 
    outputChatBox("< Current Version: #00FF00 1.0>", source, 255, 138, 0, true) 
    setCameraTarget ( source, source ) 
    setElementData( source, "Deaths", 0 ) 
    fadeCamera(source, true) 
    for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
        giveWeapon( source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
    end 
end 
addEventHandler("onPlayerJoin", aa_root, joinHandler) 
  
  
function aa_playerWasted( totalAmmo, killer ) 
    local playerdeaths = getElementData ( source, "Deaths" ) 
    setElementData ( source, "Deaths", playerdeaths+1 ) 
    local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) 
    local num = math.random( 0, total_spawns - 1 ) 
    local skin = math.random(9,288) 
    local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) 
    local x = getElementData ( spawn_random, "posX" ) 
    local y = getElementData ( spawn_random, "posY" ) 
    local z = getElementData ( spawn_random, "posZ" ) 
    local rot = getElementData ( spawn_random, "rot" ) 
    setPlayerTeam ( source, teamZombies ) 
    setTimer( spawnPlayer , 5000 , 1 , source, x, y, z, rot) 
    setCameraTarget ( source, source ) 
    fadeCamera(source, true) 
    --[[ idk what the fuck is dat 
    for k,v in ipairs( getElementChildren( getElementByID( "armas" ) ) ) do 
        setTimer( giveWeapon, 5000 , 1 , source, tonumber( getElementData( v, "id" ) ), getElementData( v, "ammo" ) ) 
    end]] 
end 
addEventHandler ( "onPlayerWasted", aa_root, aa_playerWasted ) 
  
local localPlayerName = getPlayerName(aa_root) 
-- misiones 
  
  
  
function MarkerHit1 ( hitPlayer, matchingDimension ) 
    local plrs = getElementsByType( "player" ); 
    for i, plr in pairs( plrs ) do 
        WinDisplay = textCreateDisplay () 
        setTimer( textDisplayAddText, 800, 1, WinDisplay, WinText ) 
        -- textDisplayAddText ( WinDisplay, WinText ) 
        WinText = textCreateTextItem ( getPlayerName(hitPlayer) .. " WIN! Next Map In 10 Seconds", 0.5, 0.5, "low", 255, 0, 0, 255, 2, "center" ) 
        textDisplayAddObserver ( WinDisplay, plr) 
  
        setElementData( hitPlayer, "inmarker", true ) 
        setTimer( textDestroyTextItem, 5000, 1, WinText ) 
        setTimer(StartNextMap,10000,1) 
        setPedFrozen ( aa_root, true ) 
        setTimer( setElementFrozen, 10000, 1, aa_root, false ) 
    end 
end 
addEventHandler("onMarkerHit", aa_root, MarkerHit1) 
  
function StartNextMap () 
    exports.mapmanager:changeGamemode( getResourceFromName('aa') ) 
end 
  
infection = createPickup (-1, 1, 3.11, 3, 1275, 15000 ) 
function infected ( thePlayer ) 
    setPlayerTeam ( thePlayer, teamZombies ) 
    setPedSkin ( thePlayer, 13 ) 
    setPedHeadless ( thePlayer, true ) 
end 
addEventHandler ( "onPickupUse", infection, infected ) 
  
  
addEventHandler("onPlayerSpawn", root, 
function() 
    if(getPlayerTeam(source) == teamZombies) then 
    local weaponsToGive = { 
        { id = 4, ammo = 30, setAsCurrent = true }, -- your knife 
    } 
    for _, v in ipairs(weaponsToGive) do 
        giveWeapon(source, v.id, v.ammo, v.setAsCurrent) 
    end 
    setElementModel(source, 137) 
    setPedHeadless ( source, true ) 
    outputChatBox ( "You are now a Zombie.", source, 255, 0, 0 ) 
    end 
end 
) 

Link to comment

You will have to remove auto-respawn to make it working, otherwise the team will be always alive(if the server has players)

function AreSurvivorsGone() 
    local t = {} 
    for _, v in ipairs(getPlayersInTeam(teamSurvivor)) do 
        if isPedDead(v) then 
            table.insert(t, v) 
        end 
    end 
    if #t == getPlayersInTeam(teamSurvivor) then 
        return true 
    end 
    return false 
end 
  
addEventHandler("onPlayerWasted", root, 
    function() 
        if AreSurvivorsGone() then 
            -- function for changing the map 
        end 
    end 
) 

Link to comment
  • 2 weeks later...

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