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.9, 2565.8, 60, 58.2, 17 },
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(thePlayer, command)
if(isPedDead(thePlayer)) then
return false
end
if(Arena.Players[thePlayer]) then
setElementData(thePlayer, "arena:inside", false, false)
if(isElement(Arena.Players[thePlayer].vehicle) and GetFreeSeatFromVehicle(Arena.Players[thePlayer].vehicle)) then
warpPedIntoVehicle(thePlayer, Arena.Players[thePlayer].vehicle, GetFreeSeatFromVehicle(Arena.Players[thePlayer].vehicle))
elseif(Arena.Players[thePlayer].worldPosition) then
setElementPosition(thePlayer, unpack(Arena.Players[thePlayer].worldPosition))
end
Arena.Players[thePlayer] = nil
outputChatBox("#1874CD[#00FF00Saiu do PVP#1874CD]#FFFFFF #FF7F00" .. getPlayerName(thePlayer) .. "" , thePlayer, 0, 255, 0, true)
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, 0, 255, 0, true)
setElementFrozen(thePlayer, false)
end
end
addCommandHandler("m41", SpawnPlayerOnArena)
addCommandHandler("sairm41", SpawnPlayerOnArena)
addEventHandler("onPlayerWeaponSwitch", root,function ( prevWeaponId, currentWeaponID )
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.colShape, function(hitElement, dimension)
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, 0, 255, 0, true)
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.colShape, function(leaveElement, dimension)
if(getElementType(leaveElement) == "player" and dimension) then
Arena.Players[leaveElement] = nil
setElementData(leaveElement, "arena:inside", false, false)
outputChatBox("#1874CD[#00FF00Saiu do PVP#1874CD]#FFFFFF #FF7F00" .. getPlayerName(leaveElement) .. "" , leaveElement, 0, 255, 0, true)
end
end)
end)
function GetNextWeapon(player, startPos, endPos)
for i = startPos, endPos, (startPos > endPos and -1 or 1) do
local weapon = getPedWeapon(player, i)
if(weapon ~= 0) then
return weapon
end
end
return false
end
function GetFreeSeatFromVehicle(vehicle)
for i = 0, 3 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>