Jump to content

Set de armas por comando e quando renasce (arena)


Recommended Posts

Olá tenho um script aqui que funciona como se fosse uma arena, você da o comando (por exemplo: /m41 ) e você vai para uma arena de m4 e quando você morre você continua na arena, só que nasce em outra posição da arena! Ai para sair da arena é necessário dar o comando (por exemplo: /sairm41) E com isso, precisava de uma ajuda para colocar nesse script para quando você entrasse nessa arena e você renasce-se nessa arena, você receber a tal arma escolhida, e que ela fosse removida quando você saísse da arena! Alguém poderia me ajudar?

Script abaixo:

---pvp_s.lua---

local Arena =
{
    colShape = nil,
    properties = { 1408.8998, -1992.92565.86058.217 },
    spawnPositions =
    {
        { 3151.5356445312,1809.4429931641,885.99682617188 },
        { 3136.2534179688,1792.8405761719,885.99658203125 },
        { 3126.1694335938,1819.7473144531,885.99670410156 },
        { 3162.8491210938,1809.7401123047,885.99658203125 }
    },
    Players = {}
}
 
local ForbiddenWeapons = 
    [35] = true
    [36] = true
    [37] = true
    [38] = true,
}
 
function SpawnPlayerOnArena(thePlayercommand)
    if(isPedDead(thePlayer)) then 
        return false
    end
    if(Arena.Players[thePlayer]) then
        setElementData(thePlayer, "arena:inside"falsefalse)
        if(isElement(Arena.Players[thePlayer].vehicle) and GetFreeSeatFromVehicle(Arena.Players[thePlayer].vehicle)) then
            warpPedIntoVehicle(thePlayer, Arena.Players[thePlayer].vehicleGetFreeSeatFromVehicle(Arena.Players[thePlayer].vehicle))
        elseif(Arena.Players[thePlayer].worldPositionthen
            setElementPosition(thePlayer, unpack(Arena.Players[thePlayer].worldPosition))
        end
        Arena.Players[thePlayer] = nil
        outputChatBox("#1874CD[#00FF00Saiu do PVP#1874CD]#FFFFFF #FF7F00" .. getPlayerName(thePlayer) .. "" , thePlayer, 02550true)
    else
        setElementData(thePlayer, "arena:inside"true)
        Arena.Players[thePlayer] = {}
        Arena.Players[thePlayer].worldPosition = { getElementPosition(thePlayer) }
        Arena.Players[thePlayer].skinId = getElementModel(thePlayer)
        local playerVehicle = getPedOccupiedVehicle(thePlayer)
        if(playerVehicle) then
            Arena.Players[thePlayer].vehicle = playerVehicle
            removePedFromVehicle(thePlayer)
        end
        setElementPosition(thePlayer, unpack(Arena.spawnPositions[math.random(#Arena.spawnPositions)]))
        setElementFrozen(thePlayer, true)
        outputChatBox("#1874CD[#00FF00Entrou no PVP#1874CD]#FFFFFF #FF7F00".. getPlayerName(thePlayer) .."" , thePlayer, 02550true)
        setElementFrozen(thePlayer, false)
    end
end
addCommandHandler("m41", SpawnPlayerOnArena)
addCommandHandler("sairm41", SpawnPlayerOnArena) 
 
addEventHandler("onPlayerWeaponSwitch", root,function ( prevWeaponIdcurrentWeaponID )
    if(getElementData(source, "arena:inside") and ForbiddenWeapons[currentWeaponID]) then
        local cSlot = getSlotFromWeapon(currentWeaponID)
        setPedWeaponSlot(source, GetNextWeapon(source, cSlot, getSlotFromWeapon(prevWeaponId) > cSlot and 12 or 0) or 0)
    end
end)
 
addEventHandler("onResourceStart", resourceRoot, function()
    Arena.colShape = createColCuboid(unpack(Arena.properties))
    addEventHandler("onColShapeHit", Arena.colShapefunction(hitElementdimension)
        if(getElementType(hitElement) == "player" and dimension) then
            if(Arena.Players[hitElement]) then
                return false
            end
            outputChatBox("#1874CD[#00FF00Entrou no PVP#1874CD]#FFFFFF #FF7F00".. getPlayerName(hitElement) .."" , hitElement, 02550true)
            Arena.Players[hitElement] = {}
            Arena.Players[hitElement].skinId = getElementModel(hitElement)
            if(getPedOccupiedVehicle(hitElement)) then
                removePedFromVehicle(hitElement)
            end
            setElementData(hitElement, "arena:inside"true)
        elseif(getElementType(hitElement) == "vehicle"then
            destroyElement(hitElement)
        end
    end)
    addEventHandler("onColShapeLeave", Arena.colShapefunction(leaveElementdimension)
        if(getElementType(leaveElement) == "player" and dimension) then
            Arena.Players[leaveElement] = nil
            setElementData(leaveElement, "arena:inside"falsefalse)
            outputChatBox("#1874CD[#00FF00Saiu do PVP#1874CD]#FFFFFF #FF7F00" .. getPlayerName(leaveElement) .. "" , leaveElement, 02550true)
        end
    end)
end)
 
function GetNextWeapon(playerstartPosendPos)
    for i = startPos, endPos, (startPos > endPos and -1 or 1do
        local weapon = getPedWeapon(player, i)
        if(weapon ~= 0then
            return weapon
        end
    end
    return false
end
 
function GetFreeSeatFromVehicle(vehicle)
    for i = 03 do
        if(not getVehicleOccupant(vehicle, i)) then
            return i
        end
    end
    return false
end
 
addEventHandler("onPlayerWasted", root, function()
    if(getElementData(source, "arena:inside")) then
        local x, y, z = unpack(Arena.spawnPositions[math.random(#Arena.spawnPositions)])
        spawnPlayer(source, x, y, z, 0, Arena.Players[source].skinId )
    end
end)
 
--- pvp_c.lua----
 
setDevelopmentMode(true)
 
----meta.xml----
 
<meta>
    <info author="SCORPION" version="1.5" name="PVP" type="script" />
    <script src="pvp_s.lua" type="server" /> 
    <script src="pvp_c.lua" type="client" />    
</meta>
 
Link to comment
14 hours ago, Silverlive said:

Hello I have a script here that works like an arena, you give the command (for example: /m41 ) and you go to an m4 arena and when you die you are still in the arena,
but it is born in another position of the arena! Then, to leave the arena, you need to give the command (for example: /sairm41) And with that,
I needed some help to put in this script for when you entered this arena and you are reborn in this arena, you will receive that chosen weapon,
and have it removed when you left the arena! can anybody help me?


Script:

---pvp_s.lua---

local Arena =
{
    colShape = nil,
    properties = { 1408.8998, -1992.92565.86058.217 },
    spawnPositions =
    {
        { 3151.5356445312,1809.4429931641,885.99682617188 },
        { 3136.2534179688,1792.8405761719,885.99658203125 },
        { 3126.1694335938,1819.7473144531,885.99670410156 },
        { 3162.8491210938,1809.7401123047,885.99658203125 }
    },
    Players = {}
}
 
local ForbiddenWeapons = 
    [35] = true
    [36] = true
    [37] = true
    [38] = true,
}
 
function SpawnPlayerOnArena(thePlayercommand)
    if(isPedDead(thePlayer)) then 
        return false
    end
    if(Arena.Players[thePlayer]) then
        setElementData(thePlayer, "arena:inside"falsefalse)
        if(isElement(Arena.Players[thePlayer].vehicle) and GetFreeSeatFromVehicle(Arena.Players[thePlayer].vehicle)) then
            warpPedIntoVehicle(thePlayer, Arena.Players[thePlayer].vehicleGetFreeSeatFromVehicle(Arena.Players[thePlayer].vehicle))
        elseif(Arena.Players[thePlayer].worldPositionthen
            setElementPosition(thePlayer, unpack(Arena.Players[thePlayer].worldPosition))
        end
        Arena.Players[thePlayer] = nil
        outputChatBox("#1874CD[#00FF00Saiu do PVP#1874CD]#FFFFFF #FF7F00" .. getPlayerName(thePlayer) .. "" , thePlayer, 02550true)
    else
        setElementData(thePlayer, "arena:inside"true)
        Arena.Players[thePlayer] = {}
        Arena.Players[thePlayer].worldPosition = { getElementPosition(thePlayer) }
        Arena.Players[thePlayer].skinId = getElementModel(thePlayer)
        local playerVehicle = getPedOccupiedVehicle(thePlayer)
        if(playerVehicle) then
            Arena.Players[thePlayer].vehicle = playerVehicle
            removePedFromVehicle(thePlayer)
        end
        setElementPosition(thePlayer, unpack(Arena.spawnPositions[math.random(#Arena.spawnPositions)]))
        setElementFrozen(thePlayer, true)
        outputChatBox("#1874CD[#00FF00Entrou no PVP#1874CD]#FFFFFF #FF7F00".. getPlayerName(thePlayer) .."" , thePlayer, 02550true)
        setElementFrozen(thePlayer, false)
    end
end
addCommandHandler("m41", SpawnPlayerOnArena)
addCommandHandler("sairm41", SpawnPlayerOnArena) 
 
addEventHandler("onPlayerWeaponSwitch", root,function ( prevWeaponIdcurrentWeaponID )
    if(getElementData(source, "arena:inside") and ForbiddenWeapons[currentWeaponID]) then
        local cSlot = getSlotFromWeapon(currentWeaponID)
        setPedWeaponSlot(source, GetNextWeapon(source, cSlot, getSlotFromWeapon(prevWeaponId) > cSlot and 12 or 0) or 0)
    end
end)
 
addEventHandler("onResourceStart", resourceRoot, function()
    Arena.colShape = createColCuboid(unpack(Arena.properties))
    addEventHandler("onColShapeHit", Arena.colShapefunction(hitElementdimension)
        if(getElementType(hitElement) == "player" and dimension) then
            if(Arena.Players[hitElement]) then
                return false
            end
            outputChatBox("#1874CD[#00FF00Entrou no PVP#1874CD]#FFFFFF #FF7F00".. getPlayerName(hitElement) .."" , hitElement, 02550true)
            Arena.Players[hitElement] = {}
            Arena.Players[hitElement].skinId = getElementModel(hitElement)
            if(getPedOccupiedVehicle(hitElement)) then
                removePedFromVehicle(hitElement)
            end
            setElementData(hitElement, "arena:inside"true)
        elseif(getElementType(hitElement) == "vehicle"then
            destroyElement(hitElement)
        end
    end)
    addEventHandler("onColShapeLeave", Arena.colShapefunction(leaveElementdimension)
        if(getElementType(leaveElement) == "player" and dimension) then
            Arena.Players[leaveElement] = nil
            setElementData(leaveElement, "arena:inside"falsefalse)
            outputChatBox("#1874CD[#00FF00Saiu do PVP#1874CD]#FFFFFF #FF7F00" .. getPlayerName(leaveElement) .. "" , leaveElement, 02550true)
        end
    end)
end)
 
function GetNextWeapon(playerstartPosendPos)
    for i = startPos, endPos, (startPos > endPos and -1 or 1do
        local weapon = getPedWeapon(player, i)
        if(weapon ~= 0then
            return weapon
        end
    end
    return false
end
 
function GetFreeSeatFromVehicle(vehicle)
    for i = 03 do
        if(not getVehicleOccupant(vehicle, i)) then
            return i
        end
    end
    return false
end
 
addEventHandler("onPlayerWasted", root, function()
    if(getElementData(source, "arena:inside")) then
        local x, y, z = unpack(Arena.spawnPositions[math.random(#Arena.spawnPositions)])
        spawnPlayer(source, x, y, z, 0, Arena.Players[source].skinId )
    end
end)
 
--- pvp_c.lua----
 
setDevelopmentMode(true)
 
----meta.xml----
 
<meta>
    <info author="SCORPION" version="1.5" name="PVP" type="script" />
    <script src="pvp_s.lua" type="server" /> 
    <script src="pvp_c.lua" type="client" />    
</meta>
 

 

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