Hallo wollte fragen wie man da machen kann das mann eine Meldung nur in einer Fraktion wenn man drin ist die meldugn sieht
Code:
Lua: feuerwehr_server.lua
addEvent ( "extinguishFire", true )
addEvent ( "cuttedFiremanTree", true )
local actiondatas = { list = {}, place = 0 }
local firepeds = {}
local blips = {}
local sounddata = {}
local vehobj = {}
local funcs = {}
local actiontimer = {}
local action = nil
local actionstaytime = 0
local actioncometime = 0
local amountflamesatvehicle = 0
local pedhealth = 0
local treehealth = 0
funcs.stopAction = function ( startagain )
action = nil
if firepeds[1] then
for i=1, #firepeds do
destroyElement ( firepeds[i] )
end
end
if vehobj[1] then
for i=1, #vehobj do
destroyElement ( vehobj[i] )
end
end
firepeds = {}
vehobj = {}
sounddata = {}
if bool then
setTimer ( funcs.startAction, type ( actioncometime ) == "table" and math.random ( actioncometime[1], actioncometime[2] ) or actioncometime, 1 )
end
end
local function createPedForFire ( x, y, z, parent, path, volume )
local counter = #firepeds + 1
firepeds[counter] = createPed ( 0, x, y, z, 0, false )
setElementData ( firepeds[counter], "health", ( pedhealth == "table" and math.random ( pedhealth[1], pedhealth[2] ) or pedhealth ) )
setPedAnimation ( firepeds[counter], "cop_ambient", "coplook_in", -1, true, false, false, true )
setElementAlpha ( firepeds[counter], 0 )
setElementFrozen ( firepeds[counter], true )
local blipcounter = #blips + 1
blips[blipcounter] = createBlipAttachedTo ( firepeds[counter], 0, 2, 255, 0, 0, 255, 0, 99999 )
setElementVisibleTo ( blips[blipcounter], root, false )
for playeritem, key in pairs ( fraktionMembers[10] ) do
setElementVisibleTo ( blips[blipcounter], playeritem, true )
end
setElementParent ( blips[blipcounter], firepeds[counter] )
if parent then
setElementParent ( firepeds[counter], parent )
end
if path then
sounddata[firepeds[counter]] = { path, volume or 1 }
end
end
funcs.startAction = function ( )
funcs.stopAction ( false )
action = actiondatas.list[math.random ( #actiondatas.list )]
actiondatas.place = math.random ( #actiondatas[action] )
for i=1, #actiondatas[action][actiondatas.place] do
local array = actiondatas[action][actiondatas.place][i]
local dataplace = #vehobj+1
if array.typ == "vehicle" then
vehobj[dataplace] = createVehicle ( array.model, array.posX, array.posY, array.posZ, array.rotX, array.rotY, array.rotZ, "Unfall" )
setVehicleDoorState ( vehobj[dataplace], 0, 3 )
for i=1, 5 do
setVehicleDoorState ( vehobj[dataplace], i, 2 )
end
setElementHealth ( vehobj[dataplace], 251 )
setVehicleColor ( vehobj[dataplace], array.r, array.g, array.b )
setVehicleDamageProof ( vehobj[dataplace], true )
setVehicleDoorsUndamageable ( vehobj[dataplace], true )
setVehicleEngineState ( vehobj[dataplace], false )
toggleVehicleRespawn ( vehobj[dataplace], false )
setVehicleLocked ( vehobj[dataplace], true )
setElementFrozen ( vehobj[dataplace], true )
local counter = #firepeds
local limit = type ( amountflamesatvehicle ) == "table" and math.random ( amountflamesatvehicle[1], amountflamesatvehicle[2] ) or amountflamesatvehicle
while counter < limit do
counter = counter + 1
local x, y = math.random ( -300, 300 ) / 100, math.random ( -300, 300 ) / 100
createPedForFire ( array.posX+x, array.posY+y, array.posZ, vehobj[dataplace] )
end
if array.soundpath then
sounddata[vehobj[dataplace]] = { array.soundpath, array.volume or 1 }
end
elseif array.typ == "object" then
vehobj[dataplace] = createObject ( array.model, array.posX, array.posY, array.posZ, array.rotX, array.rotY, array.rotZ )
setObjectScale ( vehobj[dataplace], array.scale )
setElementFrozen ( vehobj[dataplace], true )
if array.soundpath then
sounddata[vehobj[dataplace]] = { array.soundpath, array.volume or 1 }
end
if action ~= "tree" then
createPedForFire ( array.posX, array.posY, array.posZ, vehobj[dataplace], array.soundpath, array.volume )
else
setElementData ( vehobj[dataplace], "health", ( treehealth == "table" and math.random ( treehealth[1], treehealth[2] ) or treehealth ) )
local blipcounter = #blips + 1
blips[blipcounter] = createBlipAttachedTo ( vehobj[dataplace], 0, 2, 255, 0, 0, 255, 0, 99999 )
setElementVisibleTo ( blips[blipcounter], root, false )
for playeritem, key in pairs ( fraktionMembers[10] ) do
setElementVisibleTo ( blips[blipcounter], playeritem, true )
end
setElementParent ( blips[blipcounter], vehobj[dataplace] )
end
elseif array.typ == "fire" then
createPedForFire ( array.posX, array.posY, array.posZ, nil, array.soundpath, array.volume )
end
end
local x, y, z = actiondatas[action][actiondatas.place][1].posX, actiondatas[action][actiondatas.place][1].posY, actiondatas[action][actiondatas.place][1].posZ
if action == "fire" then
outputChatBox ( "[FEUER] Achtung: Ein Brand wurde ausgelöst! Ort: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ), root, 200, 0, 0 )
--outputDebugString ( "[FEUER] Achtung: Ein Brand wurde ausgelöst! Ort: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ).." - "..tostring ( x )..", "..tostring ( y )..", "..tostring ( z ) )
elseif action == "tree" then
outputChatBox ( "[BAUM] Achtung: Ein Baum ist umgefallen! Ort: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ), root, 200, 0, 0 )
--outputDebugString ( "[BAUM] Achtung: Ein Baum ist umgefallen! Ort: "..getZoneName ( x, y, z )..", "..getZoneName ( x, y, z, true ).." - "..tostring ( x )..", "..tostring ( y )..", "..tostring ( z ) )
end
triggerLatentClientEvent ( "startActionForFiremen", 30000, false, resourceRoot, pedhealth, action, sounddata, vehobj, firepeds )
actiontimer.stop = setTimer ( funcs.stopAction, type ( actioncometime ) == "table" and math.random ( actioncometime[1], actioncometime[2] ) or actioncometime, 1, true )
end
addEventHandler ( "extinguishFire", root, function ( ped )
for i=1, #firepeds do
if firepeds[i] == ped then
destroyElement ( ped )
table.remove ( firepeds, i )
break
end
end
if not firepeds[1] then
outputChatBox ( "[FEUER] Das Feuer konnte gelöscht werden!", root, 0, 200, 0 )
funcs.stopAction ( true )
end
end )
addEventHandler ( "cuttedFiremanTree", root, function ( tree )
for i=1, #vehobj do
if vehobj[i] == tree then
destroyElement ( tree )
table.remove ( vehobj, i )
break
end
end
if not vehobj[1] then
outputChatBox ( "[BAUM] Der Baum konnte entfernt werden!", root, 0, 200, 0 )
funcs.stopAction ( true )
end
end )
addEventHandler ( "onPlayerJoin", root, function ( )
if action then
triggerLatentClientEvent ( source, "startActionForFiremen", 30000, false, resourceRoot, pedhealth, action, sounddata, vehobj, firepeds )
end
end )
local function vioFiremanActionThings ( )
if fileExists ( "firemenactions.xml" ) then
local xml = xmlLoadFile ( "firemenactions.xml" )
local nodes = xmlNodeGetChildren ( xml )
if nodes and nodes[1] then
for i=1, #nodes do
local nodename = xmlNodeGetName ( nodes[i] )
if nodename == "settings" then
local actionstaynode = xmlFindChild ( nodes[i], "actionstaytime", 0 )
actionstaytime = actionstaynode and tonumber ( xmlNodeGetAttribute ( actionstaynode, "time" ) ) or 1800000
local actioncomenode = xmlFindChild ( nodes[i], "actioncometime", 0 )
local actioncometime2 = actioncomenode and xmlNodeGetAttribute ( actioncomenode, "time2", 0 ) or ""
actioncometime = actioncomenode and ( actioncometime2 ~= "" and { tonumber ( xmlNodeGetAttribute ( actioncomenode, "time1", 0 ) ), tonumber ( actioncometime2 ) } or tonumber ( xmlNodeGetAttribute ( actioncomenode, "time1", 0 ) ) ) or 3600000
local amountflamesatvehiclenode = xmlFindChild ( nodes[i], "amountflamesatvehicle", 0 )
local amountflamesatvehicle2 = amountflamesatvehiclenode and xmlNodeGetAttribute ( amountflamesatvehiclenode, "amount2", 0 ) or ""
amountflamesatvehicle = amountflamesatvehiclenode and ( amountflamesatvehicle2 ~= "" and { tonumber ( xmlNodeGetAttribute ( amountflamesatvehiclenode, "amount1", 0 ) ), tonumber ( amountflamesatvehicle2 ) } or tonumber ( xmlNodeGetAttribute ( amountflamesatvehiclenode, "amount1", 0 ) ) ) or 3600000
local pedhealthnode = xmlFindChild ( nodes[i], "actioncometime", 0 )
local pedhealth2 = pedhealthnode and xmlNodeGetAttribute ( pedhealthnode, "amount2", 0 ) or ""
pedhealth = pedhealthnode and ( pedhealth2 ~= "" and { tonumber ( xmlNodeGetAttribute ( pedhealthnode, "amount1", 0 ) ), tonumber ( pedhealth2 ) } or tonumber ( xmlNodeGetAttribute ( pedhealthnode, "amount1", 0 ) ) ) or 90
local treehealthnode = xmlFindChild ( nodes[i], "actioncometime", 0 )
local treehealth2 = treehealthnode and xmlNodeGetAttribute ( treehealthnode, "amount2", 0 ) or ""
treehealth = treehealthnode and ( treehealth2 ~= "" and { tonumber ( xmlNodeGetAttribute ( treehealthnode, "amount1", 0 ) ), tonumber ( treehealth2 ) } or tonumber ( xmlNodeGetAttribute ( treehealthnode, "amount1", 0 ) ) ) or 90
else
if not actiondatas[nodename] then
actiondatas[nodename] = {}
end
actiondatas.list[#actiondatas.list+1] = nodename
local actionnodes = xmlNodeGetChildren ( nodes[i] )
if actionnodes and actionnodes[1] then
for i=1, #actionnodes do
local place = #actiondatas[nodename]+1
actiondatas[nodename][place] = {}
local actionthings = xmlNodeGetChildren ( actionnodes[i] )
if actionthings and actionthings[1] then
for i=1, #actionthings do
local name = xmlNodeGetName ( actionthings[i] )
local dataplace = #actiondatas[nodename][place] + 1
actiondatas[nodename][place][dataplace] = {
typ = name,
posX = tonumber ( xmlNodeGetAttribute ( actionthings[i], "posX" ) ),
posY = tonumber ( xmlNodeGetAttribute ( actionthings[i], "posY" ) ),
posZ = tonumber ( xmlNodeGetAttribute ( actionthings[i], "posZ" ) ),
volume = tonumber ( xmlNodeGetAttribute ( actionthings[i], "volume" ) ),
soundpath = xmlNodeGetAttribute ( actionthings[i], "soundpath" ),
}
if name == "vehicle" then
actiondatas[nodename][place][dataplace].model = tonumber ( xmlNodeGetAttribute ( actionthings[i], "model" ) )
actiondatas[nodename][place][dataplace].rotX = tonumber ( xmlNodeGetAttribute ( actionthings[i], "rotX" ) ) or 0
actiondatas[nodename][place][dataplace].rotY = tonumber ( xmlNodeGetAttribute ( actionthings[i], "rotY" ) ) or 0
actiondatas[nodename][place][dataplace].rotZ = tonumber ( xmlNodeGetAttribute ( actionthings[i], "rotZ" ) ) or 0
actiondatas[nodename][place][dataplace].r = tonumber ( xmlNodeGetAttribute ( actionthings[i], "r" ) ) or 0
actiondatas[nodename][place][dataplace].g = tonumber ( xmlNodeGetAttribute ( actionthings[i], "g" ) ) or 0
actiondatas[nodename][place][dataplace].b = tonumber ( xmlNodeGetAttribute ( actionthings[i], "b" ) ) or 0
elseif name == "object" then
actiondatas[nodename][place][dataplace].model = tonumber ( xmlNodeGetAttribute ( actionthings[i], "model" ) )
actiondatas[nodename][place][dataplace].rotX = tonumber ( xmlNodeGetAttribute ( actionthings[i], "rotX" ) ) or 0
actiondatas[nodename][place][dataplace].rotY = tonumber ( xmlNodeGetAttribute ( actionthings[i], "rotY" ) ) or 0
actiondatas[nodename][place][dataplace].rotZ = tonumber ( xmlNodeGetAttribute ( actionthings[i], "rotZ" ) ) or 0
actiondatas[nodename][place][dataplace].scale = tonumber ( xmlNodeGetAttribute ( actionthings[i], "scale" ) ) or 1
end
end
end
end
end
end
end
setTimer ( funcs.startAction, type ( actioncometime ) == "table" and math.random ( actioncometime[1], actioncometime[2] ) or actioncometime, 1 )
end
xmlUnloadFile ( xml )
end
end
addCommandHandler ( "reloadexml", vioFiremanActionThings, true )
addEventHandler ( "onResourceStart", resourceRoot, vioFiremanActionThings )
addCommandHandler ( "feuerstart321", funcs.startAction )
Alles anzeigen