Duff1995 Posted February 2, 2020 Share Posted February 2, 2020 --meu sistema de level local recompensa = 100 -- 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 * 1500 if not exp then setElementData(p, "Level", 0) setElementData(p, "Exp", 0) else if exps >= needexp then setElementData(p, "Level", lvls + 1) setElementData(p, "Exp", 0) givePlayerMoney(p, recompensa) outputChatBox ("#106FE7( #ffffffLEVEL#106FE7 ) #FFFFFF Parabéns você passou para o level #106FE7" .. lvls + 1 .. "", p, 255, 255, 255, true) end end end end end setTimer(experience, 100, 0) function killandexp (ammo, killer, killerweapon, bodypart) if (killer) and (killer ~= source) then local exp = getElementData(killer, "Exp") local exps = tonumber(getElementData(killer, "Exp")) if not exp then setElementData(killer, "Exp", 0) else setElementData(killer, "Exp", exps + 2) triggerClientEvent(killer,"xplevel",killer) end end end addEventHandler ( "onPlayerWasted", getRootElement(), killandexp) function ChuvaXP (player) if (hasObjectPermissionTo(player, "command.kick", false)) then for id, players in ipairs(getElementsByType("player")) do local exp = getElementData(players, "Exp") local exps = tonumber(getElementData(players, "Exp")) if not exp then setElementData(players, "Exp", 0) else setElementData(players, "Exp", exps + 100) triggerClientEvent(players,"xplevel",players) end end end end addCommandHandler("chuvaxp", ChuvaXP) function ChuvaXPO (player) if (hasObjectPermissionTo(player, "general.tab_bans", false)) then outputChatBox ("#106FE7(#ffffffCHUVA XP#106FE7) ➺ #ffffff".. getPlayerName(player) .." #FFFFFFDeu #106FE7(#FFFFFFXP: #106FE7100 #106FE7) #FFFFFFPara Todos", root, 255, 255, 255, true) end end addCommandHandler("chuvaxp", ChuvaXPO) 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", 0) setElementData(source, "Exp", 0) setAccountData(c, "exp", 0) setAccountData(c, "lvl", 0) end end) addEventHandler("onPlayerQuit", root, function() local acc = getPlayerAccount(source) if acc and not isGuestAccount(acc) then local lvl = getElementData(source, "Level") or 0 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", 0) end end end) addCommandHandler("setlevel", function(player, cmd, target, amount) local accName = getAccountName(getPlayerAccount(player)) if not isObjectInACLGroup ("user."..accName, aclGetGroup("CDD|superMOD")) 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("Você instalou com sucesso "..amount.." 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: / setlevel [Nickname] [Level]", player, 255, 0, 0) end else outputChatBox("Use: / setlevel [Nickname] [Level]", player, 255, 0, 0) end end) --trabalho que quero que quando o player finalize receba exp MarkerSafeEntregadorDeJornal = createMarker( 1280.835, -1541.986, 13.522, "cylinder", 35, 0, 255, 0, 0) EntregadorDeJornalPickup = createPickup ( 1280.835, -1541.986, 13.522, 3, 1210) MarkerEntregadorDeJornal = createMarker ( 1280.835, -1541.986, 13.522, "cylinder", 1.2, 255, 255, 255, 0 ) attachElements ( MarkerEntregadorDeJornal, EntregadorDeJornalPickup, 0, 0, -1 ) BlipEntregadorDeJornal = createBlipAttachedTo ( MarkerEntregadorDeJornal, 42 ) setBlipVisibleDistance ( BlipEntregadorDeJornal, 150 ) function CancelarSumirPickup ( player ) cancelEvent() end addEventHandler ( "onPickupHit", EntregadorDeJornalPickup, CancelarSumirPickup ) LetraParaMarkers = "k" cmd1 = "hq" cmd2 = "profissao" local HQEntregadorDeJornalBlip = createBlip ( 1280.835, -1541.986, 13.522 ) setElementVisibleTo ( HQEntregadorDeJornalBlip, root, false ) -------------------------------------------------------------------- function VerificarBlipEmprego(player) if player then acc = getPlayerAccount ( player ) if isGuestAccount ( acc ) then return end setElementVisibleTo ( HQEntregadorDeJornalBlip, player, false ) end end setTimer( function() for i, pl in pairs(getElementsByType("player")) do if pl ~= (false or nil) then if getElementData ( pl, "Emprego" ) == "Entregador de Jornal" then return end VerificarBlipEmprego(pl) end end end, 3000,0) -------------------------------------------------------------------- function ComandoHQ ( source ) if getElementData ( source, "Emprego" ) == "Entregador de Jornal" then if isElementVisibleTo ( HQEntregadorDeJornalBlip, source ) then setElementVisibleTo ( HQEntregadorDeJornalBlip, source, false ) exports.Scripts_Dxmessages:outputDx(source, "Seu Local de Trabalho foi Desmarcado do Mapa!", "info") else setElementVisibleTo ( HQEntregadorDeJornalBlip, source, true ) exports.Scripts_Dxmessages:outputDx(source, "Seu Local de Trabalho foi Marcado no Mapa!", "info") end end end addCommandHandler ( cmd1, ComandoHQ ) -------------------------------------------------------------------- function AceitarEmprego02 (source) exports.Scripts_OnMarkerMsgs_:delete(source) unbindKey ( source, LetraParaMarkers, "down", AceitarEmprego02 ) if getElementData ( source, "AirNew>Encaminhamento" ) == "Entregador de Jornal" then setElementData ( source, "AirNew>Encaminhamento", false ) setElementData ( source, "Emprego", "Entregador de Jornal" ) exports.Scripts_Dxmessages:outputDx(source, "Você Agora Trabalha de Entregador de Jornal, Para Mais Informações Digite ( /Profissao )", "success") else exports.Scripts_Dxmessages:outputDx(source, "Você Precisa Estar Encaminhado da Agencia de Empregos para Trabalhar neste Local!", "error") end end function RecusarEmprego02 (source) exports.Scripts_OnMarkerMsgs_:delete(source) unbindKey ( source, LetraParaMarkers, "down", RecusarEmprego02 ) if isElementVisibleTo ( HQEntregadorDeJornalBlip, source ) then setElementVisibleTo ( HQEntregadorDeJornalBlip, source, false ) end removeElementData ( source, "Emprego", "Entregador de Jornal" ) exports.Scripts_Dxmessages:outputDx(source, "Você se Demitiu do Emprego de Entregador de Jornal com Sucesso!", "warning") end -------------------------------------------------------------------- function ComandosProf ( ThePlayer ) if getElementData ( ThePlayer, "Emprego" ) == "Entregador de Jornal" then playSoundFrontEnd ( ThePlayer, 43 ) outputChatBox ( "#F9A631~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #F96031Profissão #F9A631~~~~~~~~~~~~~~~~~~~~~~~~~~~~", ThePlayer, 255, 255, 255, true ) outputChatBox ( "#F96031» #BEE09AComandos da Profissão de Entregador de Jornal", ThePlayer, 255, 255, 255, true ) outputChatBox ( "#F96031» #55D444/HQ #ffffff- #9ABDE0Para Marcar / Desmarcar o seu Local de Trabalho", ThePlayer, 255, 255, 255, true ) outputChatBox ( "#F96031» #55D444/Rotas #ffffff- #9ABDE0Abre a Lista de Rotas Disponiveis Para Trabalhar", ThePlayer, 255, 255, 255, true ) outputChatBox ( "#F96031» #FFD700Entre na Bike e Digite /Rotas Selecione uma Rota e Siga os Checkpoints!", ThePlayer, 255, 255, 255, true ) outputChatBox ( "#F9A631~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #F96031Profissão #F9A631~~~~~~~~~~~~~~~~~~~~~~~~~~~~", ThePlayer, 255, 255, 255, true ) end end addCommandHandler(cmd2, ComandosProf ) -------------------------------------------------------------------- function emarker(marker,md) if (md) then if isPedInVehicle ( source ) then return end if marker == MarkerEntregadorDeJornal then if getElementData ( source, "Emprego" ) == "Entregador de Jornal" then exports.Scripts_OnMarkerMsgs_:create(source,"Aperte 'K' Para se Demitir do Emprego de Entregador de Jornal") bindKey ( source, LetraParaMarkers, "down", RecusarEmprego02 ) else exports.Scripts_OnMarkerMsgs_:create(source,"Aperte 'K' Para Aceitar o Emprego de Entregador de Jornal") bindKey ( source, LetraParaMarkers, "down", AceitarEmprego02 ) end end end end addEventHandler("onPlayerMarkerHit",getRootElement(),emarker) function lmarker(marker,md) if (md) then if marker == MarkerEntregadorDeJornal then exports.Scripts_OnMarkerMsgs_:delete(source) unbindKey ( source, LetraParaMarkers, "down", AceitarEmprego02 ) unbindKey ( source, LetraParaMarkers, "down", RecusarEmprego02 ) end end end addEventHandler("onPlayerMarkerLeave",getRootElement(),lmarker) function CriarVeiculosComData () VeiculosComDataEntregadorDeJornal = { createVehicle(510, 1271.167, -1527.32, 13.564, 0, 0, 270 ), createVehicle(510, 1271.146, -1529.044, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -2, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -4, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -6, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -8, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -10, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -12, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -14, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -16, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -18, 13.564, 0, 0, 270 ), createVehicle(510, 1271.117, -1531.384 -20, 13.564, 0, 0, 270 ), } for i, veh in ipairs(VeiculosComDataEntregadorDeJornal) do setElementData ( veh, "Emprego", "Entregador de Jornal" ) setVehicleDamageProof(veh,true) setVehicleColor( veh, 0, 0, 0 ) setVehiclePlateText ( veh, "RPGAMING" ) addEventHandler("onVehicleStartEnter", veh, VerificarEmprego ) --addEventHandler("onVehicleExit", veh, SairDoVeiculosComData ) local tx, ty, tz = getElementPosition(veh) local rx, ry, rz = getElementRotation(veh) setVehicleRespawnPosition(veh, tx, ty, tz, rx, ry, rz) end end addEventHandler("onResourceStart", resourceRoot, CriarVeiculosComData ) function VerificarEmprego (thePlayer, seat) local Jogador = getElementData(thePlayer, "Emprego" ) if seat == 0 then if Jogador == "Entregador de Jornal" then else cancelEvent() exports.Scripts_Dxmessages:outputDx(thePlayer, "Esse Veiculo é Exclusivo dos Entregadores de Jornal!", "error") end end end --[[function SairDoVeiculosComData () local veh = source setTimer(function() if getVehicleOccupant(veh) == false then respawnVehicle(veh) end end, 30000, 1) end addEventHandler ( "onPlayerQuit", getRootElement(), SairDoVeiculosComData ) --]] -------------------------------------------------------------------- local rElement = getRootElement() function respawnVehicles(player, seconds) for i, veh in ipairs(VeiculosComDataEntregadorDeJornal) do if isEmpty( veh ) then respawnVehicle ( veh ) end end end setTimer(respawnVehicles, 60000,0) function isEmpty( vehicle ) local passengers = getVehicleMaxPassengers( vehicle ) if type( passengers ) == 'number' then for seat = 0, passengers do if getVehicleOccupant( vehicle, seat ) then return false end end end return true end -------------------------------------------------------------------- atualrotnumberJORNAL = {} ppcikJORNAL = {} blips = {} rotasJORNAL = { ["Entregas de Jornais - Los Santos (1) - 20 Entregas - $670"] = { {1282.185, -1546.146, 13.547}, {1292.531, -1536.74, 13.491}, --{1117.78308, -1030.55933, 31.88287}, --{11270.73914, -1027.27011, 32.35918}, --{1466.25684, -1172.65686, 23.88302}, --{1673.56787, -1169.50952, 23.92861}, --{1791.41406, -1164.77539, 23.82813}, --{2095.31763, -1292.43701, 23.97214}, --{2150.26270, -1291.66003, 23.97753}, --{2352.627019, -1513.26306, 24.00000}, --{2561.87158, -1467.34753, 24.01236}, --{2756.12573, -1180.33130, 69.39844}, --{2863.57446, -1440.18982, 10.95315}, --{2507.24414, -1725.65881, 13.54688}, --{23270.33276, -1721.86511, 13.58705}, --{2228.38867, -1722.77356, 13.55438}, --{2175, -1742, 13.55438}, --{2072.61230, -1793.96008, 13.54688}, --{1871.15784, -1923.91858, 13.54688}, --{1352.39136, -1758.33508, 13.50781}, }, ["Entregas de Jornais - Los Santos (2) - 20 Entregas - $750"] = { {823.93018, -1413.86011, 13.46503}, {2709.32098, -1504.01135, 13.54223}, {797.72333, -1580.373270, 13.54688}, {645.75140, -1694.06555, 14.89330}, {422.36475, -1758.63403, 8.18526}, {305.55188, -1771.70020, 4.54249}, {168.62589, -1770.10681, 4.43438}, {138.38370, -1460.07129, 25.62103}, {169.82892, -1348.34363, 69.36220}, {280.87973, -1320.37817, 53.81308}, {543.01135, -1202.30334, 44.50127}, {562.19452, -1060.57458, 74.59800}, {782.98035, -808.70764, 65.19865}, {2708.08984, -684.05566, 116.23006}, {1091.30396, -627.89929, 111.38203}, {1280.77197, -614.80652, 102.93521}, {1437.30725, -935.30865, 36.26117}, {1335.64368, -1066.11133, 27.87136}, {1144.98792, -1131.54431, 23.82813}, {1022.52026, -1122.13037, 23.87152}, }, ["Entregas de Jornais - Los Santos (3) - 20 Entregas - $1500"] = { {1324.671, -1433.923, 14.969}, {1184.128, -1316.365, 13.573}, {1096.775, -1288.524, 13.554}, {994.57, -1298.388, 13.39}, {814.181, -1342.959, 13.533}, {792.273, -1626.558, 13.391}, {1077.013, -1859.017, 13.547}, {1408.296, -1881.205, 13.547}, {1830.151, -1841.683, 13.578}, {1924.561, -1789.748, 13.383}, {2096.031, -1806.206, 13.552}, {2289.097, -1724.15, 13.547}, {2268.405, -1667.375, 15.377}, {2011.597, -1597.769, 13.572}, {1911.033, -1604.44, 13.547}, {1864.723, -1604.331, 13.539}, {1671.314, -1583.68, 13.547}, {1581.473, -1448.472, 13.539}, {1519.231, -1449.773, 13.539}, {1363.771, -1431.401, 13.539}, }, } pay = { ["Entregas de Jornais - Los Santos (1) - 20 Entregas - $670"] = 670, ["Entregas de Jornais - Los Santos (2) - 20 Entregas - $750"] = 750, ["Entregas de Jornais - Los Santos (3) - 20 Entregas - $1500"] = 1500, } function ifPlayerEnterOnMarker(markerHit,matchingDimension) if isPedInVehicle(source) then if markerHit == ppcikJORNAL[source] then if (matchingDimension) then if isElement(ppcikJORNAL[source]) then local rname = getElementData(source,"rtnameJornal") or nil if rname == nil then return end destroyElement(ppcikJORNAL[source]) triggerClientEvent(source,"AirNew>JOBEntregadorDeJornal>blips<Client",source,false) local vh = getPedOccupiedVehicle(source) toggleAllControls ( source, false ) setControlState ( source, "handbrake", true ) if atualrotnumberJORNAL[source] <= #rotasJORNAL[rname] then exports.Scripts_Dxmessages:outputDx(source, "Entregando Jornais... Aguarde 2 Segundos!", "info") setTimer(gerarrota,2500,1,source) setTimer(function(source) exports.Scripts_Dxmessages:outputDx(source, "Jornais Entregues, Siga Para o Proximo Checkpoint!", "success") end,2500,1,source) elseif atualrotnumberJORNAL[source] == #rotasJORNAL[rname]+1 then setElementData(source,"rtnameJornal",rname) atualrotnumberJORNAL[source] = 1 local rec = pay[rname] givePlayerMoney(source,tonumber(rec)) local vh = getPedOccupiedVehicle(source) setTimer(function(source) exports.Scripts_Dxmessages:outputDx(source, "Você Recebeu um Valor de $"..rec.." Por Finalizar as Entregas de Jornais!", "success") end,2500,1,source) setTimer(function(source) toggleAllControls ( source, true ) end, 2500,1, source ) setTimer(function(source) setControlState ( source, "handbrake", false ) end, 2500,1, source ) setElementData(source,"rtnameJornal",nil) local exp = getElementData(player, "Exp") local exps = tonumber(getElementData(player, "Exp")) --setElementData(player, "Exp", 0) setElementData(player, "Exp", exps + 100) triggerClientEvent(player,"xplevel",player) end end end end end end addEventHandler("onPlayerMarkerHit",getRootElement(),ifPlayerEnterOnMarker) -------------------------------------------------------------------- function VerificarCairBike(player) if player then acc = getPlayerAccount ( player ) if isGuestAccount ( acc ) then return end local rname = getElementData(player,"rtnameJornal") or nil if rname == nil then triggerClientEvent ( "Desligar:AntiQueda", player ) else triggerClientEvent ( "Ligar:AntiQueda", player ) end end end setTimer( function() for i, pl in pairs(getElementsByType("player")) do if pl ~= (false or nil) then if getElementData ( pl, "Emprego" ) == "Entregador de Jornal" then VerificarCairBike(pl) end end end end, 3000,0) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- function pickjobJornal(source) if not isElement(source) then return end local im = isPedInVehicle(source) if im == false then return end local job = getElementData(source,"Emprego") or false if job == "Entregador de Jornal" then local vh = getPedOccupiedVehicle(source) if isElement(vh) then local x,y = getElementPosition(vh) local x1,y1 = getElementPosition(source) local dist = getDistanceBetweenPoints2D(x,y,x1,y1) local isMarkerSafe = isElementWithinMarker(vh,MarkerSafeEntregadorDeJornal) local id = getElementModel(vh) local seat = getPedOccupiedVehicleSeat(source) if dist > 0 then return end if id == 510 then if seat == 0 then if isMarkerSafe == false then return end triggerClientEvent(source,"AirNew>JOBEntregadorDeJornal>AbrirPainel<Client",source,rotasJORNAL) end end end end end addCommandHandler("rotas",pickjobJornal) function receivert(source,rotaname) if isElement(ppcikJORNAL[source]) then destroyElement(ppcikJORNAL[source]) end triggerClientEvent(source,"AirNew>JOBEntregadorDeJornal>blips<Client",source,false) setElementData(source,"rtnameJornal",rotaname) atualrotnumberJORNAL[source] = 1 gerarrota(source) end addEvent("AirNew>request>Startrota>Server>EntregadorDeJornal", true) addEventHandler("AirNew>request>Startrota>Server>EntregadorDeJornal",getRootElement(), receivert) function gerarrota(source) local rname = getElementData(source,"rtnameJornal") or nil if rname == nil then return end if not isElement(ppcikJORNAL[source]) and isPedInVehicle(source) then local vh = getPedOccupiedVehicle(source) toggleAllControls ( source, true ) setControlState ( source, "handbrake", false ) local id = tonumber(atualrotnumberJORNAL[source]) local x,y,z = rotasJORNAL[rname][id][1],rotasJORNAL[rname][id][2],rotasJORNAL[rname][id][3] ppcikJORNAL[source] = createMarker (x, y,z, "checkpoint", 4, 255, 0, 0, 50,source) triggerClientEvent(source,"AirNew>JOBEntregadorDeJornal>blips<Client",source,true,x,y,z) atualrotnumberJORNAL[source] = id+1 end end function sair ( quitType ) if isElement(ppcikJORNAL[source]) then destroyElement(ppcikJORNAL[source]) end end addEventHandler ( "onPlayerQuit", getRootElement(), sair ) function SairDaBike ( thePlayer, seat, jacked ) local rname = getElementData(thePlayer,"rtnameJornal") or nil if rname == nil then return end canceljobtimer (thePlayer) exports.Scripts_Dxmessages:outputDx(thePlayer, "Você Saiu da Bike, Entregas Canceladas!", "warning") end addEventHandler ( "onVehicleExit", getRootElement(), SairDaBike ) function canceljobtimer(source) if isElement(ppcikJORNAL[source]) then destroyElement(ppcikJORNAL[source]) end triggerClientEvent(source,"AirNew>JOBEntregadorDeJornal>blips<Client",source,false) atualrotnumberJORNAL[source] = 1 setElementData(source,"rtnameJornal",nil) end function canceljobdeath() local job = getElementData(source,"Emprego") or false if job ~= "Entregador de Jornal" then return end local rname = getElementData(source,"rtnameJornal") or nil if rname == nil then return end canceljobtimer(source) exports.Scripts_Dxmessages:outputDx(source, "Você Morreu e Suas Entregas Foram Canceladas!", "warning") end addEventHandler( "onPlayerWasted", getRootElement( ),canceljobdeath) Link to comment
Duff1995 Posted February 2, 2020 Author Share Posted February 2, 2020 o problema é que quando o player termina o trabalho e ganha o dinheiro, nao to conseguindo por pra ele ganhar uma quantia X de exp saca Link to comment
Developer. Posted February 3, 2020 Share Posted February 3, 2020 (edited) Faça o seguinte. Nas linhas 436, 437, 439 e 440 troque player por source. Algumas dicas simples: - Antes de tudo, procure postar suas duvidas nesta seção, pois isto ajuda a manter a organização do fórum: https://forum.multitheftauto.com/forum/127-programação-em-Lua/ - Abaixo vou deixar um post explicando melhor como funciona este fórum: - Sempre que estiver mexendo com seus mods ative o debugscript 3, digitando /debugscript 3 no chat ( para desligar use /debugscript 0). Isto lhe ajuda a identificar o que esta dando erro! - Se você entende quase 0 de scripts de uma olhada nesses posts: Post por manawydan - Lógica de Programação Básica: Post por DNL291 - Informações úteis - Scripting/Configurações/Tutoriais para o MTA: Para finalizar, caso não funcione o script só estar comentando novamente, e por favor se puder informe o erro com uma print ou algo do tipo (não se esqueça de ativar o debugscript!). Facilita bastante a estar te ajudando. Edited February 3, 2020 by Developer. 1 Link to comment
Duff1995 Posted February 3, 2020 Author Share Posted February 3, 2020 (edited) Te amo cara obrigado Edited February 3, 2020 by Lord Henry 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