Jump to content

Trampo por base de nivel


Recommended Posts

Posted

Rapaziada

Bom, eu tenho um script simples de trabalho q consiste no player ir ate o marker e ele recebe um veiculo pra entregar em outro marker...eu gostaria q ele pedisse nivel pra deixar o player fazer o trabalho

Ex.: eu sou posso fazer o trabalho de piloto de avião se eu tiver nivel 15 ou eu só posso por exemplo fazer o trabalho de caminhoneiro se eu tiver no minimo nivel 5

 

Posted
4 minutes ago, OSKHNAV said:

Ah man mas como assim

Manda o código do seu script de level e o código do trabalho. Sem esses dois códigos a gente não pode te ajudar, mas basicamente é só criar um getElementData.

Posted (edited)
19 hours ago, juaosilv said:

Manda o código do seu script de level e o código do trabalho. Sem esses dois códigos a gente não pode te ajudar, mas basicamente é só criar um getElementData.

Client ( Mod Nivel ) :

 

local x, y = guiGetScreenSize()
local x, y = (x/1366),(y/768)

addEventHandler("onClientRender", root, 
function()
    local lvl = getElementData(localPlayer, "Level") or 1
    local exp = getElementData(localPlayer, "Exp") or 0
    local needexp = lvl * 1
    
    
     dxDrawImage(x * 62, y * 485, x * 253, y * 18, "life.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
     dxDrawImage(x * 58, y * 431, x * 261, y * 16, "life.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    
    dxDrawText("Nível: "..lvl, x * 207, y * 460, x * 295, y * 467, tocolor(140, 1, 219, 255), 1.10, "default-bold", "center", "center")
    dxDrawText("Exp : "..string.format("%d", exp).."/"..needexp, x * 58, y * 459, x * 146, y * 466, tocolor(140, 1, 219, 255), 1.10, "default-bold", "center", "center")

    dxDrawText(string.format("%d", 100/(needexp/exp)).."%", x * 179, y * 488, x * 202, y * 501, tocolor(255, 0, 0), 1, "default-bold", "center", "center")
    dxDrawRectangle(x * 65, x * 488, y * 247/needexp*(exp), y * 12, tocolor(200, 200, 200, 100))
    
end)

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

server ( Mod Nivel ) :

call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Level", root, 50, "Nível", 3)
local coeff = 0 -- quantidade

function experience ()
    for i, p in ipairs( getElementsByType( "player" ) ) do
        local exp = getElementData(p, "Exp")
        local exps = tonumber(getElementData(p, "Exp"))
        local lvls = tonumber(getElementData(p, "Level"))
        if lvls and exps then 
            local needexp = lvls * 1
            if not exp then
                setElementData(p, "Level", 1)
                setElementData(p, "Exp", 0)
            else
                setElementData(p, "Exp", exps + 0.0001)
                if exps >= needexp then
                    setElementData(p, "Level", lvls + 1)
                    setElementData(p, "Exp", 0)
                    givePlayerMoney(p, coeff*(lvls+1))
                    outputChatBox("Parabéns você foi para o level! " .. lvls + 1 .. "!", p, 0, 255, 0)
                end
            end
        end
    end
end
setTimer(experience, 60, 0)

addEventHandler("onPlayerLogin", root, 
function(p, c)
    local lvl = getAccountData(c, "lvl")
    local exp = getAccountData(c, "exp")
    if lvl and exp then
        setElementData(source, "Level", lvl)
        setElementData(source, "Exp", exp)
    else
        setElementData(source, "Level", 1)
        setElementData(source, "Exp", 0)
        setAccountData(c, "exp", 0)
        setAccountData(c, "lvl", 1)
    end
end)

addEventHandler("onPlayerQuit", root, 
function()
    local acc = getPlayerAccount(source)
    if acc and not isGuestAccount(acc) then
        local lvl = getElementData(source, "Level")
        local exp = getElementData(source, "Exp")
        if lvl and exp then
            setAccountData(acc, "exp", exp)
            setAccountData(acc, "lvl", lvl)
        else
            setAccountData(acc, "exp", 0)
            setAccountData(acc, "lvl", 1)
        end
    end
end)

addCommandHandler("darnivel", 
function(player, cmd, target, amount)
    local accName = getAccountName(getPlayerAccount(player))
    if not isObjectInACLGroup ("user."..accName, aclGetGroup("Admin")) then
        outputChatBox("Você não tem acesso a esta equipe!", player, 255, 0, 0)
        return
    end
    if target then
        if tonumber(amount) then
            local targetplayer = getPlayerFromName(target)
            if targetplayer then
                setElementData(targetplayer, "Level", amount)
                setElementData(targetplayer, "Exp", 0)
                outputChatBox(getPlayerName(player).." O Admin lhe deu "..amount.." de Nivel", targetplayer, 0, 255, 0, true)
                outputChatBox("Você Setou com sucesso "..amount.." o nível do jogador "..getPlayerName(targetplayer).."!", player, 0, 255, 0, true)
            else
                outputChatBox("Erro: jogador não encontrado", player, 255, 0, 0)
            end
        else
            outputChatBox("Use: / darnivel [Nickname] [Level]", player, 255, 0, 0)
        end
    else 
        outputChatBox("Use: / darnivel [Nickname] [Level]", player, 255, 0, 0)
    end
end)

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Server ( Mod De Trabalho De Piloto ) :

 

Minicio = createMarker (1956.7326660156,-2181.5776367188,13.546875 -1, "cylinder", 2, 255 ,0 ,0, 255)
Mfim = createMarker (431.3303527832,2504.9392089844,16.484375 -1, "cylinder", 10, 0 ,255 ,0, 255)

Bfim = createBlipAttachedTo ( Mfim, 19 )
setElementVisibleTo ( Bfim, root, false )
setElementVisibleTo ( Mfim, root, false )
veh = {}
function incio (source)
if isElementWithinMarker(source, Minicio) then
if veh[source] and isElement( veh[source] ) then destroyElement ( veh[source] )
veh[source] = nil
end
x,y,z = getElementPosition(source)
Trabalho = true
veh[source] = createVehicle(553,1984.5490722656,-2493.572265625,13.53911781311, -0, 0, 89.591979980469)
setElementVisibleTo ( Bfim, source, true )
setElementVisibleTo ( Mfim, root, true )
warpPedIntoVehicle ( source, veh[source] )
 outputChatBox ("#00ff00======================================================",source,0,0,0,true )
 outputChatBox ("#ffff00Leve Veiculo Ate o Blip De Uma Bandeira Vermelha No Seu Radar ! E Sera Bem Recompenssado!",source,0,0,0,true )
 outputChatBox ("#00ff00======================================================",source,0,0,0,true )
end
end
addEventHandler( "onMarkerHit", Minicio, incio ) 

function fim (source)
if veh[source] and isElement(veh[source]) then
destroyElement (veh[source])
givePlayerMoney(source,15000)
setElementVisibleTo ( Bfim, source, false )
setElementVisibleTo ( Mfim, root, false )
outputChatBox("#00ff00voce completou com sucesso ! Recompensa: 15.000",source,0,0,0,true)
else
end
end
addEventHandler("onMarkerHit",Mfim ,fim)

function sair (source)
if (veh[source]) and isElement(veh[source]) then
setElementVisibleTo ( Bfim, source, false )
setElementVisibleTo ( Mfim, root, false )
destroyElement (veh[source])
outputChatBox("#00ff00Voce perdeu seu trabalho", source ,0,0,0,true)
else
end
end
addEventHandler ( "onVehicleExit", getRootElement(), sair )

Edited by OSKHNAV
  • Moderators
Posted

UqAT5Nh.png

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! spacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

  • Moderators
Posted

Poste o código na formatação Lua usando o botão <> do fórum ao invés de colar direto no texto.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! spacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

  • Moderators
Posted

Saberia se tivesse visto as regras:

 

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! spacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted
6 minutes ago, MaligNos said:

@OSKHNAV

Além de não seguir as normas do fórum ainda age sem educação… como espera ser ajudado ?

Ah pronto...agr aki virou um forum de moralidade...da pra ajudar com esse script logo pq eu tenho prazo pra entregar ele

Posted

Não é a primeira vez que o @OSKHNAV age assim:

Spoiler

DRH9dfk.png

A resposta já foi dada acima, mas você preferiu insultar um membro e staff (e não é a primeira vez) então sua atitude terá suas consequências... Tópico trancado.

Please do not PM me with scripting related question nor support, use the forums instead.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...