Jump to content

A question


ali

Recommended Posts

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

Link to comment

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

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

Link to comment

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