-
Posts
3,992 -
Joined
-
Last visited
-
Days Won
183
Everything posted by Lord Henry
-
Tente com getVehicleController. function click(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if isElement(chaseWindow) and button == "left" and state == "down" then if clickedElement and getElementType(clickedElement) == "vehicle" then local sx,sy,sz = getElementVelocity(clickedElement) local driver = getVehicleController(clickedElement) local realSpeed = ((sx^2 + sy^2 + sz^2)^(0.5)) * 180 guiSetText(speedLabel,"Velocidade de: "..math.floor(realSpeed).." км/H") if driver then guiSetText(driverLabel,"Motorista: "..getPlayerName(driver)) else guiSetText(driverLabel,"Motorista: Não encontrado") end if numberLabel then guiSetText(numberLabel,"Nivel de Procurado: "..getPlayerWantedLevel(driver)) end if realSpeed >= chaseSpeedLimit then guiSetEnabled(chaseButton,true) guiLabelSetColor(speedLabel,255,0,0) else guiSetEnabled(chaseButton,false) guiLabelSetColor(speedLabel,255,255,255) end clickedVeh = clickedElement end end end EDIT: Testei aqui e descobri. A função getPlayerWantedLevel sempre retornará o nível de procurado do localPlayer quando executada client-side. Tanto é que ela não usa parâmetros se estiver client-side.
-
Verifiquei aqui e detectei alguns erros na parte server-side. Aparentemente o onPlayerMarkerHit só funciona anexado ao root mesmo, o que é bem estranho... Também havia problemas com o timer, que não é capaz de obter source de outro evento, sendo necessário passar o source por parâmetro nele. Então ficou assim: local theTimers = {} local theMarker = createMarker (1409.666, -1790.515, 12.6, "cylinder", 1.2, 200, 50, 0, 150) function DeltaSCRAbrir (marker, matchingDimension) if marker == theMarker then if getPedOccupiedVehicle(source) == false then if isTimer(theTimers[source]) then outputChatBox ("╔═════════════════════════════════════════════════╗", source, 200, 50, 0) outputChatBox ("ERRO: #FFFFFFVocê já resgatou seu bônus diário, aguarde para resgatar o próximo", source, 200, 50, 0, true) outputChatBox ("╚═════════════════════════════════════════════════╝", source, 200, 50, 0) else theTimers[source] = setTimer (function (theSource) theTimers[theSource] = nil end, 60000, 1, source) -- 1 minuto. triggerClientEvent (source, "DeltaSCR:Abrir", source) end end end end addEventHandler ("onPlayerMarkerHit", getRootElement(), DeltaSCRAbrir) addEventHandler ("onPlayerLogout", getRootElement(), function (thePreviousAccount, theCurrentAccount) local timerDetails = getTimerDetails (theTimers[source]) -- Nesta função, source = player que deslogou. setAccountData (thePreviousAccount, "DeltaSCR:Timers", timerDetails) end) addEventHandler ("onPlayerQuit", getRootElement(), function() -- OnPlayerQuit não chama o evento onPlayerLogout, vc deve salvar a data aqui também. if isTimer(theTimers[source]) then -- Nesta função, source = player que quitou do server. local timerDetails = getTimerDetails (theTimers[source]) setAccountData (getPlayerAccount(source), "DeltaSCR:Timers", timerDetails) -- Salva a data na conta do player que quitou. killTimer(theTimers[source]) -- Cancela o timer. end theTimers[source] = nil -- Anula a variável do timer, para liberar espaço na memória. end) addEventHandler ("onPlayerLogin", getRootElement(), function (thePreviousAccount, theCurrentAccount) local dataTimer = getAccountData (theCurrentAccount, "DeltaSCR:Timers") if dataTimer then setAccountData (theCurrentAccount, "DeltaSCR:Timers", false) -- Remove o tempo restante da conta do player. Ela será salva novamente caso o player deslogue ou quite do server. theTimers[source] = setTimer (function (theSource) -- Nesta função, source = player que logou. theTimers[theSource] = nil end, dataTimer, 1, source) -- Recria o timer com o tempo restante que estava salvo. end end)
-
Ele quis dizer que está faltando a parte do render. Que tem os dxDraw.
-
Faça a parte do dano client-side. Dai você usa o evento onClientVehicleDamage e verifica se o attacker for um player, o motorista não perde vida.
-
@Tio.Andy pelo jeito vc não sabe nem a lógica de programação, colega. Comece por aqui: Curso de Algoritmos #02 - YouTube Não tem aquele primeiro parênteses antes do getPlayerName, também não tem aquele player ali, só o thePlayer.
-
Vc está usando 2 parâmetros no getPlayerWantedLevel: thePlayer e proc. E não faz sentido vc usar a variável proc pois ela é igual a driver. Seria mais fácil vc simplesmente usar driver no lugar de proc. function click(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if isElement(chaseWindow) and button == "left" and state == "down" then if clickedElement and getElementType(clickedElement) == "vehicle" then local sx,sy,sz = getElementVelocity(clickedElement) local driver = getVehicleOccupant(clickedElement) local realSpeed = ((sx^2 + sy^2 + sz^2)^(0.5)) * 180 guiSetText(speedLabel,"Velocidade de: "..math.floor(realSpeed).." км/H") if driver then guiSetText(driverLabel,"Motorista: "..getPlayerName(driver)) else guiSetText(driverLabel,"Motorista: Não encontrado") end if numberLabel then guiSetText(numberLabel,"Nivel de Procurado: "..getPlayerWantedLevel(driver)) end if realSpeed >= chaseSpeedLimit then guiSetEnabled(chaseButton,true) guiLabelSetColor(speedLabel,255,0,0) else guiSetEnabled(chaseButton,false) guiLabelSetColor(speedLabel,255,255,255) end clickedVeh = clickedElement end end end
-
Não. Só se vc quiser que a função ative em todos os markers do server. Ah, se der erro é pq faltou vc criar o theMarker.
-
Não sei. Não temos como adivinhar como vc está trabalhando com o level.
-
local theTimers = {} function DeltaSCRAbrir (theMarker, matchingDimension) if getPedOccupiedVehicle(source) == false then if isTimer(theTimers[source]) then outputChatBox ("╔═════════════════════════════════════════════════╗", source, 200, 50, 0) outputChatBox ("ERRO: #FFFFFFVocê já resgatou seu bônus diario, aguarde para resgatar o próximo", source, 200, 50, 0, true) outputChatBox ("╚═════════════════════════════════════════════════╝", source, 200, 50, 0) else theTimers[source] = setTimer (function () theTimers[source] = nil end, 60000, 1) -- 1 minuto. triggerClientEvent (source, "DeltaSCR:Abrir", source) end end end addEventHandler ("onPlayerMarkerHit", theMarker, DeltaSCRAbrir) addEventHandler ("onPlayerLogout", getRootElement(), function (thePreviousAccount, theCurrentAccount) local timerDetails = getTimerDetails (theTimers[source]) -- Nesta função, source = player que deslogou. setAccountData (thePreviousAccount, "DeltaSCR:Timers", timerDetails) end) addEventHandler ("onPlayerQuit", getRootElement(), function() -- OnPlayerQuit não chama o evento onPlayerLogout, vc deve salvar a data aqui também. if isTimer(theTimers[source]) then -- Nesta função, source = player que quitou do server. local timerDetails = getTimerDetails (theTimers[source]) setAccountData (getPlayerAccount(source), "DeltaSCR:Timers", timerDetails) -- Salva a data na conta do player que quitou. killTimer(theTimers[source]) -- Cancela o timer. end theTimers[source] = nil -- Anula a variável do timer, para liberar espaço na memória. end) addEventHandler ("onPlayerLogin", getRootElement(), function (thePreviousAccount, theCurrentAccount) local dataTimer = getAccountData (theCurrentAccount, "DeltaSCR:Timers") if dataTimer then setAccountData (theCurrentAccount, "DeltaSCR:Timers", false) -- Remove o tempo restante da conta do player. Ela será salva novamente caso o player deslogue ou quite do server. theTimers[source] = setTimer (function () -- Nesta função, source = player que logou. theTimers[source] = nil end, dataTimer, 1) -- Recria o timer com o tempo restante que estava salvo. end end)
-
Claro que vai, só n coloquei pq ela fica fora daquela função.
-
Editei a resposta.
-
Também daria, mas eu particularmente usaria getRealTime().timestamp pois ele não está trabalhando com datas, só com tempo. @#DeltaSCR da linha 6 em diante não faz sentido vc criar uma variável local para guardar uma variável global. function DeltaSCRAbrir (theMarker, matchingDimension) if getPedOccupiedVehicle(source) == false then if isTimer(theTimers[source]) then outputChatBox ("╔═════════════════════════════════════════════════╗", source, 200, 50, 0) outputChatBox ("ERRO: #FFFFFFVocê já resgatou seu bônus diario, aguarde para resgatar o próximo", source, 200, 50, 0, true) outputChatBox ("╚═════════════════════════════════════════════════╝", source, 200, 50, 0) else theTimers[source] = setTimer (function () theTimers[source] = nil end, 60000, 1) -- 1 minuto. triggerClientEvent (source, "DeltaSCR:Abrir", source) end end end addEventHandler ("onPlayerMarkerHit", theMarker, DeltaSCRAbrir) -- A função só funciona quando um player colide no marker. Dessa forma n precisa verificar se o elemento que colidiu é um player. source = player que colidiu no marker.
-
Na sua linha 4. playerTraficante não faz sentido. Onde ele foi declarado?
-
local marker1 = createMarker ( 2185.5439453125,-1811.8256835938,13.546875 -1, "cylinder", 1.2, 0 , 255, 0, 155 ) local marker2 = createMarker ( 2157.5869140625,-1808.6865234375,13.387050628662 -1, "cylinder", 3, 255 , 0, 0, 155) veh = {} function criaVeh () if veh[source] and isElement (veh[source]) then destroyElement (veh[source]) veh[source] = nil end local x, y, z = getElementPosition(source) veh[source] = createVehicle (490, x, y, z + 1, -0, 0, 5.1420917510986) warpPedIntoVehicle (source, veh[source]) end addEventHandler ("onPlayerMarkerHit", marker1, criaVeh) function detonaVeh (marker, matchingDimension) local theVeh = getPedOccupiedVehicle (source) if theVeh and isElement(theVeh) then destroyElement(theVeh) theVeh = nil end end addEventHandler ("onPlayerMarkerHit", marker2, detonaVeh)
-
Quando o jogador sair do servidor, vc deve salvar o tempo restante do timer dele com o setAccountData e com o getTimerDetails. E logo em seguida dar killTimer para não ficar contando o tempo do player que não existe. Quando o player logar de novo, cria o timer de novo normalmente com o setTimer usando o tempo restante que estava salvo na conta dele com getAccountData.
-
addCommandHandler - Para fazer o comando /192 funcionar. getElemenstByType - Para obter todos os elementos de tal tipo no servidor (no caso, "players") getPlayerAccount - Para obter a conta do jogador, para usar na função abaixo: getAccountName - Para obter o nome da conta do jogador, para usar na função abaixo: isObjectInACLGroup - Para verificar qual ACL Group cada jogador está. outputChatBox - Para mandar o texto no chat.
-
Só com isso já serve. for _, v in ipairs ( { "pro", "std", "poor" } ) do setWeaponProperty (ID, v, "damage", 0) -- No lugar de ID, coloque o ID da arma que vc quer mudar o dano. No lugar do 0, informe quanto dano cada tiro da arma deverá dar. end
-
givePlayerMoney eu considero uma função server-side. (ela funciona no client, mas dai só muda o dinheiro no HUD do jogador, pois no server ele continuará tendo a quantidade de antes) @LucasMTA mostre o script server-side.
-
N entendi nada.
-
Lógica de programação: Curso de Algoritmos #02 - YouTube Não se usa triggerClientEvent no client-side. Usa-se triggerServerEvent. Leia a Wiki.
-
Só uma correção: Marker Sobre digitar um comando 10x para fazer tal coisa, faça client-side. Com um addCommandHandler e uma variável que vai somando +1 a cada vez que a função é executada. Quando chegar em 10, manda tal outputChatBox. contador = 0 function output10 (cmd) if contador == 10 then outputChatBox ("Você usou este comando 10 vezes.") return else outputChatBox ("Comando executado com sucesso.") end contador = contador + 1 end addCommandHandler ("seuComandoAqui", output10)
-
Explicar essa diferença entre server-side e client-side daria um ótimo tutorial. A propósito, testei o código e funcionou aqui também. Tenha certeza de ter copiado o código sem nenhum símbolo invisível, que impede o funcionamento do script. Para fazer o esquema de ACL Groups, que só funciona server-side, você vai precisar mudar toda a lógica do seu painel. A ativação dele passará a ser no server, com um triggerClientEvent para iniciar/parar a renderização do painel.
-
Troque para server. Pois vc está usando funções server-side, que no client não funcionam.
-
Eu n entendi nada que ele disse '-'