Jump to content

[HELP] say to player to have skin purchased


BenceDev

Recommended Posts

Hi, again

I created a skin shop, so i click buy skin has been buyed and skin changed. that's work fine, but i have skin from skin shop(example: 284) and i click again buy dont change and buy again skin, and say "You already purchased this skin!".

Debugscript 3 say:

WARNING: an_safezoneSkinShop\client.lua:91: Bad argument @ 'getElementModel' [Expected element at argument 1, got nil]

Client side:
 

local skinWindow1 = guiCreateWindow(0.22, 0.22, 0.57, 0.61, "Skin Shop", true) 
guiWindowSetSizable(skinWindow1, false) 
guiSetVisible(skinWindow1,false) 

local skinText0 = guiCreateLabel(0.85, 0.95, 0.15, 0.05, "Press F4 for close panel", true, skinWindow1)
local skinText1 = guiCreateLabel(-0.40, 0.10, 1, 1, "Deafult\nPrice: 0$", true, skinWindow1)
local skinText2 = guiCreateLabel(-0.30, 0.10, 1, 1, "Deafult2\nPrice: 0$", true, skinWindow1)
local skinText3 = guiCreateLabel(-0.20, 0.10, 1, 1, "Ranger\nPrice: 500$", true, skinWindow1)
local skinText4 = guiCreateLabel(-0.10, 0.10, 1, 1, "Delta\nPrice: 825$", true, skinWindow1)
local skinText5 = guiCreateLabel(0, 0.10, 1, 1, "Special Ops\nPrice: 925$", true, skinWindow1)
local skinText6 = guiCreateLabel(0.10, 0.10, 1, 1, "Special Ops\nPrice: 1025$", true, skinWindow1)
local skinPayButton1 = guiCreateButton(0.075, 0.17, 0.05, 0.05, "Buy", true, skinWindow1)
local skinPayButton2 = guiCreateButton(0.175, 0.17, 0.05, 0.05, "Buy", true, skinWindow1)
local skinPayButton3 = guiCreateButton(0.275, 0.17, 0.05, 0.05, "Buy", true, skinWindow1)
local skinPayButton4 = guiCreateButton(0.375, 0.17, 0.05, 0.05, "Buy", true, skinWindow1)
local skinPayButton5 = guiCreateButton(0.475, 0.17, 0.05, 0.05, "Buy", true, skinWindow1)
local skinPayButton6 = guiCreateButton(0.575, 0.17, 0.05, 0.05, "Buy", true, skinWindow1)

guiSetFont(skinText0, 'clear-normal')
guiLabelSetHorizontalAlign(skinText0, "center", false)

guiSetFont(skinText1, 'clear-normal')
guiLabelSetHorizontalAlign(skinText1, "center", false)

guiSetFont(skinText2, 'clear-normal')
guiLabelSetHorizontalAlign(skinText2, "center", false)

guiSetFont(skinText3, 'clear-normal')
guiLabelSetHorizontalAlign(skinText3, "center", false)
 
guiSetFont(skinText4, 'clear-normal')
guiLabelSetHorizontalAlign(skinText4, "center", false)

guiSetFont(skinText5, 'clear-normal')
guiLabelSetHorizontalAlign(skinText5, "center", false)

guiSetFont(skinText6, 'clear-normal')
guiLabelSetHorizontalAlign(skinText6, "center", false)

   
addEvent("showSkinGUI",true) 
addEventHandler("showSkinGUI",getRootElement(), 
function () 
    if ( guiGetVisible(skinWindow1) == false ) then 
    guiSetVisible(skinWindow1,true) 
    guiLabelSetColor (skinText0, 237, 121, 2)
    guiSetProperty (skinPayButton1, "NormalTextColour", "EEE82870")
    guiSetProperty (skinPayButton2, "NormalTextColour", "EEE82870")
    guiSetProperty (skinPayButton3, "NormalTextColour", "EEE82870")
    guiSetProperty (skinPayButton4, "NormalTextColour", "EEE82870")
    guiSetProperty (skinPayButton5, "NormalTextColour", "EEE82870")
    guiSetProperty (skinPayButton6, "NormalTextColour", "EEE82870")

    showCursor(true) 
    guiSetVisible(skinPayButton1, true)
    guiSetVisible(skinPayButton2, true)
    guiSetVisible(skinPayButton3, true)
    guiSetVisible(skinPayButton4, true)
    guiSetVisible(skinPayButton5, true)
    guiSetVisible(skinPayButton6, true)
    end 
end) 




local function guzik()
	guiSetVisible(skinWindow1, false)
	showCursor(false, false)
end
bindKey("F4","down",guzik)

local function defaultSBuy()
    guiSetVisible(skinPayButton1, false)

    setElementModel(localPlayer, 287)
end
addEventHandler("onClientGUIClick", skinPayButton1, defaultSBuy, false)

local function default2SBuy()
    guiSetVisible(skinPayButton2, false)

    setElementModel(localPlayer, 283)
end
addEventHandler("onClientGUIClick", skinPayButton2, default2SBuy, false)

local function default3SBuy()
    guiSetEnabled(skinPayButton3, false)

     local money = getPlayerMoney(thePlayer)
     local id = getElementModel(thePlayer)
     
     if (money < 500) then  --if the player's money is less than 0 go no further
        outputChatBox("You don't have enough money! (500$)", 255, 0, 0)
        guiSetVisible(skinPayButton3, true)
        return
     end

    if getElementType () == "player" and id == 284 then
        outputChatBox("You already pruchased this skin!", 255, 0, 0)
    end

     outputChatBox("You purchased a Humvee! (500$)", 0, 255, 0)
     takePlayerMoney(500)
     setElementModel(localPlayer, 284)
end
addEventHandler("onClientGUIClick", skinPayButton3, default3SBuy, false)


any idea?

 

spacer.pngspacer.png

Edited by SphinxDev
Link to comment

try this

local function default3SBuy()
    guiSetEnabled(skinPayButton3, false)

     local money = getPlayerMoney(localPlayer) --replace with localPlayer
     local id = getElementModel(localPlayer) --replace with localPlayer
     
     if (money < 500) then  --if the player's money is less than 0 go no further
        outputChatBox("You don't have enough money! (500$)", 255, 0, 0)
        guiSetVisible(skinPayButton3, true)
        return
     end

     if id == 284 then --getElementType is unnecessary in this case
       outputChatBox("You already pruchased this skin!", 255, 0, 0)
     end

     outputChatBox("You purchased a Humvee! (500$)", 0, 255, 0)
     takePlayerMoney(500) --this might be problem for server side i suggest you to do it using triggerServerEvent
     setElementModel(localPlayer, 284)
end
addEventHandler("onClientGUIClick", skinPayButton3, default3SBuy, false)
Edited by Burak5312
Link to comment
1 hour ago, Burak5312 said:

try this

local function default3SBuy()
    guiSetEnabled(skinPayButton3, false)

     local money = getPlayerMoney(localPlayer) --replace with localPlayer
     local id = getElementModel(localPlayer) --replace with localPlayer
     
     if (money < 500) then  --if the player's money is less than 0 go no further
        outputChatBox("You don't have enough money! (500$)", 255, 0, 0)
        guiSetVisible(skinPayButton3, true)
        return
     end

     if id == 284 then --getElementType is unnecessary in this case
       outputChatBox("You already pruchased this skin!", 255, 0, 0)
     end

     outputChatBox("You purchased a Humvee! (500$)", 0, 255, 0)
     takePlayerMoney(500) --this might be problem for server side i suggest you to do it using triggerServerEvent
     setElementModel(localPlayer, 284)
end
addEventHandler("onClientGUIClick", skinPayButton3, default3SBuy, false)

ok i try it

 

ok that's work fine thx @Burak5312

3546-boba-corgi.gif9990-sakura-fighter.gif

Link to comment

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...