Jump to content

[Help] Pay'N'Spray


Unique

Recommended Posts

Posted (edited)

How to add in paynspray-system repair costs in main window? Tried to add ..estimatedCosts.. but didn't worked.

Screenshot:

spacer.png

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 by Danex
Posted
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?(( 

Posted
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 )?

  • Moderators
Posted
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.

Posted (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 by Danex
  • Moderators
Posted
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.

Posted (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 by Danex

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...