LabiVila Posted August 14, 2014 Share Posted August 14, 2014 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 Link to comment
Et-win Posted August 14, 2014 Share Posted August 14, 2014 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 Link to comment
LabiVila Posted August 16, 2014 Author Share Posted August 16, 2014 Can you give me an example? It's the very first time I'm doing this so... it's a bit hard for me Link to comment
Bonsai Posted August 16, 2014 Share Posted August 16, 2014 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? Link to comment
LabiVila Posted August 16, 2014 Author Share Posted August 16, 2014 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. Link to comment
Bonsai Posted August 16, 2014 Share Posted August 16, 2014 Alright. So, whenever someone gets a hunter use: GetAccountData It returns false if there is no data stored == 0 hunters obviously. Then use: SetAccountData to increase it. To reset you could probably use: GetAccounts to go through all accounts and set the hunters to 0 again. Link to comment
LabiVila Posted August 18, 2014 Author Share Posted August 18, 2014 As said up, this is my very first time doing this so I'd really like an example as I can't make it work... 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