MAB Posted July 12, 2015 Share Posted July 12, 2015 why it is not sending?! function send (player,command,player2,money) if ( not player2 or not tonumber ( money ) ) then outputChatBox ( "The correct syntax for /"..tostring(command).." is /"..tostring(command).." [playername] [amount]", player, 255, 255, 0 ) return false end local money = math.floor ( tonumber ( money ) ) local money2 = getPlayerMoney ( player ) local taker = getPlayerFromName ( player2 ) local name = getPlayerName ( player ) if ( money and money >= money2 and tonumber ( money ) and taker and player2 ) then takePlayerMoney ( player, money ) outputChatBox ( "You sent "..money.."$ to "..player2".", player, 255, 255, 0, false ) givePlayerMoney ( taker, money ) outputChatBox ( name.." sent you "..money.."$ "..player2".", player2, 255, 255, 0, false ) end end addCommandHandler ( "send", send ) Link to comment
Dealman Posted July 12, 2015 Share Posted July 12, 2015 money >= money2 This checks whether money is greater than or equal to money2. money = The money the player tries to send money2 = The player's current money Why would you check if the amount of money the player tries to send is more than he's currently got? If I have $1 000 and try to send $2 000 this would return true. Are you sure the player names are entered correctly? Link to comment
GTX Posted July 12, 2015 Share Posted July 12, 2015 function send (player,command,player2,money) if ( not player2 or not tonumber ( money ) ) then outputChatBox ( "The correct syntax for /"..tostring(command).." is /"..tostring(command).." [playername] [amount]", player, 255, 255, 0 ) return false end local money = math.floor ( tonumber ( money ) ) local money2 = getPlayerMoney ( player ) local taker = findPlayer ( player2 ) local name = getPlayerName ( player ) if ( money and money2 >= money and tonumber ( money ) and taker and player2 ) then takePlayerMoney ( player, money ) outputChatBox ( "You sent "..money.."$ to "..player2".", player, 255, 255, 0, false ) givePlayerMoney ( taker, money ) outputChatBox ( name.." sent you "..money.."$ "..player2".", player2, 255, 255, 0, false ) end end addCommandHandler ( "send", send ) function findPlayer(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
GTX Posted July 12, 2015 Share Posted July 12, 2015 Debug the code. Any errors in debugscript? function send (player,command,player2,money) if ( not player2 or not tonumber ( money ) ) then outputChatBox ( "The correct syntax for /"..tostring(command).." is /"..tostring(command).." [playername] [amount]", player, 255, 255, 0 ) return false end local money = math.floor ( tonumber ( money ) ) local money2 = getPlayerMoney ( player ) local taker = findPlayer ( player2 ) local name = getPlayerName ( player ) if taker then if money2 >= money then takePlayerMoney ( player, money ) outputChatBox ( "You sent "..money.."$ to "..getPlayerName(taker)..".", player, 255, 255, 0, false ) givePlayerMoney ( taker, money ) outputChatBox ( name.." sent you "..money.."$", taker, 255, 255, 0, false ) else outputChatBox("Not enough money", player) end else outputChatBox("Player not found", player) end end addCommandHandler ( "send", send ) function findPlayer(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end return false end Link to comment
MAB Posted July 12, 2015 Author Share Posted July 12, 2015 that one worked thank you alot btw i don't know how to debug Link to comment
GTX Posted July 12, 2015 Share Posted July 12, 2015 You're welcome. Write /debugscript 3 in chatbox to show errors. 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