ali Posted June 10, 2016 Share Posted June 10, 2016 I have a grid with all the players name online now i want to be able to get their account data called "n.cook" and also change that data how can i do it (reminder i only have Nick of the users) Link to comment
Castillo Posted June 10, 2016 Share Posted June 10, 2016 getPlayerFromName triggerServerEvent getPlayerAccount isGuestAccount getAccountData setAccountData Link to comment
ali Posted June 10, 2016 Author Share Posted June 10, 2016 http://prntscr.com/bew40y getting this error Link to comment
Castillo Posted June 10, 2016 Share Posted June 10, 2016 You have to set the second argument of addEvent to 'true'. https://wiki.multitheftauto.com/wiki/AddEvent Link to comment
ali Posted June 10, 2016 Author Share Posted June 10, 2016 this is part of the client side addEventHandler("onClientGUIClick",cookie_window, function() if (source == close_butt) then guiGridListRemoveRow ( player_grid, row ) guiSetVisible(cookie_window,false) showCursor(false) elseif (source == give_butt) then playerName = guiGridListGetItemText ( player_grid, row, guiGridListGetSelectedItem ( player_grid ), 1 ) pp = (getPlayerFromName(playerName)) amount = (guiGetText(value_edit)) triggerServerEvent("recivePlayer",resourceRoot,pp,amount) end end ) this is the whole server side addEvent("recivePlayer",true) addEventHandler("recivePlayer",root, function(pp,amount) acc = getPlayerAccount(pp) if isGuestAccount(acc) == false then cookies = getAccountData(acc,"n.cook") if not (cookies) then setAccountData(acc,"n.cook",tonumber(amount)) outputChatBox("lol") else setAccountData(acc,"n.cook", cookies + tonumber(amount)) end end end ) error says Link to comment
KariiiM Posted June 10, 2016 Share Posted June 10, 2016 Try my code: server side: addEvent ( "recivePlayer", true ) addEventHandler ( "recivePlayer",root, function ( pp, amount ) local acc = getPlayerAccount ( pp ) if isGuestAccount ( acc ) then return end local cookies = getAccountData ( acc,"n.cook" ) if ( not cookies) then setAccountData ( acc, "n.cook", tonumber ( amount ) ) --outputChatBox("lol") else setAccountData ( acc, "n.cook", cookies + tonumber ( amount ) ) end end ) client side: addEventHandler ( "onClientGUIClick", guiRoot, function ( ) if ( source == close_butt ) then guiGridListRemoveRow ( player_grid, row ) guiSetVisible ( cookie_window, false ) showCursor ( false ) elseif ( source == give_butt ) then local playerName = guiGridListGetItemText ( player_grid, row, guiGridListGetSelectedItem ( player_grid ), 1 ) local pp = getPlayerFromName ( playerName ) local amount = tonumber ( guiGetText ( value_edit ) ) triggerServerEvent ( "recivePlayer", localPlayer, pp, amount) end end ) Link to comment
KariiiM Posted June 10, 2016 Share Posted June 10, 2016 debug your code and output the results here Link to comment
ali Posted June 11, 2016 Author Share Posted June 11, 2016 In getting same error in the debug Link to comment
KariiiM Posted June 11, 2016 Share Posted June 11, 2016 In getting same error in the debug debug the values, use outputDebugString Link to comment
ali Posted June 11, 2016 Author Share Posted June 11, 2016 In getting same error in the debug debug the values, use outputDebugString i dont understand how to use it Link to comment
Simple0x47 Posted June 11, 2016 Share Posted June 11, 2016 What's your problem? Try to use "debugscript 3" in the console F8 logged as Admin to debug your script. outputDebugString it's like outputChatBox but it exports a string to the console. Link to comment
Anubhav Posted June 11, 2016 Share Posted June 11, 2016 What's your problem? Try to use "debugscript 3" in the console F8 logged as Admin to debug your script. outputDebugString it's like outputChatBox but it exports a string to the console. not to console, for that there is outputConsole (something like that)> It outputs the value to the debug. Pretty much same but the difference it outputs it to the debug. Link to comment
Simple0x47 Posted June 11, 2016 Share Posted June 11, 2016 With the console I meant the mta-server "terminal". Link to comment
ali Posted June 11, 2016 Author Share Posted June 11, 2016 well i made some tweeks and it seems like my script is not picking up the playerName stated in playerName = guiGridListGetItemText ( player_grid, row, guiGridListGetSelectedItem ( player_grid ), 1 ) client side 's part addEventHandler ( "onClientGUIClick", guiRoot, function ( ) if ( source == close_butt ) then guiGridListRemoveRow ( player_grid, row ) guiSetVisible ( cookie_window, false ) showCursor ( false ) elseif ( source == give_butt ) then playerName = guiGridListGetItemText ( player_grid, row, guiGridListGetSelectedItem ( player_grid ), 1 ) -- local pp = getPlayerFromName ( playerName ) outputDebugString(playerName) local amount = tonumber ( guiGetText ( value_edit ) ) triggerServerEvent ( "recivePlayer", localPlayer, playerName, amount) end end ) server side whole addEvent ( "recivePlayer", true ) addEventHandler ( "recivePlayer",root, function ( playerName, amount ) local pp = getPlayerFromName ( playerName ) local acc = getPlayerAccount ( pp ) outputDebugString ( playerName.."LOL"..amount) if isGuestAccount ( acc ) then return end local cookies = getAccountData ( acc,"n.cook" ) if ( not cookies) then setAccountData ( acc, "n.cook", tonumber ( amount ) ) else setAccountData ( acc, "n.cook", cookies + tonumber ( amount ) ) end end ) what i get Link to comment
ali Posted June 11, 2016 Author Share Posted June 11, 2016 i got it i just needed to remove row from that line thx guys Link to comment
ali Posted June 11, 2016 Author Share Posted June 11, 2016 ok guys thx for your help but now i am having another problem here after i got 25 it should have been 35 as i gave 10 but it gave me 9 in the next turn it gave me ten 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