justn Posted May 7, 2014 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. Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Karuzo Posted May 7, 2014 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)
justn Posted May 7, 2014 Author 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 ) Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Castillo Posted May 7, 2014 Posted May 7, 2014 That's because "lp" is a player element, use getPlayerName ( lp ). San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
justn Posted May 7, 2014 Author Posted May 7, 2014 Works perfectly, thanks to both of you ! ^^ Datastore - Store data to a database quickly. (Useful for saving scripted tables)
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