Bigjhow Posted October 6, 2022 Share Posted October 6, 2022 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
Shady1 Posted October 6, 2022 Share Posted October 6, 2022 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) 1 Link to comment
Bigjhow Posted October 6, 2022 Author Share Posted October 6, 2022 11 minutes ago, Shady1 said: OBRIGADO ME AJUDOU MUITO, ENTRETANTO O ERRO FOI PARA O ''StopSound ( som ) no caso o argumento que tenho que por nele também é relativamente algo relacionado ao ''local''?? Link to comment
Moderators Vinyard Posted October 6, 2022 Moderators Share Posted October 6, 2022 Moving this to Portuguese scripting section so you can get better help in your native language. 1 Link to comment
Shady1 Posted October 6, 2022 Share Posted October 6, 2022 (edited) 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 October 6, 2022 by Shady1 Link to comment
Bigjhow Posted October 6, 2022 Author Share Posted October 6, 2022 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
Shady1 Posted October 6, 2022 Share Posted October 6, 2022 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 1 Link to comment
Bigjhow Posted October 6, 2022 Author Share Posted October 6, 2022 MUITO OBRIGADO ME AJUDOU MUITO DE VERDADE !! SOLUCIONOU MEU PROBLEMA 100% !! Link to comment
Shady1 Posted October 6, 2022 Share Posted October 6, 2022 1 minute ago, Bigjhow said: MUITO OBRIGADO ME AJUDOU MUITO DE VERDADE !! SOLUCIONOU MEU PROBLEMA 100% !! De nada, se tiver algum outro problema, por favor abra um novo tópico e me escreva, vou te ajudar em tudo 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