Jump to content

A question


ali

Recommended Posts

Posted
getPlayerFromName 
triggerServerEvent 
getPlayerAccount 
isGuestAccount 
getAccountData 
setAccountData 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

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.

"Keep making it simplex."

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

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