sckatchof Posted March 23, 2012 Author Posted March 23, 2012 OK show how you trigger event buySkin. 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 ) but i change to finaskin
Kenix Posted March 23, 2012 Posted March 23, 2012 addEventHandler( 'onClientGUIClick', root, function( ) if source == Buttonbuyskin then assert( Sgrid, 'Grid list not exists' ) local nRow = guiGridListGetSelectedItem( Sgrid ) if nRow and nRow ~= -1 then local finalskin = guiGridListGetItemText( Sgrid, nRow, 1 ) assert( finalskin, 'Variable finalskin is false or nil.' ) 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 ) Test it and show output debug messages.
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 addEventHandler( 'onClientGUIClick', root, function( ) if source == Buttonbuyskin then assert( Sgrid, 'Grid list not exists' ) local nRow = guiGridListGetSelectedItem( Sgrid ) if nRow and nRow ~= -1 then local finalskin = guiGridListGetItemText( Sgrid, nRow, 1 ) assert( finalskin, 'Variable finalskin is false or nil.' ) 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 ) Test it and show output debug messages. thanx keni for help but nothing it show and when i click buy skin nothing it chnage
Kenix Posted March 23, 2012 Posted March 23, 2012 Try check all conditions with functions : outputChatBox outputDebugString
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 Try check all conditions with functions : outputChatBox outputDebugString Client side work but i have proble in server side in line 5 ==> setElementModel( source, finalskin ) client side : addEventHandler( 'onClientGUIClick', root, function( ) if source == Buttonbuyskin then assert( Sgrid, 'Grid list not exists' ) local nRow = guiGridListGetSelectedItem( Sgrid ) if nRow and nRow ~= -1 then local finalskin = guiGridListGetItemText( Sgrid, nRow, 1 ) assert( finalskin, 'Variable finalskin is false or nil.' ) triggerServerEvent ( 'buySkin', localPlayer, tonumber ( finalskin ) ) outputChatBox("You have successfully bought the skin!",source,225,255,255) 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 ) addEvent("buySkin", true) addEventHandler("buySkin", root, function(finalskin) if source then if (getPlayerMoney(source) >= 350) then setElementModel( source, finalskin ) setElementData ( source, "clothesSkin", finalskin, true ) outputChatBox("You have successfully bought the skin!",source,225,255,255) else outputChatBox("You dont have enough money!",source,225,0,0) end end end )
Alpha Posted March 23, 2012 Posted March 23, 2012 Try outputting debug messages, anything in /debugscript 3?
drk Posted March 23, 2012 Posted March 23, 2012 Client-side: addEventHandler( 'onClientGUIClick', root, function( ) if ( source == Buttonbuyskin ) then assert( Sgrid, 'Grid list not exists' ) local nRow = guiGridListGetSelectedItem( Sgrid ) if ( nRow and nRow ~= -1 ) then local finalskin = guiGridListGetItemText( Sgrid, nRow, 1 ) assert( finalskin, 'Variable finalskin is false or nil.' ) triggerServerEvent ( 'buySkin', localPlayer, tonumber ( finalskin ) ) outputChatBox("You have successfully bought the skin!",source,225,255,255) 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 ) Server-side: addEvent("buySkin", true) addEventHandler("buySkin", root, function ( skin ) if ( getPlayerMoney ( source ) >= 350 ) then setElementModel ( source, tonumber ( skin ) ) setElementData ( source, "clothesSkin", skin, true ) outputChatBox ( "You have successfully bought the skin!", source, 225, 255, 255 ) else outputChatBox("You dont have enough money!",source,225,0,0) end end )
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 thanks darken for help but some problem it show in debugscript 3 line 6 setElementModel .
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 What does it say? this msg in debugscript 3 : ... skin_s.lua:5: Bad argument @ 'setElementModel
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 Post all the error. i dont have any error it's work when i buy skin but it show in debugscript 3 this msg : ...skin_s.lua:5: Bad argument @ 'setElementModel
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 LOL? ISN'T THAT A ERROR???????????? No jut WARNIG
drk Posted March 23, 2012 Posted March 23, 2012 smth dude -.- Stop being noob and post here the error.
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 smth dude -.-Stop being noob and post here the error. when i buy a skin it show this WARNIG in consol and in debugscript 3 like this pic : lien :
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 Show Server-side. addEvent("buySkin", true) addEventHandler("buySkin", root, function(finalskin) if source then if (getPlayerMoney(source) >= 350) then outputChatBox ( type ( finalskin ) ..": ".. tostring ( finalskin ) ) setElementModel ( source, tonumber ( finalskin ) ) setElementData ( source, "clothesSkin", finalskin, true ) outputChatBox("You have successfully bought the skin!",source,225,255,255) else outputChatBox("You dont have enough money!",source,225,0,0) end end end )
drk Posted March 23, 2012 Posted March 23, 2012 Fuuuuu! Are you kidding me??????? I posted the correct code here and you've not used it! addEvent ( "buySkin", true ) addEventHandler ( "buySkin", root, function ( fSkin ) if ( getPlayerMoney ( source ) >= 350 ) then setElementModel ( source, fSkin ) setElementData ( source, "clothesSkin", fSkin, true ) outputChatBox ( "You have sucessfully bought the skin!", source, 255, 255, 255, false ) else outputChatBox ( "You don't have enough money!", source, 225, 0, 0, false ) end end )
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 Fuuuuu!Are you kidding me??????? I posted the correct code here and you've not used it! addEvent ( "buySkin", true ) addEventHandler ( "buySkin", root, function ( fSkin ) if ( getPlayerMoney ( source ) >= 350 ) then setElementModel ( source, fSkin ) setElementData ( source, "clothesSkin", fSkin, true ) outputChatBox ( "You have sucessfully bought the skin!", source, 255, 255, 255, false ) else outputChatBox ( "You don't have enough money!", source, 225, 0, 0, false ) end end ) no im not kidding with you and i use your code thnx again but still show WARNIG
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 Show client and server code ( the updated code ). server side : addEvent ( "buySkin", true ) addEventHandler ( "buySkin", root, function ( fSkin ) if ( getPlayerMoney ( source ) >= 350 ) then setElementModel ( source, fSkin ) setElementData ( source, "clothesSkin", fSkin, true ) outputChatBox ( "You have sucessfully bought the skin!", source, 255, 255, 255, false ) else outputChatBox ( "You don't have enough money!", source, 225, 0, 0, false ) end end ) client : ... .. Sgrid = guiCreateGridList(12,59,345,439,false,SkinWindow) .. Buttonbuyskin = guiCreateButton(12,503,122,29,"Buy skin (350$)",false,SkinWindow) .. addEventHandler( 'onClientGUIClick', root, function( ) if ( source == Buttonbuyskin ) then assert( Sgrid, 'Grid list not exists' ) local nRow = guiGridListGetSelectedItem( Sgrid ) if ( nRow and nRow ~= -1 ) then local finalskin = guiGridListGetItemText( Sgrid, nRow, 1 ) triggerServerEvent ( 'buySkin', localPlayer, tonumber ( finalskin ) ) outputChatBox("You have successfully bought the skin!",source,225,255,255) else if isTimer ( timer ) then killTimer ( timer ) end guiSetText ( LabelTNS, 'Error: Please select a skin from the list.' ) timer = setTimer ( guiSetText, 3000, 1, skinmsgla, LabelTNS ) end end end )
sckatchof Posted March 23, 2012 Author Posted March 23, 2012 Upload resource. thank you Keniiiix for help it's work
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