Adde Posted August 25, 2013 Share Posted August 25, 2013 Hello, I have a question about a system I am going to create that should count/remember days. Because I am going to create a script that adds a player to an acl group when he buys amount of days ingame for ingame money and then removes him x days later. And the question is, how can I do that? ( with counting days ). I am most thinking about if server restarts, the player leave, script restarts, etc and the script will still do exactly as it was told from the beginning/when player bought days. I hope that anyone can help me. Ask me more if you don´t understand what I mean. Link to comment
PotatoHead Posted August 26, 2013 Share Posted August 26, 2013 Not a pro at this but I am just suggesting a few things. getAccountData setAccountData Link to comment
denny199 Posted August 26, 2013 Share Posted August 26, 2013 Not a pro at this but I am just suggesting a few things. getAccountData setAccountData Thats for setting the data, just convert the day that the player will be removed from the ACL, and then check everytime the date when the player is logging in. Let's take an example; I'm buying sMod on your server, the data will store on my account until 01/09/2013, and i'm directly added to the ACL group. I'm logging again in on 30/08/2013, the script will check and do nothing I'm logging again in on 02/09/2013, the script will check again and will remove me from the list. This function also might help you: https://wiki.multitheftauto.com/wiki/GetRealTime Good luck Link to comment
Adde Posted August 26, 2013 Author Share Posted August 26, 2013 Thx! Okay ( quick example ) so If I have: local theDays = guiGetText ( editBox1 ) then I can do something like function vipShop(thePlayer) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(thePlayer) local time = getRealTime() local date = time.monthday if ( date = 1-1 ) and ( theDays = 10 ) then setAccountData(account, "1-11", VIPdate) aclGroupAddObject (aclGetGroup("VIP"), "user."..accountName)) end end end addEventhandler("onClientGUIClick", button1, vipShop) function checkRemoveDate(thePlayer) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(thePlayer) local time = getRealTime() local date = time.monthday getAccountData(account,"VIPdate") if ( VIPdate = 1-11 ) and ( date = 1-11 ) then aclGroupRemoveObject(aclGetGroup("VIP"), "user."..accountName) else return end end end addEventHandler("onPlayerLogin", getRootElement, checkRemoveDate) or can I do it on a easier way? like using set the remove date ( 1-1 + 10 )? I just remembered, "local theDays = guiGetText ( editBox1 )" i can´t use that in server side. Then i have to use triggerClientEvent right? Link to comment
Castillo Posted August 26, 2013 Share Posted August 26, 2013 You've got an error there, it's "addEventHandler" not "addEventhandler": Link to comment
Adde Posted August 27, 2013 Author Share Posted August 27, 2013 Wops, didn´t see that. I got this far, open/close gui if player isn´t in acl group VIP and wrote some functions how I think that it should be and with no errors in debug. But no function will trigger. I know that I have guiGetText server side, I know that it´s wrong and make server wont work. But I can´t figure out any other solution. server function addToACL() local account = getplayerAccount(thePlayer) local accountName = getAccountName(thePlayer) local number = guiGetText(editBox1) local time = getRealTime() local date = time.monthday local endDate = date+number setAccountData(account, "aclRemove", endDate) aclGroupAddObject(aclGetGroup("VIP"), "user."..accountName) end addEvent("buyVIP", true) addEventHandler("buyVIP", getRootElement(), addToACL) function removeFromACLGroup() local account = getPlayerAccount(thePlayer) local accountName = getAccountName(account) local removeDate = getAccountData(account,"aclRemove") local time = getRealTime() local todayDate = time.monthday if ( removeDate ) == ( todayDate ) then aclGroupRemoveObject (aclGetGroup("VIP"), "user."..accountName) else return end end addEventHandler("onPlayerLogin", getRootElement(), removeFromACLGroup) function theGUIshow(thePlayer) local account = getPlayerAccount(thePlayer) local accName1 = getAccountName(account) if ( not isObjectInACLGroup ("user."..accName1, aclGetGroup ( "VIP" ) ) ) then triggerClientEvent(thePlayer,"show", thePlayer) end end function BindHere() bindKey(source, "F5", "down", theGUIshow) end addEventHandler("onPlayerLogin",getRootElement(),BindHere) client x, y = guiGetScreenSize() GUIEditor = { button = {}, window = {}, label = {}, edit = {} } VIPbuyPanel = guiCreateWindow(x*0.420, y*0.360, 228, 156, "VIP buy panel", false) guiWindowSetSizable(VIPbuyPanel, false) guiSetVisible(VIPbuyPanel, false) guiSetAlpha(VIPbuyPanel, 0.96) GUIEditoredit = guiCreateEdit(9, 31, 115, 36, "", false, VIPbuyPanel) GUIEditorbutton = guiCreateButton(134, 29, 85, 38, "Buy VIP", false, VIPbuyPanel) guiSetProperty(VIPbuyPanel, "NormalTextColour", "FFAAAAAA") GUIEditorlabel = guiCreateLabel(10, 79, 209, 21, "Enter how many VIP days you want", false, VIPbuyPanel) GUIEditorlabel = guiCreateLabel(10, 100, 55, 17, "VIP costs:", false, VIPbuyPanel) GUIEditorlabel = guiCreateLabel(69, 100, 78, 17, "N/A", false, VIPbuyPanel) GUIEditorlabel = guiCreateLabel(9, 124, 60, 18, "Total cost:", false, VIPbuyPanel) GUIEditorlabel = guiCreateLabel(75, 124, 78, 18, "", false, VIPbuyPanel) function onVIPPressBuy() local PlayerMoney = getPlayerMoney(getLocalPlayer()) local amount = guiGetText(GUIEditoredit) local theAmount = amount*30000 if ( PlayerMoney >= theAmount ) then if ( amount >= 1 ) then triggerServerEvent("buyVIP", source) guiSetVisible(VIPbuyPanel, false) showCursor(false) guiSetInputEnabled(false) else outputChatBox("You don´t have enough money for" ..amount.. "days of VIP", getLocalPlayer()) end end end addEventHandler("onClientGUIClick", GUIEditorbutton, onVIPPressBuy) function openGUIbuy() if guiGetVisible(VIPbuyPanel) then guiSetVisible(VIPbuyPanel, false) showCursor(false) guiSetInputEnabled(false) else guiSetVisible(VIPbuyPanel, true) showCursor(true) guiSetInputEnabled(true) end end addEvent("show",true) addEventHandler("show", getLocalPlayer(),openGUIbuy) Will something like this 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