gbmv33 Posted May 25, 2019 Share Posted May 25, 2019 Estou tendo um problema muito anti-RP no meu server vou tentar explicar, uso um menu de animações no F4 só que tem um problema. Quando uma pessoa toma um taser, ativa uma animação que ele fica deitado no chão ou quando uma pessoa é algemada ativa outra animação que ele fica algemado, ai que está o problema, se a pessoa usar o painel de animações do F4 ele simplesmente cancela qualquer animação tanto de ser preso ou de tomar um taser ai eu estou tentando fazer adicionar uma função no script do taser e de algemar que ele não consiga user nenhum F do F1 ao F12 eu fiz um script mas estou errando em alguma coisa que não sei oq é -------- SCRIPT ORIGINAL PARA CANCELAR OS F'S addEventHandler("onClientKey", root, function (button, press) if getElementData(getLocalPlayer(),"preso") then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" then cancelEvent() end end end ) -------- ElementData do script de Algemar setElementData(player_a_ser_algemado,"algemado", nick_do_jogador) -------- tentei implementar no script de algemar local screenW,screenH = guiGetScreenSize() -- Função de Reposicionar Largura e altura da tela local resW, resH = 1280, 720 -- Largura e altura da tela local x, y = (resW/screenW),(resH/screenH) -- juntar dois elementos em x, y local tempo, valor = 500, 60 -- Tempo de carregamento local startTick local pBarCurWidth, pBarWidth = 0, 368 -- largura e altura do dx addEvent("doShowDXProgressBar", true) -- Ativar um evento personalizado addEventHandler("doShowDXProgressBar", root, function() startTick = getTickCount() -- Começar contagem if addEventHandler("onClientRender", root, renderDXProgressBar) then -- se executar essa função fara alguma coisa, no caso n tera nada caso queira usar para desbugar script end end ) function renderDXProgressBar() local now = getTickCount() if (now - startTick) >= tempo then -- Aumentar a largura da barra pBarCurWidth = pBarCurWidth + valor startTick = getTickCount() if pBarCurWidth > pBarWidth then -- Barra de progresso cheia pBarCurWidth = pBarWidth removeEventHandler("onClientRender", root, renderDXProgressBar) startTick = nil end end dxDrawRectangle(x*354, y*312, pBarWidth, 38, tocolor(0, 0, 0, 255), false) dxDrawRectangle(x*358, y*316, pBarCurWidth, 29, tocolor(189, 0, 0, 255), false) dxDrawText( tostring( math.ceil((pBarCurWidth * 100) / pBarWidth) ).." %", x*358, y*316, (x*358) + pBarWidth, (y*316) + 29, tocolor(255,255,255), 2) end addEventHandler("onClientKey", root, function (button, press) if getElementData(player_a_ser_algemado,"algemado") then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" then cancelEvent() end end end ) Link to comment
Jonas^ Posted May 25, 2019 Share Posted May 25, 2019 (edited) Você não precisa declarar duas funções pra fazer a mesma coisa, basta verificar ambas as datas em uma só, retire a primeira função onClientKey e deixe somente essa no lugar da última: addEventHandler ("onClientKey", root, function (button, press) if getElementData (localPlayer, "preso") or getElementData (localPlayer, "algemado") then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" then cancelEvent () end end end) Edited May 25, 2019 by Jonas^ 1 Link to comment
gbmv33 Posted May 25, 2019 Author Share Posted May 25, 2019 Entendi como funciona agora, muito obrigado só que tenho outra pergunta. Consigo usar essa mesma função no taser? eu achei um taser na internet, só que é AntiRP você toma um taser cai, ai usa o painel de animações pra cancelar a animação do taser. Link to comment
Jonas^ Posted May 25, 2019 Share Posted May 25, 2019 (edited) Depende, o taser seta alguma data no jogador enquanto ele estiver sobre o efeito do taser? se sim é possível sim, caso contrário você vai ter que setar uma data no jogador que for atingido pelo taser e quando o efeito passar remover essa data, dai no onclientkey você apenas verifica se o jogador estiver essa data e a ação sera cancelada Edited May 25, 2019 by Jonas^ Link to comment
gbmv33 Posted May 25, 2019 Author Share Posted May 25, 2019 ok, vou tentar fazer isso. Estou no caminho certo? -----Taser (server-side) local cFunc = {} local cSetting = {} -- FUNCTIONS -- setWeaponProperty("silenced", "pro", "weapon_range", 45.0) setWeaponProperty("silenced", "pro", "maximum_clip_ammo", 1) setWeaponProperty("silenced", "pro", "damage", 10) setWeaponProperty("silenced", "std", "weapon_range", 45.0) setWeaponProperty("silenced", "std", "maximum_clip_ammo", 1) setWeaponProperty("silenced", "std", "damage", 10) setWeaponProperty("silenced", "poor", "weapon_range", 45.0) setWeaponProperty("silenced", "poor", "maximum_clip_ammo", 1) setWeaponProperty("silenced", "poor", "damage", 10) -- EVENT HANDLERS -- function emshock (thePlayer) local player_alvo = getPlayerFromPartialName ( nick ) local nick_do_jogador = getPlayerName ( player_alvo ) local nick_do_agressor = getPlayerName ( thePlayer ) if player_alvo then setElementData (thePlayer, "shock", player_alvo ) end end --------taser Client Side cFunc["anim_check"] = function(_, wep, bodypart) getElementData( thePlayer, "shock" ) if(wep == 23) and (bodypart == 9) then setPedAnimation(source, "ped", "KO_shot_face", 30000, false, true, false) setElementData (thePlayer, "shock", false ) elseif(wep == 23) and (bodypart == 8) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (thePlayer, "shock", false ) elseif(wep == 23) and (bodypart == 7) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (thePlayer, "shock", false ) elseif(wep == 23) and (bodypart == 6) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (thePlayer, "shock", false ) elseif(wep == 23) and (bodypart == 5) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (thePlayer, "shock", false ) elseif(wep == 23) and (bodypart == 4) then setPedAnimation(source, "CRACK", "crckdeth3", 30000, false, true, false) setElementData (thePlayer, "shock", false ) elseif(wep == 23) and (bodypart == 3) then setPedAnimation(source, "ped", "KO_shot_stom", 30000, false, true, false) setElementData (thePlayer, "shock", false ) elseif(wep == 23) and (bodypart == 2) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (thePlayer, "shock", false ) elseif(wep == 23) and (bodypart == 1) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (thePlayer, "shock", false ) end end Link to comment
Jonas^ Posted May 25, 2019 Share Posted May 25, 2019 Quase, tem algumas coisas erradas, tente assim: cFunc["anim_check"] = function(_, wep, bodypart) if(wep == 23) and (bodypart == 9) then setPedAnimation(source, "ped", "KO_shot_face", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 8) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 7) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 6) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 5) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 4) then setPedAnimation(source, "CRACK", "crckdeth3", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 3) then setPedAnimation(source, "ped", "KO_shot_stom", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 2) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 1) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) end end addEventHandler ("onClientKey", root, function (button, press) if getElementData (localPlayer, "preso") or getElementData (localPlayer, "algemado") or getElementData (localPlayer, "shock") then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" then cancelEvent () end end end) Link to comment
gbmv33 Posted May 25, 2019 Author Share Posted May 25, 2019 Mudei o function apenas para shock, ele não está mais como um "taser" está como a silenciada normal, apenas com a textura do taser cFunc["anim_check"] = function(_, wep, bodypart) if(wep == 23) and (bodypart == 9) then setPedAnimation(source, "ped", "KO_shot_face", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 8) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 7) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 6) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 5) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 4) then setPedAnimation(source, "CRACK", "crckdeth3", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 3) then setPedAnimation(source, "ped", "KO_shot_stom", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 2) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 1) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) end end addEventHandler ("onClientKey", root, function (button, press) if (localPlayer, "shock") then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" then cancelEvent () end end end) -- EVENT HANDLER -- addEventHandler("onClientPlayerWeaponFire", getRootElement(), cFunc["shot_check"]) addEventHandler("onClientRender", getRootElement(), cFunc["render_shots"]) addEventHandler("onClientPedDamage", getRootElement(),cFunc["anim_check"]) addEventHandler("onClientPlayerDamage", getRootElement(),cFunc["anim_check"]) Link to comment
Jonas^ Posted May 26, 2019 Share Posted May 26, 2019 addEventHandler ("onClientKey", root, function (button, press) if getElementData (localPlayer, "shock") then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" then cancelEvent () end end end) Link to comment
gbmv33 Posted May 26, 2019 Author Share Posted May 26, 2019 coloquei o getElementData que eu tinha removido sem querer mais continua a mesma coisa. está uma silenciada normal apenas com a textura do taser Link to comment
Jonas^ Posted May 26, 2019 Share Posted May 26, 2019 Troque source por localPlayer nas datas, pensei que o resource fosse server-side. Se você tivesse com o /debugscript 3 ativo já teria visto. Link to comment
gbmv33 Posted May 26, 2019 Author Share Posted May 26, 2019 troquei os source por localPlayer não houve mudanças Silenced tem a textura do taser apenas, mas age como uma silenced normal to achando que o problema pode ser server-side. o meu function está certo? function emshock (thePlayer) local player_alvo = getPlayerFromPartialName ( nick ) local nick_do_jogador = getPlayerName ( player_alvo ) local nick_do_agressor = getPlayerName ( thePlayer ) if player_alvo then setElementData (thePlayer, "shock", player_alvo ) end end Link to comment
Jonas^ Posted May 26, 2019 Share Posted May 26, 2019 (edited) Pra falar a verdade é source ao invés de localPlayer mesmo pois no evento onClientPedDamage quem recebe o Damage é o source volte pra source nas datas, e no server está errado, a data neste caso você precisa informar um valor bool. Troque por: setElementData (player_alvo, "shock", true) Onde essa função emshock esta sendo chamada no server-side ? Acredito que de pra gente fazer tudo server-side e nem precisamos usar as datas no client. Digite /debugscript 3 e diga se aparecer erros quando startar o resouce. Edited May 26, 2019 by Jonas^ 1 Link to comment
gbmv33 Posted May 27, 2019 Author Share Posted May 27, 2019 consertei aq descobri o error no codigo tinha 2 sinais "??" invisiveis, eles so aparecem no notepad++ addEventHandler ("onClientKey", root, function (button, press) if getElementData (source, "shock") then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" then cancelEvent () end end end)?? ------AQUI quando ativei o debug mod eu vi que deu error de sinais estranhos perto da linha ai eu não vi nada naquela linha, quando passei pro notepad++ esses sinais apareceram. Link to comment
DNL291 Posted May 27, 2019 Share Posted May 27, 2019 @gbmv33 Esses símbolos aparecem depois da primeira vez que você copia no fórum, ou seja, na primeira funciona. Minha dica é estar ciente disso e quando copiar o código dar f5 para 'resetar' o bug e então copiar. 1 Link to comment
gbmv33 Posted May 27, 2019 Author Share Posted May 27, 2019 (edited) preciso de ajuda ainda kkk, não aparece nada mais no debug script mas ele não está setando o shock no player para não ativar os F's, nsei mais oq fazer vou deixar os scripts server e client side se alguem poder me ajudar agradeço Server-side local cFunc = {} local cSetting = {} -- FUNCTIONS -- setWeaponProperty("silenced", "pro", "weapon_range", 45.0) setWeaponProperty("silenced", "pro", "maximum_clip_ammo", 1) setWeaponProperty("silenced", "pro", "damage", 10) setWeaponProperty("silenced", "std", "weapon_range", 45.0) setWeaponProperty("silenced", "std", "maximum_clip_ammo", 1) setWeaponProperty("silenced", "std", "damage", 10) setWeaponProperty("silenced", "poor", "weapon_range", 45.0) setWeaponProperty("silenced", "poor", "maximum_clip_ammo", 1) setWeaponProperty("silenced", "poor", "damage", 10) -- EVENT HANDLERS -- function emshock (thePlayer) local player_alvo = getPlayerFromPartialName ( nick ) local nick_do_jogador = getPlayerName ( player_alvo ) local nick_do_agressor = getPlayerName ( thePlayer ) if player_alvo then setElementData (player_alvo, "shock", true) end end client-side --[[ ########################################################################## ## ## ## Project: 'Taser' - resource for MTA: San Andreas ## ## ## ########################################################################## [C] Copyright 2013-2014, Falke ]] local cFunc = {} local cSetting = {} cSetting["shots"] = {} cSetting["shot_calcs"] = {} local last_shot = 1 -- FUNCTIONS -- cFunc["render_shots"] = function() for index, tbl in pairs(cSetting["shots"]) do dxDraw:OedLine3D(tbl[1], tbl[2], tbl[3], tbl[4], tbl[5], tbl[6], tocolor(0, 255, 0)) end end cFunc["draw_shot"] = function(x1, y1, z1, x2, y2, z2) table.insert(cSetting["shots"], last_shot, {x1, y1, z1, x2, y2, z2}) -- SHOT CALCULATING local lastx, lasty, lastz = x1, y1, z1 local dis = getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) cSetting["shot_calcs"][last_shot] = {} for i = 1, dis, 0.5 do -- cSetting["shot_calcs"][i] = nx, ny, nz -- cSetting["shot_calcs"][last_shot][i] = end last_shot = last_shot+1 end cFunc["shot_weapon"] = function(hitX, hitY, hitZ, x, y, z) playSound3D("data/Fire.wav", x, y, z) local s = playSound3D("data/Fire.wav", hitX, hitY, hitZ) setSoundMaxDistance(s, 50) for i = 1, 5, 1 do fxAddPunchImpact(hitX, hitY, hitZ, 0, 0, 0) fxAddSparks(hitX, hitY, hitZ, 0, 0, 0, 8, 1, 0, 0, 0, true, 3, 1) end cFunc["draw_shot"](x, y, z, hitX, hitY, hitZ) fxAddPunchImpact(x, y, z, 0, 0, -3) end cFunc["wait_shot"] = function() toggleControl("fire", false) setTimer(function() toggleControl("fire", true) end, 350, 1) end cFunc["shot_check"] = function(wp, _, _, hitX, hitY, hitZ, element, startX, startY, startZ) if(wp == 23) then cFunc["shot_weapon"](hitX, hitY, hitZ, startX, startY, startZ) if(source == localPlayer) then cFunc["wait_shot"]() end end end dxDraw:OedLine3D = function(x1, y1, z1, x2, y2, z2, color) local dis = getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) local lastx, lasty, lastz = x1, y1, z1 --for i = 1, dis, 3 do -- dxDrawLine3D(x1, y1, z1, x2, y2, z2) --end end cFunc["anim_check"] = function(_, wep, bodypart) if(wep == 23) and (bodypart == 9) then setPedAnimation(source, "ped", "KO_shot_face", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 8) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 7) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 6) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 5) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 4) then setPedAnimation(source, "CRACK", "crckdeth3", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 3) then setPedAnimation(source, "ped", "KO_shot_stom", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 2) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) elseif(wep == 23) and (bodypart == 1) then setPedAnimation(source, "CRACK", "crckdeth2", 30000, false, true, false) setElementData (source, "shock", true) setTimer (function () setElementData (source, "shock", false) end, 30000, 1) end end addEventHandler ("onClientKey", getRootElement(), function (button, press) if getElementData (source, "shock") then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "F9" or button == "F10" or button == "F11" or button == "F12" or button == "t" then cancelEvent () end end end) -- EVENT HANDLER -- addEventHandler("onClientPlayerWeaponFire", getRootElement(), cFunc["shot_check"]) addEventHandler("onClientRender", getRootElement(), cFunc["render_shots"]) addEventHandler("onClientPedDamage", getRootElement(),cFunc["anim_check"]) addEventHandler("onClientPlayerDamage", getRootElement(),cFunc["anim_check"]) na real apareceu algo sim, quando eu levo o tiro aparece, Bad Argument @ 'setElementData' [Expected element at argument 1,got nil] Edited May 27, 2019 by gbmv33 Link to comment
Other Languages Moderators Lord Henry Posted May 28, 2019 Other Languages Moderators Share Posted May 28, 2019 Erro naquela linha 23 do server-side. Está retornando false pois nick não foi declarado em lugar nenhum. Link to comment
DNL291 Posted May 28, 2019 Share Posted May 28, 2019 On 26/05/2019 at 07:12, Jonas^ said: Onde essa função emshock esta sendo chamada no server-side ? Responda essa pergunta @gbmv33 Link to comment
gbmv33 Posted May 28, 2019 Author Share Posted May 28, 2019 (edited) eu usei o server side para setar o elementdata no alvo do taser, e chama-la em client side que iria bloquear o uso dos F`s então eu removo a linha 23? esqueci de falar que e esse errorBad Argument @ 'setElementData' [Expected element at argument 1,got nil] deu no client side nas linhas da data esqueci de falar que e esse errorBad Argument @ 'setElementData' [Expected element at argument 1,got nil] deu no client side nas linhas da data Edited May 28, 2019 by gbmv33 Link to comment
Other Languages Moderators Lord Henry Posted May 28, 2019 Other Languages Moderators Share Posted May 28, 2019 Cara, vc claramente não sabe lógica de programação. Dai nós ficamos quebrando a cabeça pra fazer o código inteiro por você. 1 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