Jump to content

[AJUDA]BadArgument@'SetPedWalkingStyle'[Expected element at argument 1, got nil]


Recommended Posts

local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1336), (screenH/768)
 
function dxMaconha()
  exports["Blur"]:dxDrawBluredRectangle(screenW * 0.0000, screenH * 0.0013, screenW * 1.0000, screenH * 0.9987, tocolor(255, 255, 255, 150))  
  dxDrawImage(screenW * 0.0000, screenH * 0.0013, screenW * 1.0000, screenH * 0.9987, "files/efeito.png", 0, 0, 0, tocolor(0, 254, 6, 255), false)
end
 
function UsarMaconha(player)
    sound = playSound( "files/reggae_music.mp3", true )
    addEventHandler ( "onClientRender", root, dxMaconha )
    setPedControlState(player, "walk", true)
    setWindVelocity(100, 100, 0)
    setCameraShakeLevel(255)
    setGameSpeed(0.5)
    setTimer(function()
        stopSound( sound )
        resetWindVelocity()
        setCameraShakeLevel(1)
        setGameSpeed(1)
        removeEventHandler ( "onClientRender", root, dxMaconha )
    end,player*4000,1)
end
addEvent("TB:UsarMaconha", true)
addEventHandler ("TB:UsarMaconha", root, UsarMaconha )
 
function onClientResourceStart()
  setPedWalkingStyle(player, 0)
  stopSound( sound )
  resetWindVelocity()
  setCameraShakeLevel(1)
  setGameSpeed(1)
  removeEventHandler ( "onClientRender", root, dxMaconha )
end
addEventHandler("onClientResourceStart",resourceRoot, onClientResourceStart)
-- ERROS
-- [RPINV]\CzInventory\cTeoBeack.lua30: Bad Argument @'SetPedWalkingStyle' [Expected element at argument 1, got nil]
Link to comment

hey welcome @Bigjhow the forum-site,The answer to your question is very simple, you should use localPlayer instead of player,I fixed your code and I am sending it to you, if you have any other questions please open a new topic and wait I will help you,Don't forget to like my comment if your problem is solved....

 

function onClientResourceStart()
  setPedWalkingStyle(localPlayer, 0)-- localPlayer, not "player"
  stopSound( sound )
  resetWindVelocity()
  setCameraShakeLevel(1)
  setGameSpeed(1)
  removeEventHandler ( "onClientRender", root, dxMaconha )
end
addEventHandler("onClientResourceStart",resourceRoot, onClientResourceStart)

 

  • Thanks 1
Link to comment
2 hours ago, Bigjhow said:

 

O que você quer fazer com StopSound, a música não toca quando onClientResourceStart é executado, você também adicionou o evento (onClientResourceStart ) que pode causar um erro durante a execução, mostre-me o erro.

Edited by Shady1
Link to comment
5 minutes ago, Shady1 said:

Bom está dando o mesmo erro que estava dando no ''SetPedWalkingStyle'', só que agora está no ''stopSound'': badargument@'stopSound'[expected element at argument 1, got nil] , E estou preso já que ainda estou aprendendo sobre algumas funções.

local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1336), (screenH/768)


function dxMaconha()
  exports["Blur"]:dxDrawBluredRectangle(screenW * 0.0000, screenH * 0.0013, screenW * 1.0000, screenH * 0.9987, tocolor(255, 255, 255, 150))	
  dxDrawImage(screenW * 0.0000, screenH * 0.0013, screenW * 1.0000, screenH * 0.9987, "files/efeito.png", 0, 0, 0, tocolor(0, 254, 6, 255), false)
end

function UsarMaconha(player)
    sound = playSound( "files/reggae_music.mp3", true )
    addEventHandler ( "onClientRender", root, dxMaconha )
    setPedControlState(player, "walk", true)
    setWindVelocity(100, 100, 0)
    setCameraShakeLevel(255)
    setGameSpeed(0.5)
    setTimer(function()
        stopSound( sound )
        resetWindVelocity()
        setCameraShakeLevel(1)
        setGameSpeed(1)
        removeEventHandler ( "onClientRender", root, dxMaconha )
    end,player*4000,1)
end
addEvent("TB:UsarMaconha", true)
addEventHandler ("TB:UsarMaconha", root, UsarMaconha )

function onClientResourceStart () 
  setPedWalkingStyle ( localPlayer , 0 ) -- localPlayer, não "player" 
  stopSound ( som ) 
  resetWindVelocity () 
  setCameraShakeLevel ( 1 ) 
  setGameSpeed ( 1 ) 
  removeEventHandler ( "onClientRender" , root , dxMaconha ) end 
addEventHandler ( "onClientResourceStart" , resourceRoot , onClientResourceStart ) 
Link to comment
11 minutes ago, Bigjhow said:
local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1336), (screenH/768)


function dxMaconha()
  exports["Blur"]:dxDrawBluredRectangle(screenW * 0.0000, screenH * 0.0013, screenW * 1.0000, screenH * 0.9987, tocolor(255, 255, 255, 150))	
  dxDrawImage(screenW * 0.0000, screenH * 0.0013, screenW * 1.0000, screenH * 0.9987, "files/efeito.png", 0, 0, 0, tocolor(0, 254, 6, 255), false)
end

function UsarMaconha(player)
    sound = playSound( "files/reggae_music.mp3", true )
    addEventHandler ( "onClientRender", root, dxMaconha )
    setPedControlState(player, "walk", true)
    setWindVelocity(100, 100, 0)
    setCameraShakeLevel(255)
    setGameSpeed(0.5)
    setTimer(function()
        stopSound( sound )
        resetWindVelocity()
        setCameraShakeLevel(1)
        setGameSpeed(1)
        removeEventHandler ( "onClientRender", root, dxMaconha )
    end,player*4000,1)
end
addEvent("TB:UsarMaconha", true)
addEventHandler ("TB:UsarMaconha", root, UsarMaconha )

function onClientResourceStart () 
  setPedWalkingStyle ( localPlayer , 0 ) -- localPlayer, não "player" 
  stopSound ( som ) 
  resetWindVelocity () 
  setCameraShakeLevel ( 1 ) 
  setGameSpeed ( 1 ) 
  removeEventHandler ( "onClientRender" , root , dxMaconha ) end 
addEventHandler ( "onClientResourceStart" , resourceRoot , onClientResourceStart ) 

aqui dentro do evento TB:UsarMaconha "sound = playSound( "files/reggae_music.mp3", true )" onClientResourceStart é o evento mais extremo, tudo começa aqui,se ele executar esse evento antes.
Não é possível.
o som pode não estar tocando,se o objeto sonoro não ocorreu,dá nil,porque esse momento não ocorreu.
se você quiser suprimir este erro,Adicione isso :

 

function onClientResourceStart () 
  setPedWalkingStyle (localPlayer , 0 ) -- localPlayer, não "player" 
  if(isElement(sound)) then stopSound(sound)  end -- verifique o som se existir e pare
  resetWindVelocity() 
  setCameraShakeLevel(1) 
  setGameSpeed (1) 
  removeEventHandler("onClientRender" , root , dxMaconha) end 
addEventHandler ("onClientResourceStart" , resourceRoot , onClientResourceStart)

verifique com isElement

se eu te ajudei com sucesso, por favor mencione e você pode curtir meu comentário

  • Thanks 1
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...