Jump to content

Need help


sckatchof

Recommended Posts

hello guys i have 2 problem in shop gui when i buy skin it does not change .

client side :

  
local skinmsglabel = "Welcome" 
.. 
Sgrid = guiCreateGridList(12,59,345,439,false,Window) 
... 
Buttonbuyskin = guiCreateButton(12,503,122,29,"Buy skin (350$)",false,Window) 
Buttonclose = guiCreateButton(240,503,117,30,"Exit",false,Window) 
LabelTNS = guiCreateLabel(50,36,220,30,skinmsglabel ,false,Window) 
... 
addEventHandler("onClientGUIClick", root, 
    function () 
        if (source == Buttonbuyskin) then 
            local row,col = guiGridListGetSelectedItem(Sgrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local finalskin = guiGridListGetItemText(Sgrid, row, 1) 
                triggerServerEvent("buySkin",localPlayer,finalskin) 
            else 
    if isTimer(timer) then killTimer(timer) end 
    timer = setTimer(guiSetText(LabelTNS, "Error: Please select a skin from the list."),3000, 1, skinmsglabel ) 
            end 
        end 
    end 
) 

Server side :

addEvent("buySkin", true) 
addEventHandler("buySkin", root, 
function(finalskin) 
if source then 
     if (getPlayerMoney(source) >= 350) then 
          setElementModel(source,finalskin) 
     else 
          outputChatBox("You dont have enough money!",source,225,0,0) 
     end 
end) 

Link to comment

Try this:

local skinmsglabel = "Welcome" 
.. 
Sgrid = guiCreateGridList(12,59,345,439,false,Window) 
... 
Buttonbuyskin = guiCreateButton(12,503,122,29,"Buy skin (350$)",false,Window) 
Buttonclose = guiCreateButton(240,503,117,30,"Exit",false,Window) 
LabelTNS = guiCreateLabel(50,36,220,30,skinmsglabel ,false,Window) 
... 
addEventHandler("onClientGUIClick", root, 
    function () 
        if (source == Buttonbuyskin) then 
            local row,col = guiGridListGetSelectedItem(Sgrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local finalskin = guiGridListGetItemText(Sgrid, row, 1 ) 
                triggerServerEvent ( "buySkin", localPlayer, tonumber ( finalskin ) ) 
            else 
                if isTimer ( timer ) then 
                    killTimer ( timer ) 
                end 
                guiSetText ( LabelTNS, "Error: Please select a skin from the list." ) 
                timer = setTimer ( guiSetText, 3000, 1, LabelTNS, skinmsglabel ) 
            end 
        end 
    end 
) 

Link to comment
Copy the code again.
  
local skinmsglabel = "Welcome" 
.. 
Sgrid = guiCreateGridList(12,59,345,439,false,Window) 
... 
Buttonbuyskin = guiCreateButton(12,503,122,29,"Buy skin (350$)",false,Window) 
Buttonclose = guiCreateButton(240,503,117,30,"Exit",false,Window) 
LabelTNS = guiCreateLabel(50,36,220,30,skinmsglabel ,false,Window) 
... 
addEventHandler("onClientGUIClick", root, 
    function () 
        if (source == Buttonbuyskin) then 
            local row,col = guiGridListGetSelectedItem(Sgrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local finalskin = guiGridListGetItemText(Sgrid, row, 1) 
                triggerServerEvent("buySkin",localPlayer,finalskin) 
            else 
    if isTimer(timer) then killTimer(timer) end 
    timer = setTimer(guiSetText(LabelTNS, "Error: Please select a skin from the list."),3000, 1, skinmsglabel ) 
            end 
        end 
    end 
) 

Link to comment
As I said, copy the code again.

client side

local tnsskinlabel = "Welcome" 
.. 
LabelTNS = guiCreateLabel(50,36,220,30,tnsskinlabel,false,Window) 
... 
Buttonbuyskin = guiCreateButton(12,503,122,29,"Buy skin (350$)",false,Window) 
Buttonclose = guiCreateButton(240,503,117,30,"Exit",false,Window) 
... 
addEventHandler("onClientGUIClick", root, 
    function () 
        if (source == Buttonbuyskin) then 
            local row,col = guiGridListGetSelectedItem(Sgrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local finalskin = guiGridListGetItemText(Sgrid, row, 1 ) 
                triggerServerEvent ( "buySkin", localPlayer, tonumber ( finalskin ) ) 
            else 
                if isTimer ( timer ) then 
                    killTimer ( timer ) 
                end 
                timer = setTimer ( guiSetText, 3000, 1, LabelTNS, "Error: Please select a skin from the list." ) 
            end 
        end 
    end 
) 

Link to comment
Should work, if you've selected a item from the gridlist.

i want that msg show when i dont selecte for gridlist when i click 'buy skin' without select from list it show ""guiSetText ( LabelTNS, "Error: Please select a skin from the list." ) just for 3 seconed and it back 'skinmsglabel = "Welcome"

Link to comment
And what doesn't work? does it set your skin?

thank you sanke again for help :)

it work when i buy skin but it some probelem :

:6 :@setElementModel

:7 :@setElementModel

server side

addEvent("buySkin", true) 
addEventHandler("buySkin", root, 
function(finalskin) 
if source then 
     if (getPlayerMoney(source) >= 350) then 
          setElementModel(source,finalskin) 
       setElementData ( source, "clothesSkin", getElementModel ( localPlayer ), true ) 
            takePlayerMoney( source, 350 ) 
     end 
end 
end 
) 
  

Link to comment
addEvent ( "buySkin", true ) 
addEventHandler ( "buySkin", root, 
    function ( finalskin ) 
        if (getPlayerMoney(source) >= 350) then 
            setElementModel ( source, finalskin ) 
            setElementData ( source, "clothesSkin", finalskin, true ) -- Your player argument is 'source', not 'localPlayer'. 
            takePlayerMoney( source, 350 ) 
        end 
    end 
) 

Edited by Guest
Link to comment
addEvent ( "buySkin", true ) 
addEventHandler ( "buySkin", root, 
    function ( finalskin ) 
        if (getPlayerMoney(source) >= 350) then 
            setElementModel ( source, finalskin ) 
            setElementData ( source, "clothesSkin", finalskin, true ) -- it's "finalskin" not "fnalskin"  
            takePlayerMoney( source, 350 ) 
        end 
    end 
) 

Link to comment

thank guys for help but it still have bad argument line 6 @ setElementModel

  
addEvent("buySkin", true) 
addEventHandler("buySkin", root, 
function(finalskin) 
if source then 
     if (getPlayerMoney(source) >= 350) then 
          setElementModel( source, finalskin ) 
         setElementData ( source, "clothesSkin", finalskin, true ) 
.. 
... 

Link to comment

Use this:

addEvent ( "buySkin", true ) 
addEventHandler ( "buySkin", root, 
    function ( finalskin ) 
        if (getPlayerMoney(source) >= 350) then 
            outputChatBox ( type ( finalskin ) ..": ".. tostring ( finalskin ) ) 
            setElementModel ( source, finalskin ) 
            setElementData ( source, "clothesSkin", finalskin, true ) 
            takePlayerMoney ( source, 350 ) 
        end 
    end 
) 

and tell me what does it output.

Link to comment
addEvent ( 'buySkin', true ) 
addEventHandler ( 'buySkin', root, 
    function ( nFinalSkin ) 
        if getPlayerMoney( source ) >= 350 then 
            assert ( type ( nFinalSkin ) == 'number', 'Variable nFinalSkin is not number' ) 
            assert( isElement( source ) and getElementType( source ) == 'player', 'source is not player element' ) 
            setElementModel ( source, nFinalSkin ) 
            setElementData ( source, 'clothesSkin', nFinalSkin, true ) 
            takePlayerMoney ( source, 350 ) 
        end 
    end 
) 

All errors you can see in debug ( type /debugscript 3 ).

Link to comment
Use this:
addEvent ( "buySkin", true ) 
addEventHandler ( "buySkin", root, 
    function ( finalskin ) 
        if (getPlayerMoney(source) >= 350) then 
            outputChatBox ( type ( finalskin ) ..": ".. tostring ( finalskin ) ) 
            setElementModel ( source, finalskin ) 
            setElementData ( source, "clothesSkin", finalskin, true ) 
            takePlayerMoney ( source, 350 ) 
        end 
    end 
) 

and tell me what does it output.

it show

nil :nil

Link to comment
addEvent ( 'buySkin', true ) 
addEventHandler ( 'buySkin', root, 
    function ( nFinalSkin ) 
        if getPlayerMoney( source ) >= 350 then 
            assert ( type ( nFinalSkin ) == 'number', 'Variable nFinalSkin is not number' ) 
            assert( isElement( source ) and getElementType( source ) == 'player', 'source is not player element' ) 
            setElementModel ( source, nFinalSkin ) 
            setElementData ( source, 'clothesSkin', nFinalSkin, true ) 
            takePlayerMoney ( source, 350 ) 
        end 
    end 
) 

All errors you can see in debug ( type /debugscript 3 ).

in debugscript show WARNIG line 5 variabel nFinalSkin is not number

Edited by Guest
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...