sckatchof Posted March 22, 2012 Posted March 22, 2012 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)
Castillo Posted March 22, 2012 Posted March 22, 2012 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. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 22, 2012 Author Posted March 22, 2012 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"
Castillo Posted March 22, 2012 Posted March 22, 2012 Copy the code again. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 22, 2012 Author Posted March 22, 2012 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 )
Castillo Posted March 22, 2012 Posted March 22, 2012 As I said, copy the code again. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 22, 2012 Author Posted March 22, 2012 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 )
drk Posted March 22, 2012 Posted March 22, 2012 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
sckatchof Posted March 22, 2012 Author Posted March 22, 2012 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 @Snake : it dont work it stay "Error: Please select a skin from the list."
Castillo Posted March 22, 2012 Posted March 22, 2012 Should work, if you've selected a item from the gridlist. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 22, 2012 Author Posted March 22, 2012 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"
drk Posted March 22, 2012 Posted March 22, 2012 Dude, copy Solidsnake14 first code. It should work properly. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted March 22, 2012 Posted March 22, 2012 And what doesn't work? does it set your skin? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 22, 2012 Author Posted March 22, 2012 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 )
Castillo Posted March 22, 2012 Posted March 22, 2012 (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 March 22, 2012 by Guest San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted March 22, 2012 Posted March 22, 2012 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
sckatchof Posted March 22, 2012 Author Posted March 22, 2012 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 ) .. ...
X-SHADOW Posted March 23, 2012 Posted March 23, 2012 use what Darken Post ! My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 use what Darken Post ! it use it but still line 6 @setElementModel
Castillo Posted March 23, 2012 Posted March 23, 2012 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. Education is the most powerful weapon which you can use to change the world.
Kenix Posted March 23, 2012 Posted March 23, 2012 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.
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 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
Kenix Posted March 23, 2012 Posted March 23, 2012 Show how you trigger event buySkin. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 (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 March 23, 2012 by Guest
Kenix Posted March 23, 2012 Posted March 23, 2012 OK show how you trigger event buySkin. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
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