Jump to content

[Porblem]Give-money


//_Dragon

Recommended Posts

Posted

I have problem in this script

When some one give to other player money , all players can see in chatbox what he gave

[DR]Dragon gave to [DR]Fedex 5555$

& i add something in script for fixe the problem but still when i give money to player , nothen happened

----[u][b]Before changing[/b][/u] 
function giveSomeoneMoney(player, cmd, target, amount) 
if target then 
if amount then 
local money = getPlayerMoney(player) 
local targetplayer = getPlayerFromName(target) 
amount = tonumber(amount) 
if targetplayer then 
if money >= amount and amount >= 250 then 
givePlayerMoney(targetplayer, amount) 
takePlayerMoney(player, amount) 
outputChatBox(getPlayerName(player).." give "..amount.." to "..getPlayerName(targetplayer), getRootElement(), 0, 165, 0, true) 
else 
outputChatBox("• You don't have enought money!", player, 255, 0, 0) 
end 
else 
outputChatBox("• Player not found", player, 255, 0, 0) 
end 
else 
outputChatBox("• Error: /gm [player name] [amount]", player, 255, 0, 0) 
end 
else 
outputChatBox("• Error: /gm [player name] [amount]", player, 255, 0, 0) 
end 
end 
addCommandHandler("gm", giveSomeoneMoney) 
addCommandHandler("givemoney", giveSomeoneMoney) 

----[b][u]Atfter adding[/u][/b] 
function giveSomeoneMoney(player, cmd, target, amount) 
if target then 
if amount then 
local money = getPlayerMoney(player) 
local targetplayer = getPlayerFromParticalName(target) -------new 
local r,g,b = getPlayerNametagColor(player) -------new  
amount = tonumber(amount) 
if targetplayer then 
if money >= amount and amount >= 250 then 
givePlayerMoney(targetplayer, amount) 
takePlayerMoney(player, amount) 
                    outputChatBox("You Were Given #00FF00$"..tostring(amount).." #006400 From #FF0000"..getPlayerName(player) , targetplayer, 0, 100, 0, true) -------new 
                    outputChatBox("You Gave #00FF00$"..tostring(amount).."#006400 To #FF0000"..getPlayerName(targetplayer), player, 0, 100, 0, true) ------new  
          else 
outputChatBox("• You don't have enought money!", player, 255, 0, 0) 
end 
          else 
outputChatBox("• Player not found", player, 255, 0, 0) 
end 
     else 
outputChatBox("• Error: /gm [player name] [amount]", player, 255, 0, 0) 
end 
                 else 
outputChatBox("• Error: /gm [player name] [amount]", player, 255, 0, 0) 
end 
end 
addCommandHandler("gm", giveSomeoneMoney) 
addCommandHandler("givemoney", giveSomeoneMoney) 

Posted

That's because getPlayerFromParticalName is not defined.

Add this function to the end of the script:

function getPlayerFromParticalName (name) -- BY TAPL 
    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 

Posted

thanks work

but i've a little problem i want getplayercolorname :/

outputChatBox("You Were Given #00FF00$"..tostring(amount).." #006400 From #FF0000"..getPlayerName(player) , targetplayer, 0, 100, 0, true) 
                    outputChatBox("You Gave #00FF00$"..tostring(amount).."#006400 To #FF0000"..getPlayerName(targetplayer), player, 0, 100, 0, true) 

Posted
What do you mean?

I mean like ur nametag color is : Solidsnake14 i must see in chatbox you get were given 2222$ from Solidsnake14 --- ur color

you gave 2222$ to Oussez--Color blue

Posted
Try to do it, if it doesn't work, post here what you tried.
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(thePlayer)  ---- local r, g, b 
local fromHex = string.format("#%.2X%.2X%.2X", r, g, b) -- converts R, G, B to HEX value 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) -- converts R, G, B to HEX value 
amount = tonumber(amount) 
if targetplayer then 
if money >= amount and amount >= 250 then 
givePlayerMoney(targetplayer, amount) 
takePlayerMoney(player, amount) 
                    outputChatBox("You Were Given from " ..fromHex.. getPlayerName(player) .. " #00FF00$"..tostring(amount).." , targetplayer, 0, 100, 0, true)     
                    outputChatBox("You Gave to " ..toHex.. getPlayerName(targetplayer) .. " #00FF00$"..tostring(amount)..", player, 0, 100, 0, true)  

Posted
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(thePlayer)  ---- local r, g, b 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) -- converts R, G, B to HEX value 
amount = tonumber(amount) 
if targetplayer then 
if money >= amount and amount >= 250 then 
givePlayerMoney(targetplayer, amount) 
takePlayerMoney(player, amount) 
outputChatBox("You Were Given from "..hex..getPlayerName(player).." #00FF00$"..tostring(amount).."", targetplayer, 0, 100, 0, true)     
outputChatBox("You Gave to "..hex..getPlayerName(targetplayer).." #00FF00$"..tostring(amount).."", player, 0, 100, 0, true) 
                end 
            end 
        end 
    end 
end 
addCommandHandler("give", giveSomeoneMoney) 

Posted

You both repeated the same errors, and btw your code is totally messy you forgot about 5 ends,

Plus there're some arguments typed and not defined.

Try that, It should works

function giveSomeoneMoney(player, _, target, amount) 
if target then 
if amount then 
local money = getPlayerMoney(player) 
local targetplayer = getPlayerFromParticalName(target) 
local r, g, b = getPlayerNametagColor(targetplayer) 
local pr, pg, pb = getPlayerNametagColor(player)    
local hex = string.format("#%.2X%.2X%.2X", r, g, b) 
local fromHex = string.format("#%.2X%.2X%.2X", pr, pg, pb)   
local amount = tonumber(amount) 
if targetplayer then 
if money >= amount and amount >= 250 then 
 givePlayerMoney(targetplayer, amount) 
 takePlayerMoney(player, amount) 
 outputChatBox("You Were Given from " ..fromHex .. getPlayerName(player).. " #00FF00$"..tostring(amount).."" , targetplayer, 0, 100, 0, true)     
 outputChatBox("You Gave to "..hex..getPlayerName(targetplayer).." #00FF00$"..tostring(amount).."", player, 0, 100, 0, true) 
                 end 
            end 
        end 
    end 
end 
addCommandHandler("give", giveSomeoneMoney) 
  
function getPlayerFromParticalName (name) -- BY TAPL 
    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 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...