Jump to content

Erro server para client


Recommended Posts

Boa noite precisava de uma ajuda que to em fretando em alguns scripts fica dando esse erro direto no meu servidor 

 

but event is not added client side

 

nesta função Client

addEvent( "Zomb_STFU", true )
addEventHandler( "Zomb_STFU", getRootElement(),function ( ped )
    if (isElement(ped)) then
        setPedVoice(ped, "PED_TYPE_DISABLED")
    end
end)

 

Que vai pra essa linha no server

 

zombiesaliveee = 0  -- Current Zombies alive
function createZomieForPlayer (x,y,z)
   x,y,z = getElementPosition(source)
   counter = 0
    if getElementData(source,"lastzombiespawnposition") then
        local xL,yL,zL = getElementData(source,"lastzombiespawnposition")[1] or false,getElementData(source,"lastzombiespawnposition")[2] or false,getElementData(source,"lastzombiespawnposition")[3] or false
        if xL then
            if getDistanceBetweenPoints3D (x,y,z,xL,yL,zL) < 20 then
                return
            end
        end
    end  
    if getElementData(source, "spawnedzombies") + 3 <= gameplayVariables["playerzombies"] then -- If spawned zombies + 3 lower or equal to 9 -> Create zombies -> Increase digit (default: 9) to let more zombies spawn. WARNING: THE HIGHER THE VALUE, THE MORE LAG CAN OCCUR!
        for i = 1, gameplayVariables["amountzombies"] do --Amount of zombies to be spawned (default: 3) WARNING: THE HIGHER THE VALUE, THE MORE LAG CAN OCCUR!
            counter = counter+1
            local number1 = math.random(-49,40)
            local number2 = math.random(-38,42)
            randomZskin = math.random ( 1, table.getn ( ZombiePedSkins ) ) 
            local zombie = createPed ( tonumber( ZombiePedSkins[randomZskin] ),x+number1, y+number2,z, math.random(0, 360))
            local Zx, Zy, Zz = getElementPosition( zombie )
            setElementData(zombie,"zombie",true)
            setElementData(zombie,"bloodZumbie",gameplayVariables["zombieblood"]) -- [ID:0000009 - Zombie menace] //L
            setElementData(zombie,"owner",source)
            if not rot then rot = math.random (1,359) end
            if not interior then interior = 0 end
            if not dimension then dimension = 0 end
            setTimer ( setElementInterior, 100, 1, zombie, tonumber(interior)) --sets interior
            setTimer ( setElementDimension, 100, 1, zombie, tonumber(dimension)) --sets dimension
            setElementData ( zombie, "zombie", true  )
            setElementData ( zombie, "forcedtoexist", true  )
            setTimer ( function (zombie, rot) if ( isElement ( zombie ) ) then setPedRotation ( zombie, rot ) end end, 500, 1, zombie, rot )
            setTimer ( function (zombie) if ( isElement ( zombie ) ) then setElementData ( zombie, "status", "idle" ) end end, 2000, 1, zombie )
            setTimer ( function (zombie) if ( isElement ( zombie ) ) then setElementData ( zombie, "forcedtoexist", true ) end end, 1000, 1, zombie )
            setTimer ( function (zombie) if ( isElement ( zombie ) ) then table.insert( everyZombie, zombie ) end end, 1000, 1, zombie )
            triggerClientEvent ( "Zomb_STFU", getRootElement(), zombie )   ---- AQUI O AVISOOOOO
        end
        setElementData(source,"lastzombiespawnposition",{x,y,z})
        setElementData(source,"spawnedzombies",getElementData(source,"spawnedzombies")+3)
        zombiesaliveee = zombiesaliveee + 3
    end
end
addEvent("createZomieForPlayer",true)
addEventHandler("createZomieForPlayer",getRootElement(),createZomieForPlayer)

 

Link to comment

Isso pode acontecer em 2 ocasiões mais comuns.

1. O código pode estar com algum erro no lado server/client.

2. Quando o evento é chamado pelo server ele é não é reconhecido pois pode ter algum erro ou o mais comum que é o server carregar antes do client informando esse erro no debug.

--

A solução é colocar dentro de um timer ou se tiver algum problema achar e corrigi-lo mas como acredito que seu código não tem erros é a segunda opção.

 

 

Link to comment
  • Moderators

A função 'createZomieForPlayer' é chamada quando? Se for no evento "onResourceStart" é esse o motivo do aviso. O código do lado server carrega antes do cliente, e quando utiliza triggerClientEvent assim que o lado server inicia ocorre esse tipo de erro. Isso também pode ser por algum erro no lado cliente como já foi falado.

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