mysql = exports.mysql
local prisonmarker = createMarker ( 187.14199829102, 1868.3699951172, 17.746978759766, "cylinder", 250, 0, 0, 0, 0, 0 )
function playerDeath()
if getElementData(source, "dbid") then
local name = string.gsub(getPlayerName(source), "_", " ")
local eventStarted = false
local playersJoinedEvent = { }
local weaponEvent, weaponAmmo, eventEnded
local adminPositionX, adminPositionY, adminPositionZ
local playersData = { }
setPlayerNametagText(source, tostring(name))
exports['anticheat-system']:changeProtectedElementDataEx(source, "nameTint", 0)
if getElementData(source, "adminjailed") then
spawnPlayer(source, 263.821807, 77.848365, 1001.0390625, 270, getElementModel(source), 0, getElementData(source, "playerid")+65400, getPlayerTeam(source))
setCameraInterior(source, 6)
setCameraTarget(source)
fadeCamera(source, true)
else
outputChatBox("Respawn in 10 seconds.", source)
setTimer(respawnPlayer, 10000, 1, source)
playersJoinedEvent = true
spawnPlayer = false
end
end
end
addEventHandler("onPlayerWasted", getRootElement(), playerDeath)
function respawnPlayer(thePlayer)
if (isElement(thePlayer)) then
local cost = 0
local faction = false
if not exports.global:isPlayerSilverDonator(thePlayer) then
local team = getPlayerTeam(thePlayer)
if getTeamName(team) == "San Andreas Network" then
_, cost = exports.global:takeMoney(team, math.random(150, 300), true)
faction = getTeamName(team)
else
_, cost = exports.global:takeMoney(thePlayer, math.random(150, 300), true)
end
end
local tax = exports.global:getTaxAmount()
exports.global:giveMoney( getTeamFromName("Las Venturas Emergency Services"), math.ceil((1-tax)*cost) )
exports.global:giveMoney( getTeamFromName("Government of Los Santos"), math.ceil(tax*cost) )
mysql:query_free("UPDATE characters SET deaths = deaths + 1 WHERE charactername='" .. mysql:escape_string(getPlayerName(thePlayer)) .. "'")
setCameraInterior(thePlayer, 0)
local text = "You have recieved treatment from the Los Santos Medical Center."
if cost > 0 then
text = text .. " Cost: " .. cost .. "$"
end
if faction then
text = text .. ", paid by " .. faction .. "."
end
outputChatBox(text, thePlayer, 255, 255, 0)
-- take all drugs
local count = 0
for i = 30, 43 do
while exports.global:hasItem(thePlayer, i) do
exports.global:takeItem(thePlayer, i)
count = count + 1
end
end
if count > 0 then
outputChatBox("The illegal substances you had have been handed over to investigators.", thePlayer, 255, 194, 14)
end
local theSkin = getPedSkin(thePlayer)
local theTeam = getPlayerTeam(thePlayer)
local fat = getPedStat(thePlayer, 21)
local muscle = getPedStat(thePlayer, 23)
setPedStat(thePlayer, 21, fat)
setPedStat(thePlayer, 23, muscle)
spawnPlayer(thePlayer,1185.296875, -1323.7158203125, 13.572407722473, 0, theSkin, 0, 0, theTeam)
fadeCamera(thePlayer, true, 6)
triggerClientEvent(thePlayer, "fadeCameraOnSpawn", thePlayer)
end
end
function deathRemoveWeapons(weapons, removedWeapons)
setTimer(giveGunsBack, 10005, 1, source, weapons, removedWeapons)
end
addEvent("onDeathRemovePlayerWeapons", true)
addEventHandler("onDeathRemovePlayerWeapons", getRootElement(), deathRemoveWeapons)
function giveGunsBack(thePlayer, weapons, removedWeapons, removedWeapons2)
if (removedWeapons~=nil) then
if tonumber(getElementData(thePlayer, "license.gun")) == 0 and getElementData(getPlayerTeam(thePlayer),"type") ~= 2 then
outputChatBox("The employees have taken away weapons which you did not have a license for. (" .. removedWeapons .. ").", thePlayer, 255, 194, 14)
else
outputChatBox("The employees have taken away weapons which you are not allowed to carry. (" .. removedWeapons .. ").", thePlayer, 255, 194, 14)
end
end
if removedWeapons2 ~= nil then
outputChatBox("The employees have taken away your " .. removedWeapons2 .. " for safety purposes.", thePlayer, 255, 194, 14)
end
-- 28
for key, value in ipairs(weapons) do
local weapon = tonumber(weapons[key][1])
local ammo = tonumber(weapons[key][2])
local removed = tonumber(weapons[key][3])
if (removed==0) then
exports.global:giveWeapon(thePlayer, weapon, math.floor( ammo / 2 ), false)
else
exports.global:takeWeapon(thePlayer, weapon)
exports.logs:logMessage("[Death] " .. getElementData(thePlayer, "gameaccountusername") .. "/" .. getPlayerName(thePlayer) .. " lost a weapon (" .. getWeaponNameFromID (weapon) .. "/".. tostring(ammo) .." ammo)", 28)
end
end
end
local eventStarted = false
local playersJoinedEvent = { }
local weaponEvent, weaponAmmo, eventEnded
local adminPositionX, adminPositionY, adminPositionZ
local playersData = { }
function convertPlayerWeaponsToTable(player)
local weapons = { }
for slot = 0, 12 do
local weapon = getPedWeapon( player, slot )
if ( weapon > 0 ) then
local ammo = getPedTotalAmmo( player, slot )
if ( ammo > 0 ) then
weapons[weapon] = ammo
end
end
end
return weapons
end
function playerJoinsEvent ( thePlayer, command )
if ( eventStarted == true and not playersJoinedEvent[thePlayer] and command == "joinevent" ) then
local pX, pY, pZ = getElementPosition ( thePlayer )
local randomobjectnumber = math.random(1, 300)
local playerSkin = getElementModel ( thePlayer )
playersData[thePlayer] =
{
position = { pX, pY, pZ },
skin = playerSkin,
weapons = convertPlayerWeaponsToTable( thePlayer )
}
if spawnPlayer( thePlayer, adminPositionX, adminPositionY, adminPositionZ, 0, tonumber( skinID ) ) then
playerJoinedEvent = true
setElementModel ( thePlayer, randomobjectnumber )
exports.global:giveWeapon ( thePlayer, weaponEvent, tonumber( weaponAmmo ) )
outputChatBox( "#FFFFFFEVENT: You successfully joined the event", thePlayer, 255, 255, 255, true )
playersJoinedEvent[thePlayer] = true
end
elseif ( eventStarted == false and not playersJoinedEvent[thePlayer] and command == "joinevent" ) then
outputChatBox( "#FFFFFFEVENT: There is no event currently ongoing.", thePlayer, 255, 255, 255, true )
elseif ( eventStarted == true and playerJoinedEvent == true and command == "joinevent" ) then
outputChatBox( "#FFFFFFEVENT: You are already in the event", thePlayer, 255, 255, 255, true )
end
if ( eventEnded == false and not playersJoinedEvent[thePlayer] and command == "endevent" ) then
loadOriginalData ( thePlayer )
eventEnded = true
end
if ( command == "quitevent" and eventStarted == true and playersJoinedEvent[thePlayer] )then
--loadOriginalData ( thePlayer )
killPed( thePlayer )
outputChatBox( "#FFFFFFEVENT: You successfully quit the event.", thePlayer, 255, 255, 255, true )
end
end
addCommandHandler("joinevent",playerJoinsEvent)
addCommandHandler("quitevent",playerJoinsEvent)
function loadOriginalData ( thePlayer )
local savedData = playersData[thePlayer]
if ( savedData and type ( savedData ) == "table" ) then
local x, y, z = unpack ( savedData.position )
playersJoinedEvent[thePlayer] = nil
local spawned = spawnPlayer( thePlayer, x, y, z, 0, savedData.skin)
if (spawned ) then
takeAllWeapons ( thePlayer )
for weapon, ammo in pairs ( savedData.weapons ) do
exports.global:giveWeapon ( thePlayer, weapon, ammo )
end
end
end
end
function adminStartEvent(thePlayer, command, weaponId, ammoCMD)
if ( eventStarted == false and command == "startevent" and weaponId ~= null ) then
playersData = { }
playersJoinedEvent = { }
--Declaring booleans and variables
weaponAmmo = ammoCMD
weaponEvent = weaponId
eventEnded = false
eventStarted = true
local weaponName = getWeaponNameFromID ( weaponEvent )
adminPositionX, adminPositionY, adminPositionZ = getElementPosition ( thePlayer )
--***********************
outputChatBox( "#FFFFFFEVENT: Event started by Admin", getRootElement( ), 255, 255, 255, true )
outputChatBox( "#FFFFFFEVENT: Weapon being used ".. weaponName, thePlayer,255, 255, 255, true )
end
if ( eventStarted == false and command == "startevent" and weaponId == null ) then
outputChatBox( "SYNTAX: /startevent [weaponID] [ammo]", thePlayer, 255, 194, 14, true )
end
if ( eventStarted == true and command == "endevent" ) then
eventStarted = false
eventEnded = true
playerJoinedEvent = false
outputChatBox( "#FFFFFFEVENT: Event ended by an Admin", thePlayer, 255, 255, 255, true )
elseif ( eventStarted == false and command == "endevent" ) then
outputChatBox( "#FFFFFFEVENT: There is no event in progress.", thePlayer, 255, 255, 255, true )
end
end
addCommandHandler( "startevent", adminStartEvent )
addCommandHandler( "endevent", adminStartEvent )
addEventHandler( "onPlayerSpawn", getRootElement( ),
function ( )
if ( eventStarted == true and playersJoinedEvent[source] ) then
loadOriginalData ( source )
end
end
)
addEventHandler( "onPlayerWasted", getRootElement( ),
function ( )
if ( eventStarted == true and playerJoinedEvent == true ) then
loadOriginalData ( source )
end
end
)
You mean it?
See line 177
If you type cmd /quitevent you killed and respawned.