Jump to content

A question


ali

Recommended Posts

Posted

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)

Posted

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

B7apvQP.png

Posted

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 
) 

Posted
In getting same error in the debug

debug the values, use

outputDebugString 

i dont understand how to use it

Posted

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.

Posted
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.

Posted

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

6uw1kly.png

Posted

ok guys thx for your help but now i am having another problem here

qWWEVz6.png

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...