Jump to content

Just to make sure (Real time)


WolfPire

Recommended Posts

I'm making a script which will get real time when you buy a membership for a team... However i'm not sure if it'll work... For example when the day of end comes... The memebrship will expire and you will no longer be part of said team and you will become unsubscribed...

As for now i can't pass one of the spawn conditionals... Here's the code (Part of it)

function Buy() 
    if MoonPB then 
        local time = getRealTime() 
        local yearday = time.yearday 
        local day = time.monthday 
        local month = time.month + 1 
        local year = time.year 
        local money = getPlayerMoney() 
        if(guiRadioButtonGetSelected(Moon1w))then 
            if money > 10000 then 
            takePlayerMoney(10000) 
            MoonMembership = true 
            local DateMS = yearday 
            local DateME = DateMS + 7 
            setElementData(localPlayer, "player.Moonmemend", DateME, true) 
            setElementData(localPlayer, "player.Moonmem", MoonMembership, true) 
            triggerServerEvent("turnOnMem", root, localPlayer) 
            guiSetVisible(MoonPB, false) 
            guiSetVisible(MoonUB, true) 
            addEventHandler("onClientGUIClick", MoonUB, CancelSub, false) 
            outputChatBox("You bought a 1 week subscription (Today's Date: "..day.."/"..month.."/"..year.."). It will end in 7 days.", 255, 255, 255) 
        end 
        elseif(guiRadioButtonGetSelected(Moon1m))then 
            if money > 50000 then 
            takePlayerMoney(50000) 
            MoonMembership = true 
            local DateMS = yearday 
            local DateME = DateMS + 31 
            setElementData(localPlayer, "player.Moonmemend", DateME, true) 
            setElementData(localPlayer, "player.Moonmem", MoonMembership, true) 
            triggerServerEvent("turnOnMem", root, localPlayer) 
            guiSetVisible(MoonPB, false) 
            guiSetVisible(MoonUB, true) 
            addEventHandler("onClientGUIClick", MoonUB, CancelSub, false) 
            outputChatBox("You bought a 1 month subscription (Today's Date: "..day.."/"..month.."/"..year.."). It will end in 31 days.", 255, 255, 255) 
        end 
        elseif(guiRadioButtonGetSelected(Moon6m))then 
            if money > 100000 then 
            takePlayerMoney(100000) 
            MoonMembership = true 
            local DateMS = yearday 
            local DateME = DateMS + 182 
            setElementData(localPlayer, "player.Moonmemend", DateME, true) 
            setElementData(localPlayer, "player.Moonmem", MoonMembership, true) 
            triggerServerEvent("turnOnMem", root, localPlayer) 
            guiSetVisible(MoonPB, false) 
            guiSetVisible(MoonUB, true) 
            addEventHandler("onClientGUIClick", MoonUB, CancelSub, false) 
            outputChatBox("You bought a 6 month subscription (Today's Date: "..day.."/"..month.."/"..year.."). It will end in 182 days.", 255, 255, 255) 
        end 
        elseif(guiRadioButtonGetSelected(Moon1y))then 
            if money > 500000 then 
            takePlayerMoney(500000) 
            MoonMembership = true 
            local DateMS = yearday 
            local DateME = DateMS + 364 
            setElementData(localPlayer, "player.Moonmemend", DateME, true) 
            setElementData(localPlayer, "player.Moonmem", MoonMembership, true) 
            triggerServerEvent("turnOnMem", root, localPlayer) 
            guiSetVisible(MoonPB, false) 
            guiSetVisible(MoonUB, true) 
            addEventHandler("onClientGUIClick", MoonUB, CancelSub, false) 
            outputChatBox("You bought a yearly subscription (Today's Date: "..day.."/"..month.."/"..year.."). It will end in 364 days.", 255, 255, 255) 
        end 
    end 
    end 
end 
  
  
  
---Spawn--- 
  
function onSpawn() 
    local isOn = getElementData(localPlayer, "player.Moonmemturn") 
    local Member = getElementData(localPlayer, "player.Moonmem") 
    local MemberEnd = getElementData(localPlayer, "player.Moonmemend") 
    if source == localPlayer then 
        if not yearday == MemberEnd then 
            if Member == true then 
                if isOn == true then 
                triggerServerEvent("turnOnSpawn", root, localPlayer) 
                setTimer(outputChatBox, 3000, 1, "☬Moon Member Check........", 255, 255, 255) 
                setTimer(outputChatBox, 5000, 1, "☬Moon Member Check........Done!", 255, 255, 255) 
                else 
                outputChatBox("☬Advice: Your Member tag is not on, if you want to turn it on do /moonon", 0, 150, 255) 
            end 
        end 
    end 
end 
end 
addEventHandler("onClientPlayerSpawn", root, onSpawn) 
  
  

Help is appreciated :):D

Link to comment
function Buy() 
    if MoonPB then 
        local time = getRealTime() 
        local yearday = time.yearday 
        local day = time.monthday 
        local month = time.month + 1 
        local year = time.year 
        local money = getPlayerMoney() 
        if(guiRadioButtonGetSelected(Moon1w))then 
            if money > 10000 then 
                takePlayerMoney(10000) 
                MoonMembership = true 
                local DateMS = yearday 
                local DateME = DateMS + 7 
                setElementData(localPlayer, "player.Moonmemend", DateME, true) 
                setElementData(localPlayer, "player.Moonmem", MoonMembership, true) 
                triggerServerEvent("turnOnMem", root, localPlayer) 
                guiSetVisible(MoonPB, false) 
                guiSetVisible(MoonUB, true) 
                addEventHandler("onClientGUIClick", MoonUB, CancelSub, false) 
                outputChatBox("You bought a 1 week subscription (Today's Date: "..day.."/"..month.."/"..year.."). It will end in 7 days.", 255, 255, 255) 
            end 
        elseif(guiRadioButtonGetSelected(Moon1m))then 
            if money > 50000 then 
                takePlayerMoney(50000) 
                MoonMembership = true 
                local DateMS = yearday 
                local DateME = DateMS + 31 
                setElementData(localPlayer, "player.Moonmemend", DateME, true) 
                setElementData(localPlayer, "player.Moonmem", MoonMembership, true) 
                triggerServerEvent("turnOnMem", root, localPlayer) 
                guiSetVisible(MoonPB, false) 
                guiSetVisible(MoonUB, true) 
                addEventHandler("onClientGUIClick", MoonUB, CancelSub, false) 
                outputChatBox("You bought a 1 month subscription (Today's Date: "..day.."/"..month.."/"..year.."). It will end in 31 days.", 255, 255, 255) 
            end 
        elseif(guiRadioButtonGetSelected(Moon6m))then 
            if money > 100000 then 
                takePlayerMoney(100000) 
                MoonMembership = true 
                local DateMS = yearday 
                local DateME = DateMS + 182 
                setElementData(localPlayer, "player.Moonmemend", DateME, true) 
                setElementData(localPlayer, "player.Moonmem", MoonMembership, true) 
                triggerServerEvent("turnOnMem", root, localPlayer) 
                guiSetVisible(MoonPB, false) 
                guiSetVisible(MoonUB, true) 
                addEventHandler("onClientGUIClick", MoonUB, CancelSub, false) 
                outputChatBox("You bought a 6 month subscription (Today's Date: "..day.."/"..month.."/"..year.."). It will end in 182 days.", 255, 255, 255) 
            end 
        elseif(guiRadioButtonGetSelected(Moon1y))then 
            if money > 500000 then 
                takePlayerMoney(500000) 
                MoonMembership = true 
                local DateMS = yearday 
                local DateME = DateMS + 364 
                setElementData(localPlayer, "player.Moonmemend", DateME, true) 
                setElementData(localPlayer, "player.Moonmem", MoonMembership, true) 
                triggerServerEvent("turnOnMem", root, localPlayer) 
                guiSetVisible(MoonPB, false) 
                guiSetVisible(MoonUB, true) 
                addEventHandler("onClientGUIClick", MoonUB, CancelSub, false) 
                outputChatBox("You bought a yearly subscription (Today's Date: "..day.."/"..month.."/"..year.."). It will end in 364 days.", 255, 255, 255) 
            end 
        end 
    end 
end 
  
  
  
---Spawn--- 
  
function onSpawn() 
    local isOn = getElementData(localPlayer, "player.Moonmemturn") 
    local Member = getElementData(localPlayer, "player.Moonmem") 
    local MemberEnd = getElementData(localPlayer, "player.Moonmemend") 
    if source == localPlayer then 
        if not yearday == MemberEnd then 
            if Member == true then 
                if isOn == true then 
                triggerServerEvent("turnOnSpawn", root, localPlayer) 
                setTimer(outputChatBox, 3000, 1, "?Moon Member Check........", 255, 255, 255) 
                setTimer(outputChatBox, 5000, 1, "?Moon Member Check........Done!", 255, 255, 255) 
                else 
                    outputChatBox("?Advice: Your Member tag is not on, if you want to turn it on do /moonon", 0, 150, 255) 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientPlayerSpawn", root, onSpawn) 

use

setAccountData,getAccountData 

For save all in account

setElementData - it can store a temporary data

Link to comment

Suddenly, 4 hours ago realized i should have used "setAccountData" and "getAccountData" thanks for clarifing me the doubt...

And yes... While doing one of my recent scripts i noticed aswell when i re-checked in the wiki that it only takes clientside money...

Thanks for the support guys. however... Am i doing right with dates and stuff?

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...