Unique Posted August 21, 2020 Share Posted August 21, 2020 (edited) How to add in paynspray-system repair costs in main window? Tried to add ..estimatedCosts.. but didn't worked. Screenshot: Code: client Spoiler loadstring(exports.dgs:dgsImportFunction())() local sW,sH = guiGetScreenSize() local wx,wy = (sW/2)-150,(sH/2)-100 addEvent("receiveAnswer",true) addEvent("showRepairGui",true) addEventHandler("showRepairGui",getLocalPlayer(), function(vehicle,col) local x,y,z = getElementPosition(getLocalPlayer()) main = dgsCreateWindow(wx, wy, 300, 200, "Los Santos Customs",false,_,_,_,tocolor(85,155,255,200),_,tocolor(15,15,15,200),_,true) local w,h = dgsGetSize(main) label = dgsCreateLabel(5,25,w,15,"Welcome to vehicle repair garage!",false,main) label2 = dgsCreateLabel(5,45,w,15,"Fix your: "..exports.global:getVehicleName(vehicle).."?",false,main) label3 = dgsCreateLabel(5,65,w,15,"Repair cost: $",false,main) -- ..estimatedCosts dgsLabelSetHorizontalAlign( label, "center" ) dgsLabelSetHorizontalAlign( label2, "center" ) dgsLabelSetHorizontalAlign( label3, "center" ) accept = dgsCreateButton(0,120,w,26,"Fix Vehicle",false,main) cancel = dgsCreateButton(0,150,w,26,"Close",false,main) dgsSetProperty(cancel,"font", "default-bold") dgsSetProperty(cancel,"color",{tocolor(85,155,255,200),tocolor(85,155,255,100),tocolor(200,100,0,255)}) dgsSetProperty(accept,"font", "default-bold") dgsSetProperty(accept,"color",{tocolor(85,155,255,200),tocolor(85,155,255,100),tocolor(200,100,0,255)}) dgsSetProperty(main,"font", "default-bold") showCursor(true) addEventHandler("onDgsMouseClick",accept,function(button,state) if button == "left" and state == "down" then if vehicle and col then triggerServerEvent("triggerRepair",resourceRoot,vehicle,getLocalPlayer(),col) dgsCloseWindow(main) showCursor(false) end end end) addEventHandler("onDgsMouseClick",cancel,function(button,state) if button == "left" and state == "down" then if vehicle and col then dgsCloseWindow(main) showCursor(false) end end end) end) Edited August 21, 2020 by Danex Link to comment
Moderators Patrick Posted August 21, 2020 Moderators Share Posted August 21, 2020 (edited) estimatedCosts isn't defined, so it's nil. (nothing) Edited August 21, 2020 by Patrick 1 Link to comment
Unique Posted August 21, 2020 Author Share Posted August 21, 2020 12 minutes ago, Patrick said: estimatedCosts isn't defined, so it's nil. (nothing) ouh.. okay. mby you can tell me what i need put there?(( Link to comment
Moderators Patrick Posted August 21, 2020 Moderators Share Posted August 21, 2020 (edited) You have to calculate the price, or isn't changing? Edited August 21, 2020 by Patrick Link to comment
Unique Posted August 21, 2020 Author Share Posted August 21, 2020 10 minutes ago, Patrick said: You have to calculate the price, or isn't changing? local playerMoney = exports.global:getMoney(thePlayer, true) if (estimatedCosts > playerMoney) then toFix = playerMoney / costDamageRatio else completefix = true toFix = damage end estimatedCosts = math.floor ( toFix * costDamageRatio )? Link to comment
Moderators Patrick Posted August 21, 2020 Moderators Share Posted August 21, 2020 55 minutes ago, Danex said: local playerMoney = exports.global:getMoney(thePlayer, true) if (estimatedCosts > playerMoney) then toFix = playerMoney / costDamageRatio else completefix = true toFix = damage end estimatedCosts = math.floor ( toFix * costDamageRatio )? Is this on server side? You have to calculate this on client-side too. Link to comment
Unique Posted August 21, 2020 Author Share Posted August 21, 2020 1 hour ago, Patrick said: Is this on server side? You have to calculate this on client-side too. this is client side Link to comment
Moderators Patrick Posted August 21, 2020 Moderators Share Posted August 21, 2020 6 minutes ago, Danex said: this is client side then show the full client sided code Link to comment
Unique Posted August 21, 2020 Author Share Posted August 21, 2020 (edited) 9 minutes ago, Patrick said: then show the full client sided code Spoiler loadstring(exports.dgs:dgsImportFunction())() local sW,sH = guiGetScreenSize() local wx,wy = (sW/2)-150,(sH/2)-100 addEvent("receiveAnswer",true) addEvent("showRepairGui",true) addEventHandler("showRepairGui",getLocalPlayer(), function(vehicle,col) local x,y,z = getElementPosition(getLocalPlayer()) main = dgsCreateWindow(wx, wy, 300, 200, "Los Santos Customs",false,_,_,_,tocolor(85,155,255,200),_,tocolor(15,15,15,200),_,true) local w,h = dgsGetSize(main) label = dgsCreateLabel(5,25,w,15,"Welcome to vehicle repair garage!",false,main) label2 = dgsCreateLabel(5,45,w,15,"Fix your: "..exports.global:getVehicleName(vehicle).."?",false,main) label3 = dgsCreateLabel(5,65,w,15,"Repair cost: $",false,main) -- ..estimatedCosts dgsLabelSetHorizontalAlign( label, "center" ) dgsLabelSetHorizontalAlign( label2, "center" ) dgsLabelSetHorizontalAlign( label3, "center" ) accept = dgsCreateButton(0,120,w,26,"Fix Vehicle",false,main) cancel = dgsCreateButton(0,150,w,26,"Close",false,main) dgsSetProperty(cancel,"font", "default-bold") dgsSetProperty(cancel,"color",{tocolor(85,155,255,200),tocolor(85,155,255,100),tocolor(200,100,0,255)}) dgsSetProperty(accept,"font", "default-bold") dgsSetProperty(accept,"color",{tocolor(85,155,255,200),tocolor(85,155,255,100),tocolor(200,100,0,255)}) dgsSetProperty(main,"font", "default-bold") showCursor(true) addEventHandler("onDgsMouseClick",accept,function(button,state) if button == "left" and state == "down" then if vehicle and col then triggerServerEvent("triggerRepair",resourceRoot,vehicle,getLocalPlayer(),col) dgsCloseWindow(main) showCursor(false) end end end) addEventHandler("onDgsMouseClick",cancel,function(button,state) if button == "left" and state == "down" then if vehicle and col then dgsCloseWindow(main) showCursor(false) end end end) end) Edited August 21, 2020 by Danex Link to comment
Moderators Patrick Posted August 21, 2020 Moderators Share Posted August 21, 2020 8 minutes ago, Danex said: Reveal hidden contents loadstring(exports.dgs:dgsImportFunction())() local sW,sH = guiGetScreenSize() local wx,wy = (sW/2)-150,(sH/2)-100 addEvent("receiveAnswer",true) addEvent("showRepairGui",true) addEventHandler("showRepairGui",getLocalPlayer(), function(vehicle,col) local x,y,z = getElementPosition(getLocalPlayer()) main = dgsCreateWindow(wx, wy, 300, 200, "Los Santos Customs",false,_,_,_,tocolor(85,155,255,200),_,tocolor(15,15,15,200),_,true) local w,h = dgsGetSize(main) label = dgsCreateLabel(5,25,w,15,"Welcome to vehicle repair garage!",false,main) label2 = dgsCreateLabel(5,45,w,15,"Fix your: "..exports.global:getVehicleName(vehicle).."?",false,main) label3 = dgsCreateLabel(5,65,w,15,"Repair cost: $",false,main) -- ..estimatedCosts dgsLabelSetHorizontalAlign( label, "center" ) dgsLabelSetHorizontalAlign( label2, "center" ) dgsLabelSetHorizontalAlign( label3, "center" ) accept = dgsCreateButton(0,120,w,26,"Fix Vehicle",false,main) cancel = dgsCreateButton(0,150,w,26,"Close",false,main) dgsSetProperty(cancel,"font", "default-bold") dgsSetProperty(cancel,"color",{tocolor(85,155,255,200),tocolor(85,155,255,100),tocolor(200,100,0,255)}) dgsSetProperty(accept,"font", "default-bold") dgsSetProperty(accept,"color",{tocolor(85,155,255,200),tocolor(85,155,255,100),tocolor(200,100,0,255)}) dgsSetProperty(main,"font", "default-bold") showCursor(true) addEventHandler("onDgsMouseClick",accept,function(button,state) if button == "left" and state == "down" then if vehicle and col then triggerServerEvent("triggerRepair",resourceRoot,vehicle,getLocalPlayer(),col) dgsCloseWindow(main) showCursor(false) end end end) addEventHandler("onDgsMouseClick",cancel,function(button,state) if button == "left" and state == "down" then if vehicle and col then dgsCloseWindow(main) showCursor(false) end end end) end) I can't see estimatedCosts calculation part here. Link to comment
Unique Posted August 21, 2020 Author Share Posted August 21, 2020 (edited) 2 minutes ago, Patrick said: I can't see estimatedCosts calculation part here. yeah, because you ask show client side, estimated function is on server side. Edited August 21, 2020 by Danex Link to comment
Gordon_G Posted August 22, 2020 Share Posted August 22, 2020 then pass the estimated cost clientside when you call the client side's gui 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