justn Posted May 7, 2014 Share Posted May 7, 2014 Hi I'm working on a script to give player VIP, but it doesn't work, i don't know why. here's debugscript errors. ERROR: VIP\Server.lua:11: Bad argument @ 'setElementData' [Expected argument at argument 3 , got none] ERROR: VIP\Server.lua:12 attempt to concatenate global 'source' (a userdata value) Client ( Where you give the player vip ): addEventHandler("onClientGUIClick",SureWindow, function (b) if b == "left" and source == SureGive then local selected1 = guiGridListGetItemText(VIP_GiveMainGrid, guiGridListGetSelectedItem(VIP_GiveMainGrid), VIP_GiveVIPName) local selected2 = guiGridListGetItemText(VIP_GiveMainGrid, guiGridListGetSelectedItem(VIP_GiveMainGrid), VIP_GiveVIPRank) local ComboS = guiComboBoxGetItemText(SureCombo,guiComboBoxGetSelected(SureCombo)) if ( selected1 ) then if ComboS ~= "" then local selected3 = getPlayerFromName(selected1) if (selected3) then exports["TopBarChat"]:sendClientMessage("#ff0000* #00ff00You have given VIP to "..selected1,255,255,255,true) triggerServerEvent("giveSelected",localPlayer,selected1,selected2,selected3,ComboS) end end end end end) Server: addEventHandler("onPlayerJoin",getRootElement(), function() if ( getPlayerSerial(source) == "D5FF7C8E58745AE326AD72702D60ECA1" ) then setElementData(source, "VIP", "Premium" ) end end) addEvent("giveSelected",true) addEventHandler("giveSelected",getRootElement(), function(selected1,selected2,selected3,ComboS) setElementData(selected3,ComboS) exports["TopBarChat"]:sendClientMessage("#FF0000* #00ff00You have gotten VIP by "..source,selected3,255,255,255,true) end) Thanks. Link to comment
Karuzo Posted May 7, 2014 Share Posted May 7, 2014 What should this be : setElementData(selected3,ComboS) ? You need to set a "key" where you can save the data to. Like setElementData(selected3,"test",ComboS) --client addEventHandler("onClientGUIClick",SureWindow, function (b) if b == "left" and source == SureGive then local selected1 = guiGridListGetItemText(VIP_GiveMainGrid, guiGridListGetSelectedItem(VIP_GiveMainGrid), VIP_GiveVIPName) local selected2 = guiGridListGetItemText(VIP_GiveMainGrid, guiGridListGetSelectedItem(VIP_GiveMainGrid), VIP_GiveVIPRank) local ComboS = guiComboBoxGetItemText(SureCombo,guiComboBoxGetSelected(SureCombo)) if ( selected1 ) then if ComboS ~= "" then local selected3 = getPlayerFromName(selected1) if (selected3) then exports["TopBarChat"]:sendClientMessage("#ff0000* #00ff00You have given VIP to "..selected1,255,255,255,true) triggerServerEvent("giveSelected",localPlayer,localPlayer,selected1,selected2,selected3,ComboS) end end end end end) --server addEventHandler("onPlayerJoin",getRootElement(), function() if ( getPlayerSerial(source) == "D5FF7C8E58745AE326AD72702D60ECA1" ) then setElementData(source, "VIP", "Premium" ) end end) addEvent("giveSelected",true) addEventHandler("giveSelected",getRootElement(), function(lp,selected1,selected2,selected3,ComboS) setElementData(selected3,"test",ComboS) exports["TopBarChat"]:sendClientMessage("#FF0000* #00ff00You have gotten VIP by "..lp,selected3,255,255,255,true) end) Link to comment
justn Posted May 7, 2014 Author Share Posted May 7, 2014 Well it works fine now, but I have gotten an error in debugscript ERROR: VIP\server.lua:12:attempt to concatenate local 'lp' ( a userdata value ) Link to comment
Castillo Posted May 7, 2014 Share Posted May 7, 2014 That's because "lp" is a player element, use getPlayerName ( lp ). Link to comment
justn Posted May 7, 2014 Author Share Posted May 7, 2014 Works perfectly, thanks to both of you ! ^^ Link to comment
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