Jump to content

[HELP] getElementData, seAccountData


LabiVila

Recommended Posts

Posted
function onPlayerQuit () 
    playeraccount = getPlayerAccount (source) 
    if (playeraccount) and not isGuestAccount (playeraccount) then 
        local playermoney = getPlayerMoney (source) 
        setAccountData (playeraccount, "piraterpg.money", playermoney) 
    end 
end 
addEventHandler ("onPlayerQuit", getRootElement(getThisResource()), onPlayerQuit) 
  
function onPlayerLogin (_, playeraccount) 
    if (playeraccount) then 
        local playermoney = getAccountData (playeraccount, "piraterpg.money") 
        if (playermoney) then 
            setPlayerMoney (source, playermoney) 
        end 
    end 
end 
addEventHandler ("onPlayerLogin", getRootElement(), onPlayerLogin) 
  
------------------------------------------------------------------------------------- 
local hunters = 0 
local deaths = 0 
local starts = 0 
  
function hunterPickups (pickupID, pickupType, vehicleModel) 
    local playeraccount = getPlayerAccount (source) 
    if (playeraccount) and not isGuestAccount (playeraccount) then 
        if pickupType == "vehiclechange" and vehicleModel == 425 then 
            outputChatBox ("one more hunter", source) 
            hunters = hunters + 1 
            triggerClientEvent (source, "hunterADD", source, hunters) 
            if hunters == 10 then 
                removeEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) 
                givePlayerMoney (source, 7500) 
            end 
        end 
    else 
        outputChatBox ("You must be logged in... nab", source) 
    end 
end 
addEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) 
  
function deathADD () 
    local playeraccount = getPlayerAccount (source) 
    if (playeraccount) and not isGuestAccount (playeraccount) then 
        deaths = deaths + 1 
        triggerClientEvent (source, "deathADD", source, deaths) 
        if deaths == 25 then 
            removeEventHandler ("onPlayerRaceWasted", root, addDeath) 
            givePlayerMoney (source, 7500) 
        end 
    else 
        outputChatBox ("You must be logged in fcker", source) 
    end 
end 
addEvent ("onPlayerRaceWasted", true) 
addEventHandler ("onPlayerRaceWasted", root, deathADD) 
  
function addStartPoint (state) 
    local playeraccount = getPlayerAccount (source) 
    if (playeraccount) and not isGuestAccount (playeraccount) then 
        if (state == "Running") then 
            starts = starts + 1 
            triggerClientEvent (source, "startADD", source, starts) 
            if starts == 25 then 
                removeEventHandler ("onRaceStateChanging", root, addStartPoint) 
                givePlayerMoney (source, 7500) 
            end 
        end 
    else 
        outputChatBox ("You must be logged in, LOGGED IN!", source) 
    end 
end 
addEvent ("onRaceStateChanging", true) 
addEventHandler ("onRaceStateChanging", root, addStartPoint) 

Hello, this is my code, and it works cool. But there is something I need to know and haven't ever done it before, if we cut this part:

function hunterPickups (pickupID, pickupType, vehicleModel) 
    local playeraccount = getPlayerAccount (source) 
    if (playeraccount) and not isGuestAccount (playeraccount) then 
        if pickupType == "vehiclechange" and vehicleModel == 425 then 
            outputChatBox ("one more hunter", source) 
            hunters = hunters + 1 
            triggerClientEvent (source, "hunterADD", source, hunters) 
            if hunters == 10 then 
                removeEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) 
                givePlayerMoney (source, 7500) 
            end 
        end 
    else 
        outputChatBox ("You must be logged in... nab", source) 
    end 
end 
addEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) 

how am I possible to do that when the player quits, the hunters = hunters + 1 store on his account, and when he gets back, he has the same hunters amount?

Thanks further

Posted

As soon as he got the Hunter, get his account data, if it exists then hunter = hunter + 1 and then set it on his account. If it doesn't exists, then set it to 1

Posted

Why do you call guest players nab :(

What is this script about?

At the moment, you seem to increase your hunter counter whenever a player gets a hunter.

So why you want to save that for a certain player?

Posted

Calling my players nab is just a test, to see if it's working... I'll surely edit that later.

This script is about some daily rewards, once you hit 10 hunters, you get some money (as you see in the script). I'll make this panel reset every 24 hour, but when a player quits and comes again, players are actually 0, they should be the same number as when they quit... hopefully you got what I'm trying to do.

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