SirniNamaz Posted August 17, 2012 Share Posted August 17, 2012 i have a label which is a number and it is different for every player.. what i need is script that will save it when players disconnect and load it when players connect Link to comment
Taalasmaa Posted August 17, 2012 Share Posted August 17, 2012 Well for the client: addEvent("getLabelTxt",true) addEventHandler("getLabelTxt",getRootElement(), function() textt = guiGetText(mylabelnamehere) -- PUT YOUR LABEL NAME HERE triggerServerEvent("saveLabelTxt",getLocalPlayer(),getLocalPlayer(),textt) -- we will send it to the server end) and the server: function getTextQuit() triggerClientEvent(source,"getLabelTxt",getRootElement()) -- trigger client end addEventHandler("onPlayerQuit",getRootElement(),getTextQuit) -- save addEvent("saveLabelTxt",true) addEventHandler("saveLabelTxt",getRootElement(), function(player,text) playeraccount = getPlayerAccount(player) if (playeraccount) and (text) then setAccountData(playeraccount,"number",tonumber(text)) -- save it end end) -- load function loadTextNumb() playeraccount = getPlayerAccount(source) if (playeraccount) then number = getAccountData(playeraccount,"number") -- DO WHATEVER YOU WANT WITH THE NUMBER ARGUEMENT end end addEventHandler("onPlayerLogin",getRootElement(),loadTextNumb) The code looks messy and I don't guarantee that it'll work. Link to comment
SirniNamaz Posted August 17, 2012 Author Share Posted August 17, 2012 i dont actually understand your code, but can you make the code for the following labels pls: - lblCannabis - lblHeroin - lblCocaine - lblLSD - lblEcstasy - lblOpium (i will put your name in credits when i post this resource) every player has different value, and the only thing im asking for is to save that number when player disconnects, and load it when he connects Link to comment
Taalasmaa Posted August 17, 2012 Share Posted August 17, 2012 i dont actually understand your code, but can you make the code for the following labels pls:- lblCannabis - lblHeroin - lblCocaine - lblLSD - lblEcstasy - lblOpium (i will put your name in credits when i post this resource) every player has different value, and the only thing im asking for is to save that number when player disconnects, and load it when he connects You can figure it out by yourself It's not really that hard. Link to comment
SirniNamaz Posted August 17, 2012 Author Share Posted August 17, 2012 ok, i got it now, but how do i make it write '0' if it cant find the value (loading first time) Link to comment
Taalasmaa Posted August 17, 2012 Share Posted August 17, 2012 Glad you got it working by yourself. Just edit the server load function like this: -- load function loadTextNumb() playeraccount = getPlayerAccount(source) if (playeraccount) then number = getAccountData(playeraccount,"number") if (number) then -- DO WHATEVER YOU WANT WITH THE NUMBER ARGUEMENT else -- No number found.. New player triggerClientEvent(source,"firstTime",getRootElement()) end end end addEventHandler("onPlayerLogin",getRootElement(),loadTextNumb) and add client: addEvent("firstTime",true) addEventHandler("firstTime",getRootElement(), function() guiSetText(myLabelNameHere,"0") end) Link to comment
SirniNamaz Posted August 17, 2012 Author Share Posted August 17, 2012 Glad you got it working by yourself.Just edit the server load function like this: -- load function loadTextNumb() playeraccount = getPlayerAccount(source) if (playeraccount) then number = getAccountData(playeraccount,"number") if (number) then -- DO WHATEVER YOU WANT WITH THE NUMBER ARGUEMENT else -- No number found.. New player triggerClientEvent(source,"firstTime",getRootElement()) end end end addEventHandler("onPlayerLogin",getRootElement(),loadTextNumb) and add client: addEvent("firstTime",true) addEventHandler("firstTime",getRootElement(), function() guiSetText(myLabelNameHere,"0") end) i thought i make it work but i didnt, and i postet the entire script to this theard and i hope you can help me: viewtopic.php?f=91&t=46802 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