Jump to content

Need help


sckatchof

Recommended Posts

Posted

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) 

Posted

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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

thank snake for help work but it show after 3 second

guiSetText, 3000, 1, LabelTNS, "Error: Please select a skin from the list." )

i want when i press buy skin it show for 3 second it it back to this

local skinmsglabel = "Welcome"

Posted

Copy the code again.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

As I said, copy the code again.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

looooooool He is saying you to copy him code and test dude. Not to post old here.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted
looooooool He is saying you to copy him code and test dude. Not to post old here.

@ Darken :Loooool cs i don't understand what he want ex xD

@Snake : it dont work it stay "Error: Please select a skin from the list."

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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"

Posted

Dude, copy Solidsnake14 first code.

It should work properly.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted (edited)
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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

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

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted
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

Posted (edited)
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

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