dima3367 Posted October 5, 2017 Share Posted October 5, 2017 Hello! I have such a problem, it's impossible to check the player's money. I have a game mod that uses its own money system. And for example, that the player would give the money to the resource, I have to use the export. Example: exports["tws-main"]:givePlayerMoney I need to do something by analogy to check the player's amount of money. For example, in this function: function StartStudyBtn () if source == StartLessonBtn then local playerLesson = guiGridListGetItemData ( VehicleLessons, guiGridListGetSelectedItem ( VehicleLessons ), 2 ) local Money = guiGridListGetItemText ( VehicleLessons, guiGridListGetSelectedItem ( VehicleLessons ), 3 ) local StudyLevel = getElementData(localPlayer, "VehLevel")+1 if playerLesson and guiGetEnabled(StartLessonBtn) == true then if getPlayerMoney () < tonumber(Money) then outputChatBox("У вас недостаточно денег") else if tonumber(playerLesson) > tonumber(StudyLevel) then outputChatBox("Вы не прошли предыдуший курс") elseif tonumber(playerLesson) < tonumber(StudyLevel) then outputChatBox("Вы уже прошли этот курс") else if (getElementData ( localPlayer, "working") == "1") then setElementModel ( localPlayer, tonumber(getElementData ( localPlayer, "skinback"))) setElementData ( localPlayer, "working", "0" ) end guiSetVisible(LicensePanel,false) showCursor(false) removeEventHandler ( "onClientGUIClick", getRootElement(), ByLicense ,false ) removeEventHandler ( "onClientGUIClick", getRootElement(), StartStudyBtn ,false ) triggerServerEvent("TakePlayerMoney", getRootElement(), localPlayer,Money) setLesson(playerLesson) end end end end end In line 7 there is a check whether the player has enough money. I need to make an appeal to my system of money tws-money. I tried to do so: if localPlayer:getData("tws-money") < tonumber(Money) then But I get an error. How can I do this here? Please tell me. I apologize for the bad english. Link to comment
Moderators IIYAMA Posted October 5, 2017 Moderators Share Posted October 5, 2017 local money = exports["tws-main"]:getPlayerMoney() iprint(money) I do not know that resource, if you check the meta.xml file of tws-main you can see the export functions that are available. Link to comment
dima3367 Posted October 6, 2017 Author Share Posted October 6, 2017 There is here such request: <export function="getPlayerMoney" type="server"/> But he server, and the code snippet I sent above, client. How to be? Link to comment
Dimos7 Posted October 6, 2017 Share Posted October 6, 2017 you can change the type to share i think Link to comment
Moderators IIYAMA Posted October 6, 2017 Moderators Share Posted October 6, 2017 Changing the type to share will not solve the issue, because that means that the function should be created on both sides of the resource: tws-main Thought it will look like it is working because getPlayerMoney already exist as a MTA default function. There is a tutorial for this issue: 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