Jump to content

erro then?


Recommended Posts

ola, estava criando um script de missão estilo resident evil 4. criei um bot(ashley) e quero que ela siga o jogador que é considerado leon.

local AllPlayers = getElementsByType ( "player" ) 
    for _, player in ipairs ( AllPlayers ) do 
if (getElementModel ( player ) == 284 ) then 
if (getPlayerTeam ( player ) == RPD ) 
exports [ "slothBot" ]:setBotFollow( Ashley, player ) 
end 
end 
end 

acredito que seja um erro bobo meu.

obrigado pela atenção

Link to comment

O própiro nome do tópico já diz o que falta. Está faltando 'then' na condição da linha 4 do código.

De qualquer forma, você pode usar isso:

local AllPlayers = getElementsByType ("player") 
    for _, player in ipairs (AllPlayers) do 
        if (getElementModel(player) == 284) and (getPlayerTeam(player) == RPD) then 
            exports[ "slothBot" ]:setBotFollow(Ashley, player) 
        end 
    end 

Se RPD Não for uma equipe criada no mesmo código, use getTeamFromName("RPD").

Link to comment

bom ainda não terminei o script(por causa desse erro)

CLIENT

-- by manawydan-- 
  
-- janela 
  
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        JanelaMissao = guiCreateWindow(459, 246, 308, 285, "by manawydan", false) 
        guiWindowSetSizable(JanelaMissao, false) 
        guiSetAlpha(JanelaMissao, 0.68) 
        guiSetVisible(JanelaMissao, false) 
  
        Texto1 = guiCreateMemo(9, 24, 290, 51, "A FILHA DO PRESIDENTE FOI RAPITADA. SUA MISSAO? SALVA-LA. BOA SORTE!", false, JanelaMissao) 
        AshleyFoto = guiCreateStaticImage(9, 86, 64, 64, "ashley_photo.png", false, JanelaMissao) 
        Texto2 = guiCreateMemo(78, 154, 220, 39, "RECOMPENSA: ARMAS E DINHEIRO", false, JanelaMissao) 
        BotaoAceito = guiCreateButton(9, 238, 69, 38, "ACEITO", false, JanelaMissao) 
        BotaoCancel = guiCreateButton(214, 237, 69, 38, "CANCEL", false, JanelaMissao)  
addEventHandler("onClientGUIClick", BotaoAceito, PressionarBotao)    
addEventHandler("onClientGUIClick", BotaoCancel, PressionarBotao)  
    end 
) 
  
function PressionarBotao(button, state) 
  
    if (button == "left") then 
if(source == BotaoAceito) then 
            triggerServerEvent("MissaoP1", root) 
guiSetVisible(JanelaMissao, false) 
        showCursor(false) 
        elseif(source == BotaoCancel) then 
            guiSetVisible(JanelaMissao, false) 
        showCursor(false) 
end 
end 
end      
  
  
  
  
addEvent ( "verGuiMissao", true ) 
addEventHandler ( "verGuiMissao", root, 
    function ( ) 
guiSetVisible(JanelaMissao, true) 
        showCursor(true) 
    end 
) 
  
addEvent ( "NaoverGuiMissao", true ) 
addEventHandler ( "NaoverGuiMissao", root, 
    function ( ) 
guiSetVisible(JanelaMissao, false) 
        showCursor(false) 
    end 
) 
  

SERVER

-- by MANAWYDAN-- 
--time 
 createTeam("RPD", 0, 100, 150) 
RPD = getTeamFromName ( "RPD" ) 
--ashley 
 Ashley = exports [ "slothBot" ]:spawnBot ( -772.39703369141, 2423.974609375, 157.08949279785, 90,  math.random ( 300, 303 ), 0, 0, RPD, 0,         "hunting", true ) 
setElementModel(Ashley, 257) 
exports [ "slothBot" ]:setBotAttackEnabled(Ashley, false) 
setElementData(Ashley, "Ashley",true)-- necessario?-- 
  
  
-- marcadores 
local MarcadorMissao = createMarker ( 1553.3884277344, -1675.2432861328, 15.2543125, "cylinder", 1.5, 2, 25, 200, 170 ) 
local  MarcadorMissao2 = createMarker ( -374.21533203125, 2322.4465332031, 31.759742736816, "cylinder", 1.5, 2, 25, 200, 170 ) 
local  MarcadorMissao3 = createMarker ( -775.29901123047, 2422.8540039063, 156.00520935059, "cylinder", 1.5, 2, 25, 200, 170 ) 
  
function EntrarNoMarcadorMissao( hitElement) 
if getElementType ( hitElement ) == "player" then 
if getElementModel ( hitElement ) == 284 then 
triggerClientEvent ( "verGuiMissao", root ) 
setElementData(hitElement, "Leon",true) 
setPlayerTeam ( hitElement, RPD ) 
destroyElement(MarcadorMissao) 
end 
end 
end 
addEventHandler( "onMarkerHit", MarcadorMissao, EntrarNoMarcadorMissao )  
  
function EntrarNoMarcadorMissao2( hitElement) 
if getElementType ( hitElement ) == "player" then 
if getElementModel ( hitElement ) == 284 then 
if getElementData(hitElement, "Leon") then 
outputChatBox("Presidente: leon resgate minha filha, ela esta emcima do morro, uma agente especial te espera!", hitElement, 0, 125, 200) 
destroyElement(MarcadorMissao2) 
triggerEvent("ZombiesLasBrujas", root ) 
setElementData ( hitElement, "leader", true ) 
end 
end 
end 
end 
addEventHandler( "onMarkerHit", MarcadorMissao2, EntrarNoMarcadorMissao2 )  
  
function EntrarNoMarcadorMissao3( hitElement) 
if getElementType ( hitElement ) == "player" then 
if getElementModel ( hitElement ) == 284 then 
if getElementData(hitElement, "Leon") then 
triggerEvent("MissaoP3", root ) 
outputChatBox("Ada: você deve ser leon entre no helicoptero!", hitElement, 0, 120, 200) 
destroyElement(MarcadorMissao3) 
end 
end 
end 
end 
addEventHandler( "onMarkerHit", MarcadorMissao3, EntrarNoMarcadorMissao3 )  
  
addEvent ( "MissaoP1", true ) 
addEventHandler ( "MissaoP1", root, 
    function ( ) 
PatriotMissao = createVehicle(470, 1558.8189697266, -1624.6198730469, 13.505779266357) 
outputChatBox("Presidente: leon pegue o patriot para fazer sua missao, e va para las brujas!", hitElement, 0, 125, 200) 
    end 
) 
  
addEvent ( "ZombiesLasBrujas", true ) 
addEventHandler ( "ZombiesLasBrujas", root, 
    function ( ) 
zumbie1 = exports [ "zombies" ]:createZombie(-398.50952148438, 2262.6394042969, 42.058856964111, 90, 70, 0, 0) 
zumbie2 = exports [ "zombies" ]:createZombie(-398.38272094727, 2245.2702636719, 47.534622192383, 90, 70, 0, 0) 
zumbie3 = exports [ "zombies" ]:createZombie(-381.86883544922, 2229.3969726563, 42.09375, 90, 84, 0, 0) 
zumbie4 = exports [ "zombies" ]:createZombie(-363.04089355469, 2227.2353515625, 42.484375, 90, 84, 0, 0) 
zumbie5 = exports [ "zombies" ]:createZombie(-331.83184814453, 2222.1301269531, 42.489109039307, 90, 105, 0, 0) 
zumbie6 = exports [ "zombies" ]:createZombie(-330.69683837891, 2213.5700683594, 42.484928131104, 90, 167, 0, 0) 
zumbie7 = exports [ "zombies" ]:createZombie(-354.18716430664, 2204.1984863281, 42.484375, 90, 264, 0, 0) 
zumbie8 = exports [ "zombies" ]:createZombie(-375.24328613281, 2202.8664550781, 43.058856964111, 90, 264, 0, 0) 
zumbie9 = exports [ "zombies" ]:createZombie(-422.16159057617, 2205.3933105469, 42.4296875, 90, 287, 0, 0) 
zumbie10 = exports [ "zombies" ]:createZombie(-431.77001953125, 2234.4045410156, 42.4296875, 90, 287, 0, 0) 
giveWeapon ( zumbie1, 6, 1) 
giveWeapon ( zumbie2, 6, 1) 
giveWeapon ( zumbie3, 9, 1) 
giveWeapon ( zumbie4, 9, 1) 
giveWeapon ( zumbie5, 5, 1) 
giveWeapon ( zumbie6, 5, 1) 
giveWeapon ( zumbie7, 4, 1) 
giveWeapon ( zumbie8, 4, 1) 
    end 
) 
  
addEvent ( "onBotFindEnemy", true ) 
addEventHandler ( "onBotFindEnemy", root, 
    function ( ) 
if (getElementModel ( source ) == 257 ) then 
cancelEvent() 
end 
end 
) 
  
addEvent ( "MissaoP3", true ) 
addEventHandler ( "MissaoP3", root, 
    function ( ) 
local Maverick = createVehicle(497, -799.13732910156, 2428.3779296875, 157.08525085449) 
Ada = exports [ "slothBot" ]:spawnBot ( -795.38226318359, 2423.7541503906, 157.08544921875, 90,  math.random ( 300, 303 ), 0, 0, RPD, 31,         "hunting", true ) 
warpPedIntoVehicle ( Ada, Maverick, 0 ) 
setElementModel(Ada, 263) 
setElementData(Ada, "Ada",true) 
    end 
) 
  
function Ashleyvehicle ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and getElementData ( thePlayer, "Leon", true ) ) and getElementData (Ashley, "Ashley", true) then 
        warpPedIntoVehicle ( Ashley, source, 3 ) 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), Ashleyvehicle ) 
  

Link to comment

Está fazendo o bot seguir com a função exportada? (Eu nunca usei o resource slothBot, não sei te indicar a função para ser usada).

DebugScript não mostra nenhum erro certo?

Você já criou a equipe no mesmo código, então não precisa usar getTeamFromName(), apenas defina a variavel na função createTeam e use ela.

Link to comment

neste caso o bot que se chama ashley esta no modo hunting(mata inimigos e segui jogadores ou ped do mesmo time), porém eu quero que ela apenas me siga, então tentei cancela o "ataque" dela com

addEvent ( "onBotFindEnemy", true ) 
addEventHandler ( "onBotFindEnemy", root, 
    function ( ) 
if (getElementModel ( source ) == 257 ) then 
cancelEvent() 
end 
end 
) 

onBotFindEnemy

This triggers when a bot locates an enemy, This event can be cancelled to prevent the bot from chasing players

Parameters

element enemy

enemy: The Player or Ped the bot has spotted

Source

The source of this event is the Bot that has found an enemy

também tentei cancela o ataque de outra forma

exports [ "slothBot" ]:setBotAttackEnabled(Ashley, false) 

setBotAttackEnabled

allow or disallow the bot to attack (press fire)

Syntax

bool setBotAttackEnabled( element theBot, bool enabled)

Required Arguments

theBot: The bot you want to set if it can atack

enabled: set to false to remove the bots ability to attack, true to allow it

mas, ela(o bot chamado ashley) continua atacando

Link to comment

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