Jump to content

Help-me ped not dead


Estevam2d

Recommended Posts

Posted

I have this script enemy of the problem that the ped does not die for nothing.

I spent my ammo on him and he does not suffer any damage.

Could anyone help me.

Sorry bad English

local Exercito  = getTeamFromName ( "Exercito" ) 
  
function Exercitosobymanawydan ( thePlayer)  
local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then 
       nemesi = exports [ "slothBot" ]:spawnBot ( 103.65139007568,1902.8734130859,33.8984375, 90,  math.random ( 300, 303 ), 0, 0, Exercito, 34,         "guarding", true ) 
      setElementModel ( nemesi, 287 ) 
BlipExercito = createBlipAttachedTo ( nemesi, 0, 2, 11, 86, 16, 255, 1) 
      triggerClientEvent ( "nsound", root )     
      setElementData(nemesi, "exercito",true) 
if nemesi then 
 exports.extra_health:setElementExtraHealth ( nemesi, 100 ) 
         end 
      end 
end 
addCommandHandler("exercito",  Exercitosobymanawydan)  
setTimer ( destroyElement, 3600000, 0, slothbot) 
  
addEvent("onBotWasted",true) 
addEventHandler("onBotWasted",getRootElement(), 
function (killer) 
if (source == nemesi) then 
givePlayerMoney(killer,math.random(4000,6000))  
outputChatBox ( getPlayerName ( killer ) .. " #081DBFmatou um soldado",getRootElement(), 255, 255, 255, true ) 
 exports.exp_system:addPlayerEXP ( killer, 600 )  
destroyElement(BlipExercito) 
end 
end) 
  
function SetAdmExercitoTeam(thePlayer) 
local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) )  
     if isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then  
setPlayerTeam ( thePlayer, Exercito ) 
end 
 end 
addCommandHandler("nemesiTeam",SetAdmExercitoTeam) 

  • Moderators
Posted

are you in the same team?

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

you haven't named your function at line 19 , here try this not sure if it would work

local Exercito  = getTeamFromName ( "Exercito" ) 
  
function Exercitosobymanawydan ( thePlayer) 
local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then 
       nemesi = exports [ "slothBot" ]:spawnBot ( 103.65139007568,1902.8734130859,33.8984375, 90,  math.random ( 300, 303 ), 0, 0, Exercito, 34,         "guarding", true ) 
      setElementModel ( nemesi, 287 ) 
BlipExercito = createBlipAttachedTo ( nemesi, 0, 2, 11, 86, 16, 255, 1) 
      triggerClientEvent ( "nsound", root )     
      setElementData(nemesi, "exercito",true) 
if nemesi then 
 exports.extra_health:setElementExtraHealth ( nemesi, 100 ) 
         end 
      end 
end 
addCommandHandler("exercito",  Exercitosobymanawydan) 
setTimer ( destroyElement, 3600000, 0, slothbot) 
  
function onplayerkill( ammo, killer, killerweapon, bodypart ) 
if (source == nemesi) then 
 if ( killer ) and ( killer ~= source ) then 
givePlayerMoney(killer,math.random(4000,6000)) 
outputChatBox ( getPlayerName ( killer ) .. " #081DBFmatou um soldado",getRootElement(), 255, 255, 255, true ) 
 exports.exp_system:addPlayerEXP ( killer, 600 ) 
destroyElement(BlipExercito) 
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) 
end 
end 
  
function SetAdmExercitoTeam(thePlayer) 
local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then 
setPlayerTeam ( thePlayer, Exercito ) 
end 
 end 
addCommandHandler("nemesiTeam",SetAdmExercitoTeam) 

EDIT: also mention your errors.

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

  • Moderators
Posted
you haven't named your function at line 19 , here try this not sure if it would work
local Exercito  = getTeamFromName ( "Exercito" ) 
  
function Exercitosobymanawydan ( thePlayer) 
local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then 
       nemesi = exports [ "slothBot" ]:spawnBot ( 103.65139007568,1902.8734130859,33.8984375, 90,  math.random ( 300, 303 ), 0, 0, Exercito, 34,         "guarding", true ) 
      setElementModel ( nemesi, 287 ) 
BlipExercito = createBlipAttachedTo ( nemesi, 0, 2, 11, 86, 16, 255, 1) 
      triggerClientEvent ( "nsound", root )     
      setElementData(nemesi, "exercito",true) 
if nemesi then 
 exports.extra_health:setElementExtraHealth ( nemesi, 100 ) 
         end 
      end 
end 
addCommandHandler("exercito",  Exercitosobymanawydan) 
setTimer ( destroyElement, 3600000, 0, slothbot) 
  
function onplayerkill( ammo, killer, killerweapon, bodypart ) 
if (source == nemesi) then 
 if ( killer ) and ( killer ~= source ) then 
givePlayerMoney(killer,math.random(4000,6000)) 
outputChatBox ( getPlayerName ( killer ) .. " #081DBFmatou um soldado",getRootElement(), 255, 255, 255, true ) 
 exports.exp_system:addPlayerEXP ( killer, 600 ) 
destroyElement(BlipExercito) 
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) 
end 
end 
  
function SetAdmExercitoTeam(thePlayer) 
local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then 
setPlayerTeam ( thePlayer, Exercito ) 
end 
 end 
addCommandHandler("nemesiTeam",SetAdmExercitoTeam) 

EDIT: also mention your errors.

you haven't named your function at line 19

wtf! O_o

A function is a value that needs to be stored at some place. He already put it inside his event handler.

A both all, that wasn't his problem at the first place.

His problem is this: (in slot bot)

addEventHandler("onClientPedDamage",root, 
-- check if same team, then cancel....... 
cancelEvent() 
end) 
  

But it seems slot bot doesn't get the right information, to do it's job.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

No the problem starts here, starts at you. A player can't kill a bot from the same team.

Try this:

local Exercito  = getTeamFromName ( "Exercito" ) 
if not Exercito then 
    Exercito = createTeam ( "Exercito",0, 255, 0) 
    for i=1,5 do 
        outputChatBox("failure to get Exercito team, so recreate the team.") 
    end 
end 
  
-- put the variables in to locals -- 
local nemesi,BlipExercito 
------------------------------------ 
  
function Exercitosobymanawydan ( thePlayer) 
    local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if AclNome and isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then 
        if nemesi and isElement(nemesi) then 
            destroyElement(nemesi) 
        end 
        if BlipExercito and isElement(BlipExercito) then 
            destroyElement(BlipExercito) 
        end 
        nemesi = exports [ "slothBot" ]:spawnBot ( 103.65139007568,1902.8734130859,33.8984375, 90,  287, 0, 0, Exercito, 34,         "guarding", true ) 
        --setElementModel ( nemesi, 287 ) --math.random ( 300, 303 ) 
        BlipExercito = createBlipAttachedTo ( nemesi, 0, 2, 11, 86, 16, 255, 1) 
         
        triggerClientEvent ( "nsound", root )     
        setElementData(nemesi, "exercito",true) 
        if nemesi then 
            exports.extra_health:setElementExtraHealth ( nemesi, 100 ) 
        end 
    end 
end 
addCommandHandler("exercito",  Exercitosobymanawydan) 
  
setTimer ( destroyElement, 3600000, 0, slothbot) -- wtf? 
  
addEvent("onBotWasted",true) 
addEventHandler("onBotWasted",getRootElement(), 
function (killer) 
    if (source == nemesi) and killer and getElementType(killer) == "player" then 
        givePlayerMoney(killer,math.random(4000,6000)) 
        outputChatBox ( getPlayerName ( killer ) .. " #081DBFmatou um soldado",getRootElement(), 255, 255, 255, true ) 
        exports.exp_system:addPlayerEXP ( killer, 600 ) 
        if BlipExercito and isElement(BlipExercito) then 
            destroyElement(BlipExercito) 
        end 
    end 
end) 
  
function SetAdmExercitoTeam(thePlayer) 
    local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if AclNome and isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then 
        setPlayerTeam ( thePlayer, Exercito ) 
    end 
end 
addCommandHandler("nemesiTeam",SetAdmExercitoTeam) 
  
local testTeam  = createTeam ( "testTeam",255, 0, 0) 
local function SetAdmTestTeam(thePlayer) 
    local AclNome = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if AclNome and isObjectInACLGroup ("user."..AclNome, aclGetGroup ( "Admin" ) ) then 
        setPlayerTeam ( thePlayer,testTeam) 
    end 
end 
addCommandHandler("testteam",SetAdmTestTeam) 

Write down /testteam before you start shooting at the ped. Not tested!

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

It will die, unless you made one of the stupid mistakes in your live.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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