India Posted February 7, 2021 Share Posted February 7, 2021 Hello, I get this error when, im in Area 51 radar room and when i shot, this error given BUT No problem when i shot outside, i think it gives an error because it could not determine the exact location. ERROR: clientside element 'ped' at argument 3 @'TriggerServerEvent' error line: triggerServerEvent ('zombieHeared'), localPlayer, zomb ) client.lua function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if getElementData ( localPlayer, "isPlayerZombie" ) then return true end if shotCheckAvailable then if weapon > 9 and weapon ~= 23 then shotCheckAvailable = false setTimer ( function () shotCheckAvailable = true end, 4000, 1 ) local zombs = getElementsByType ( "ped", getRootElement(), true ) local x,y,z = getElementPosition ( localPlayer ) for i,zomb in ipairs(zombs) do if not getElementData ( zomb, "target" ) and not getElementData ( zomb, "zHeared" ) then local zx,zy,zz = getElementPosition (zomb) if getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) < 50 then triggerServerEvent ("zombieHeared", localPlayer, zomb ) end end end end end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) server.lua fast_blood = 12000 -- Hızlı zombi kan sold_blood = 12000 -- asker kan zomb_blood = 12000 -- Normal zombiler kan sold_damage = 12000 -- Bitti hızlı zombiler fast_damage = 12000 -- Bitti asker zomb_damage = 12000 -- Bitti zamanki zombiler function chasedStartAttack (zomb) if isElement ( zomb ) and not getElementData ( zomb, "target" ) then if getElementData ( zomb, "zHeared" ) then setElementData ( zomb, "zHeared", false ) end setElementSyncer ( zomb, source ) setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) exports.npc_hlc:addNPCTask ( zomb, {"killPed", source, 2, 2} ) setElementData ( zomb, "target", source ) end end addEvent( "chasedStartAttackC", true ) addEventHandler( "chasedStartAttackC", getRootElement(), chasedStartAttack ) function spawnNewZombie(x, y, z, creator, ztype, skin) local zomb = createPed(skin,x,y,z+0.5,math.random(0,360),true) setElementData(zomb,"spawn_x",x) setElementData(zomb,"spawn_y",y) setElementData(zomb,"spawn_z",z) setElementData(zomb,"spawn_ztype",ztype) setElementData(zomb,"spawn_skin",skin) if isElement ( zomb ) then if not isElementInWater ( zomb ) then setTimer ( activateZombie, 1000, 1, zomb, x, y, z, ztype ) setElementData ( zomb, "creator", creator ) return true else destroyElement ( zomb ) return false end end return false end function activateZombie (zomb, x, y, z, ztype) if isElement ( zomb ) then local zSphere = createColSphere ( x, y, z, 50 ) local zSphereFar = createColSphere ( x, y, z, 150 ) local zSphereNear = createColSphere ( x, y, z, 3 ) attachElements ( zSphere, zomb ) attachElements ( zSphereFar, zomb ) attachElements ( zSphereNear, zomb ) setElementData ( zSphere, 'shapeZomb', true ) setElementData ( zSphereFar, 'shapeZomb', true ) setElementData ( zSphereNear, 'shapeZomb', true ) setElementData ( zomb, "zombieShape", zSphere ) setElementData ( zSphere, "zombieShape", true ) setElementData ( zSphere, "zombieElement", zomb ) setElementData ( zomb, "shapeFar", zSphereFar ) setElementData ( zomb, "shapeNear", zSphereNear ) setElementData ( zSphereNear, "zShapeNear", true ) if ztype == 3 then setElementData ( zomb, "soldier", true ) setElementData(zomb, "blood", sold_blood) setElementData(zomb, "damage", sold_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 2 then setElementData(zomb, "blood", fast_blood) setElementData ( zomb, "fast", true ) setElementData(zomb, "damage", fast_damage) setElementData(zomb, "speed", "run") else setElementData(zomb, "blood", zomb_blood) setElementData(zomb, "damage", zomb_damage) setElementData(zomb, "speed", "run") end setElementData ( zomb, "zombie", true ) wentZombieToWalk ( zomb ) end end function wentZombieToWalk ( zomb ) if zomb then if isElement ( zomb ) then if not isPedDead ( zomb ) then if checkPlayersInView ( zomb ) then if not getElementData ( zomb, "target" ) and not getElementData ( zomb, 'rotating' ) then local rdmangle = math.random( 1, 359 ) setPedRotation( zomb, rdmangle ) setPedAnimation ( zomb, "PED", "WALK_fatold", -1, true, true, true) setTimer ( wentZombieToWalk, 7000, 1, zomb ) end else if isElement ( getElementData ( zomb, "zombieShape" ) ) then destroyElement ( getElementData ( zomb, "zombieShape" ) ) end if isElement ( getElementData ( zomb, "shapeFar" ) ) then destroyElement ( getElementData ( zomb, "shapeFar" ) ) end if isElement ( getElementData ( zomb, "shapeNear" ) ) then destroyElement ( getElementData ( zomb, "shapeNear" ) ) end local attaches = getAttachedElements ( zomb ) if attaches then for ElementKey, ElementValue in ipairs ( attaches ) do if isElement ( ElementValue ) then if not getElementData ( ElementValue, "zRadZone" ) then destroyElement ( ElementValue ) end end end end local creator = getElementData ( zomb, "creator" ) if isElement ( creator ) then setElementData ( creator, "spawnedzombies", ( getElementData ( creator, "spawnedzombies" ) or 1 ) - 1 ) end setElementData ( zomb, "target", false ) setElementData ( zomb, "rotating", nil ) if not getElementData ( zomb, "target" ) and not getElementData ( zomb, 'rotating' ) then local rdmangle = math.random( 1, 359 ) setPedRotation( zomb, rdmangle ) setPedAnimation ( zomb, "PED", "WALK_fatold", -1, true, true, true) setTimer ( wentZombieToWalk, 7000, 1, zomb ) end end end end end end function checkPlayersInView ( zomb ) local shapeFar = getElementData ( zomb, "shapeFar" ) if isElement(shapeFar) then if #getElementsWithinColShape ( shapeFar, 'player' ) == 0 then return false else return true end end end function zombieKilledPlayer (task) if getElementData ( source, "zombie" ) then if task[1] == "walkToPos" then if getElementData ( source, "rotating" ) then setElementRotation ( source, 0, 0, task[6] ) setTimer ( function ( zomb ) if isElement ( zomb ) then setElementData ( zomb, "rotating", false ); wentZombieToWalk ( zomb ) end end, 3000, 1, source ) end end if getElementData ( source, "target" ) then local diedPlayer = task[2] setElementData ( source, "target", nil ) wentZombieToWalk ( source ) end end end addEventHandler ( "npc_hlc:onNPCTaskDone", root, zombieKilledPlayer ) --function resetPlayerZombies(killer, headshot) --if not headshot and not getElementData ( source, "diedOfSick" ) then --local x,y,z = getElementPosition ( source ) --spawnNewZombie ( x, y, z, nil ) --end --end --addEvent("kilLDayZPlayer",true) --addEventHandler("kilLDayZPlayer",getRootElement(),resetPlayerZombies) function killPlayerOfSick() for i, v in ipairs ( getElementsByType ("ped")) do if getElementData ( v, "zombie" ) then local target = getElementData ( v, "target" ) if target and target == source then setElementData ( v, "target", false ) exports.npc_hlc:clearNPCTasks(v) setTimer ( wentZombieToWalk, 3000, 1, v ) end end end end addEvent("killPlayerOfSick",true) addEventHandler("killPlayerOfSick",getRootElement(),killPlayerOfSick) function checkUnactiveZombies () for i, v in ipairs ( getElementsByType ("ped")) do if getElementData ( v, "zombie" ) then local target = getElementData ( v, "target" ) if target and not isElement ( target ) then setElementData ( v, "target", false ) wentZombieToWalk ( v ) end end end end setTimer (checkUnactiveZombies,600000,0) function zombieWasAttackedS ( zomb ) if not isPedDead ( zomb ) and not getElementData ( source, "isPlayerZombie" ) then setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) exports.npc_hlc:addNPCTask ( zomb, {"killPed", source, 2, 2} ) setElementData ( zomb, "target", source ) setTimer ( wentZombieToWalk, 1000, 1, zomb ) end end addEvent( "zombieWasAttacked", true ) addEventHandler( "zombieWasAttacked", getRootElement(), zombieWasAttackedS ) function zombieHearedS ( zomb ) if isElement ( zomb ) then if not isPedDead ( zomb ) then if not getElementData ( zomb, "target" ) and not getElementData ( source, "zHeared" ) and not getElementData ( source, "isPlayerZombie" ) then setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) setElementData ( zomb, "zHeared", source ) local x,y,z = getElementPosition ( source ) exports.npc_hlc:addNPCTask ( zomb, {"walkToPos", x, y, z, 2}) end end end end addEvent( "zombieHeared", true ) addEventHandler( "zombieHeared", getRootElement(), zombieHearedS ) function killPlayerOfSick () for i, v in ipairs ( getElementsByType ("ped")) do if getElementData ( v, "zombie" ) then local target = getElementData ( v, "target" ) if target and target == source then setElementData ( v, "target", false ) setTimer ( wentZombieToWalk, 3000, 1, v ) end end end end addEvent( "killPlayerOfSick", true ) addEventHandler( "killPlayerOfSick", getRootElement(), killPlayerOfSick ) function rotateZombieToPlayer ( rotation, x, y, z ) if not isPedDead ( source ) then if not getElementData ( source, "target" ) then setPedAnimation ( source ) if not exports.npc_hlc:isHLCEnabled ( source ) then exports.npc_hlc:enableHLCForNPC( source, getElementData ( source,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (source) exports.npc_hlc:addNPCTask ( source, {"walkToPos", x, y, z, 1, rotation}) end end end addEvent( "rotateZombieToPlayer", true ) addEventHandler( "rotateZombieToPlayer", getRootElement(), rotateZombieToPlayer ) function zombieNearLeave ( thePlayer ) if (getElementType(thePlayer) or false) == "player" and getElementData ( source, "zombieShape" ) then local zomb = getElementData ( source, "zombieElement" ) if isElement ( zomb ) and exports.npc_hlc:isHLCEnabled ( zomb ) then if getElementData ( zomb, "fast" ) then return true end local thistask = getElementData(zomb,"npc_hlc:thistask") if thistask then local task = getElementData(zomb,"npc_hlc:task."..thistask) if task then if task[1] == "killPed" and isElement ( task[2] ) then if task[2] == thePlayer then exports.npc_hlc:clearNPCTasks (zomb) setElementData(zomb,"target",false) wentZombieToWalk(zomb) end end end end end end end addEventHandler ( "onColShapeLeave", root, zombieNearLeave ) Link to comment
Furzy Posted February 7, 2021 Share Posted February 7, 2021 Yes, looks that ped cant determine where is the player. Simple solution: Create a big marker inside radar room and with isElementWithinMarker you dont execute zombieHeared event. 1 Link to comment
Moderators IIYAMA Posted February 7, 2021 Moderators Share Posted February 7, 2021 9 minutes ago, India said: ERROR: clientside element 'ped' at argument 3 @'TriggerServerEvent' if getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) < 50 and not isElementLocal (zomb) then I guess it is because the ped is created clientside. I haven't seen this error before to be honest. 1 Link to comment
Furzy Posted February 7, 2021 Share Posted February 7, 2021 1 minute ago, IIYAMA said: if getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) < 50 and not isElementLocal (zomb) then I guess it is because the ped is created clientside. I haven't seen this error before to be honest. I use the same script for zombies and i dont get this error too. 2 Link to comment
India Posted February 7, 2021 Author Share Posted February 7, 2021 1 hour ago, Furzy said: Yes, looks that ped cant determine where is the player. Simple solution: Create a big marker inside radar room and with isElementWithinMarker you dont execute zombieHeared event. It's not just something that is in the area 51, it can fail anywhere underground. I can't put markers everywhere, but thanks for your idea. if getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) < 50 and not isElementLocal (zomb) then This solved my problem 2 Link to comment
Moderators IIYAMA Posted February 7, 2021 Moderators Share Posted February 7, 2021 (edited) 21 minutes ago, Furzy said: I use the same script for zombies and i dont get this error too. It is not the zombie resource alone that causes the error. Another resource is making clientside peds, this combination will make it possible for the error to appear. If you do not have clientside created peds in your server, then you will not be able to get this error. Edited February 7, 2021 by IIYAMA 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now