Jump to content

[HELP] Pay command script


Galactix

Recommended Posts

Posted

Hello! I have scripted a pay command but I dont want guest accounts to be able to use it because they can send infinite amounts of money. I tried to put a condition with if that would make a guest account unable to use the command, but I get an error stating that condition is missing an "end". I tried to put dozens of end after or even just one but the result is always the same.

addCommandHandler( 'pay', 
    function( source,_,player,amount ) 
        local find = findPlayer( player ) 
       if find then
		local sourceAccount = getPlayerAccount ( playerSource )
	local guestAccount = getPlayerAccount ( playerSource )
		if (guestAccount == guest) then
		 return
		else
         if amount then 
		 givePlayerMoney( find,tonumber( amount ) ) 
				takePlayerMoney ( source, tonumber(amount) )
				outputChatBox( '[Pay]:You transfered '..amount..'$ to '..getPlayerName( find ),source,255,0,0 )
				outputChatBox( '[Pay]:You received '..amount..'$ from '..getPlayerName( source ),find,0,255,0 ) 
            else 
                outputChatBox( '[Pay]:/pay [playername][amount]!',source,255,0,0 ) 
				end
			else
				outputChatBox( '[Pay]: You are not logged in!',source,255,0,0 )
			end
        else 
           outputChatBox( '[Pay]:Player not found!',source,255,0,0 ) 
		end
		end
	end

)

 

If I helped you, make sure you click the reaction button on the right to support me!
It will grant me more visibility and will help me to help others!

If you have any kind of request or subject you would like to discuss about with me,
don't hesitate to send me a private message about it!

 

  • Moderators
Posted (edited)
addCommandHandler( 'pay', function( source,_,player,amount ) 
    local find = findPlayer( player ) 
    if find then
        local sourceAccount = getPlayerAccount ( source )
        local guestAccount = isGuestAccount ( sourceAccount )
        
        if guestAccount then
            outputChatBox( '[Pay]: You are not logged in!',source,255,0,0 )
      	else
            if amount then 
                givePlayerMoney( find,tonumber( amount ) ) 
                takePlayerMoney ( source, tonumber(amount) )
                outputChatBox( '[Pay]:You transfered '..amount..'$ to '..getPlayerName( find ),source,255,0,0 )
                outputChatBox( '[Pay]:You received '..amount..'$ from '..getPlayerName( source ),find,0,255,0 ) 
            else 
                outputChatBox( '[Pay]:/pay [playername][amount]!',source,255,0,0 ) 
            end
        end
    else 
        outputChatBox( '[Pay]:Player not found!',source,255,0,0 )
    end
end)

 

Edited by Patrick2562
  • Thanks 1
Posted

Thanks!

If I helped you, make sure you click the reaction button on the right to support me!
It will grant me more visibility and will help me to help others!

If you have any kind of request or subject you would like to discuss about with me,
don't hesitate to send me a private message about it!

 

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