Jump to content

Mission time


MaRcell

Recommended Posts

I have a mission system , to put a time so that the player can make the mission on 1 and 1 day

-- server 
local playerMission = nil -- jogador da missao 
local markerMission = createMarker(2500.74951, -1674.49402, 12.35166,"cylinder", 2, 255, 0, 0, 255) -- pode continuar kk 
local blipMission = createBlip (2500.74951 ,-1674.49402, 13.35166 ,15) 
local blipDestination = nil 
local botPrincipal = nil 
local botMissionTeam = createTeam("botMissionTeam",0,0,0) 
  
function onMarkerMissionHit(Element) 
    local t = getElementType(Element) 
    if(t == "player" and playerMission == nil)then  
    playerMission = Element 
    outputChatBox("Va ate a bandeira vermelha mata uns bot") 
    blipDestination = createBlip(2324.74756, -1532.23267, 25.34375)---pronto 
    botPrincipal = exports [ "slothBot" ]:spawnBot(2289.10254 ,-1528.64917 ,26.87500,90,104,0,0,botMissionTeam,31,"guarding") 
    addEventHandler("onPedWasted",botPrincipal,onPedWasted) 
    addEventHandler("onPlayerWasted",playerMission,PlayerPrincipalPerde) 
    addEventHandler("onPlayerQuit",playerMission,PlayerPrincipalPerde) 
  
    for i=1,4 do  
    randomBot = exports [ "slothBot" ]:spawnBot(2289.10254+math.cos(math.rad(math.random(0,360)))*math.random(-3,3),-1528.64917+math.sin(math.rad(math.random(0,360)))*math.random(-3,3),29.87500,90,103,0,0,botMissionTeam,31,"hunting") 
    setElementData(randomBot,"botMissionKill",true) 
    end 
  
    end 
end 
addEventHandler("onMarkerHit",markerMission,onMarkerMissionHit) -- n exatamente faltas coisa tanto no blips quanto o marker 
  
function onPedWasted() -- quando o bot principal morrer o que acontece? 
givePlayerMoney (playerMission, 20000) 
exports.Manawydan_expSystem:addPlayerExp(playerMission,10)-- da 50 de exp 
outputChatBox( '#ffffffMISSAO COMPLETA +20MIl.',playerMission,255,255,255,true) 
destroyElement(blipDestination) 
blipDestination = nil 
removeEventHandler("onPedWasted",botPrincipal,onPedWasted) -- pode ser denecessario 
removeEventHandler("onPlayerWasted",playerMission,PlayerPrincipalPerde) 
removeEventHandler("onPlayerQuit",playerMission,PlayerPrincipalPerde) 
playerMission = nil 
 MatarBotsVivos() 
end 
  
function PlayerPrincipalPerde() 
    outputChatBox("missao fracassada voce morreu",playerMission) 
     
    removeEventHandler("onPedWasted",botPrincipal,onPedWasted) 
    removeEventHandler("onPlayerWasted",playerMission,PlayerPrincipalPerde) 
    removeEventHandler("onPlayerQuit",playerMission,PlayerPrincipalPerde) 
    destroyElement(blipDestination) 
    blipDestination = nil 
    playerMission = nil 
        MatarBotsVivos() 
end 
  
function MatarBotsVivos() 
    if(botPrincipal and isElement(botPrincipal))then destroyElement(botPrincipal) end -- destruir bot se exitir 
    local allPeds = getElementsByType("ped") -- pega todos os peds 
    for k,v in ipairs (allPeds) do 
        if(getElementData(v,"botMissionKill"))then  -- checa se tem a data da missao 
            destroyElement(v) -- destroi eles 
            end 
      end 
       botPrincipal = nil 
end 

Link to comment

First you'd have to store the information on a database. After that step all what's coming it's easy.

- Player gets done the mission.

- You get the current date, and you store it on a column.

- When the player is thinking about making a mission, get the current date, and subtract it to the stored date. After that you just need to use an statment to compare the operation result with 1 day.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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