Negriukas Posted July 3, 2014 Posted July 3, 2014 Hi, When i try to send someone money it doesnt output in chat box the text for the local player, but the target player can see the output, It suppose to write in chatbox ("You gave "..money.." to "..getPlayerName(targetPlayer)", source, r, g, b) The problem is that the target player can recieve the text of the money but who send money it doesnt output nothing, here is the code function giveSomeoneMoney(player, cmd, target, amount) if target then if amount then local money = getPlayerMoney(player) local targetplayer = getPlayerFromParticalName(target) local r,g,b = getPlayerNametagColor(source) amount = tonumber(amount) if targetplayer then if money >= amount then givePlayerMoney(targetplayer, amount) takePlayerMoney(player, amount) outputChatBox("You have been given #00FF00$"..amount.." #0096FF from #FFFFFF"..getPlayerName(player) , targetplayer, 0, 81, 255, true) outputChatBox("You gave #00FF00$"..amount.."#0096FF to #FFFFFF"..getPlayerName(target), player, 0, 81, 255, true) else outputChatBox("You don't have enought money!", player, 255, 0, 0) end else outputChatBox("Error: Player not found", player, 255, 0, 0) end else outputChatBox("Error: /givemoney [player name] [amount]", player, 255, 0, 0) end else outputChatBox("Error: /givemoney [player name] [amount]", player, 255, 0, 0) end end addCommandHandler("givemoney", giveSomeoneMoney) function getPlayerFromParticalName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end Screw putin
MTA Team botder Posted July 3, 2014 MTA Team Posted July 3, 2014 outputChatBox("You gave #00FF00$"..amount.."#0096FF to #FFFFFF"..getPlayerName(target) getPlayerName(target) Use targetplayer instead of target, because you pass the command parameter name to the function: Example usage: /givemoney Franklin234 500 That line produces the following code: outputChatBox("You gave #00FF00$".."500".."#0096FF to #FFFFFF"..getPlayerName("Franklin234") GitHub: Debug Console • MTA-Discord Relay Scripting: How to draw a line chart with DirectX functions? • Doppler Effect in MTA • Get the client's FPS • Customizable Blur Shader
Negriukas Posted July 5, 2014 Author Posted July 5, 2014 Another problem is showing up, I guess it's the second argument of outputChatBox in line 13 Screw putin
SkittlesAreFalling Posted July 5, 2014 Posted July 5, 2014 tostring(amount) http://www.prntscr.com/4fkwyj
SkittlesAreFalling Posted July 5, 2014 Posted July 5, 2014 But you cannot set a string with a number in Lua, you must convert the number to string: outputChatBox("You gave #00FF00$"..tostring(amount).."#0096FF to #FFFFFF"..getPlayerName(target)); Do not argue just test it before being naive. http://www.prntscr.com/4fkwyj
MTA Team botder Posted July 5, 2014 MTA Team Posted July 5, 2014 outputChatBox("You gave #00FF00$"..tostring(amount).."#0096FF to #FFFFFF"..getPlayerName(target)) Again the wrong variable: outputChatBox("You gave #00FF00$"..tostring(amount).."#0096FF to #FFFFFF"..getPlayerName(targetplayer)) GitHub: Debug Console • MTA-Discord Relay Scripting: How to draw a line chart with DirectX functions? • Doppler Effect in MTA • Get the client's FPS • Customizable Blur Shader
-.Paradox.- Posted July 5, 2014 Posted July 5, 2014 But you cannot set a string with a number in Lua, you must convert the number to string:outputChatBox("You gave #00FF00$"..tostring(amount).."#0096FF to #FFFFFF"..getPlayerName(target)); Do not argue just test it before being naive. Line 12 is working fine for target player Without converting it, The problem is that it doesnt show for the player who sent the money.... If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
SkittlesAreFalling Posted July 5, 2014 Posted July 5, 2014 (edited) I just copied and pasted the code you had and edited the problem I saw for you. As long as it's fixed now: outputChatBox("You gave #00FF00$"..tostring(amount).."#0096FF to #FFFFFF"..getPlayerName(targetplayer), player, 0, 81, 255, true); Edited July 5, 2014 by Guest http://www.prntscr.com/4fkwyj
-.Paradox.- Posted July 5, 2014 Posted July 5, 2014 Try changing player argument If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
Et-win Posted July 15, 2014 Posted July 15, 2014 function giveSomeoneMoney(player, cmd, target, amount) if target then if amount then local money = getPlayerMoney(player) local targetplayer = getPlayerFromParticalName(target) local r,g,b = getPlayerNametagColor(player) amount = tonumber(amount) if targetplayer then if money >= amount then givePlayerMoney(targetplayer, amount) takePlayerMoney(player, amount) outputChatBox("You have been given #00FF00$"..tostring(amount).." #0096FF from #FFFFFF"..getPlayerName(player) , targetplayer, 0, 81, 255, true) outputChatBox("You gave #00FF00$"..tostring(amount).."#0096FF to #FFFFFF"..getPlayerName(targetplayer), player, 0, 81, 255, true) else outputChatBox("You don't have enought money!", player, 255, 0, 0) end else outputChatBox("Error: Player not found", player, 255, 0, 0) end else outputChatBox("Error: /givemoney [player name] [amount]", player, 255, 0, 0) end else outputChatBox("Error: /givemoney [player name] [amount]", player, 255, 0, 0) end end addCommandHandler("givemoney", giveSomeoneMoney) function getPlayerFromParticalName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end Did everything what they said with your script and it works. EDIT: Edited it after forgetting to change a line back to normal. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
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