Jump to content

Givemoney


ZeyadGTX

Recommended Posts

Posted

I use this givemoney resource which you use /givemoney playername amount

but the problem that you can send money by negative like /givemoney playername -9999

and your money get decreasing i want to disable that !

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 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) 
                else 
                    outputChatBox("You Don't Have Enough Money ! , 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 
 

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(player) 
            amount = tonumber(amount) 
            if targetplayer then 
                if string.find(tostring(amount), "-", true) then 
                    return outputChatBox("Sorry, you are not allowed to send negative money!", player ) 
                end  
                if money >= amount then 
                    givePlayerMoney(targetplayer, amount) 
                    takePlayerMoney(player, amount) 
                    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) 
                else 
                    outputChatBox("You Don't Have Enough Money ! , 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 
  
  
 

Thanks Works 100%

Posted

I got problem

Givemoney\script.lua:19: unfinished string near '"You Don't Have Enough Money ! , player, 255, 0, 0)'

[2014-09-16 05:56:15] ERROR: Loading script failed: (Sroam)Givemoney\script.lua:19: unfinished string near '"You Don't Have Enough Money ! , player, 255, 0, 0)'

Posted

Lot of errors

(Sroam)Givemoney\script.lua:35: 'end' expected (to close 'if' at line 6) near ''

[2014-09-16 06:20:04] ERROR: Loading script failed: (Sroam)Givemoney\script.lua:35: 'end' expected (to close 'if' at line 6) near ''

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(player) 
            amount = tonumber(amount) 
            if targetplayer then 
                if string.find(tostring(amount), "-", true) then 
                    return outputChatBox("Sorry, you are not allowed to send negative money!", player ) 
                end 
                if money >= amount then 
                    givePlayerMoney(targetplayer, amount) 
                    takePlayerMoney(player, amount) 
                    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) 
                else 
                    outputChatBox("You Don't Have Enough Money !" , 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 
  
  
  

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(player) 
            amount = tonumber(amount) 
            if targetplayer then 
                if string.find(tostring(amount), "-", true) then 
                    return outputChatBox("Sorry, you are not allowed to send negative money!", player ) 
                end 
                if money >= amount then 
                    givePlayerMoney(targetplayer, amount) 
                    takePlayerMoney(player, amount) 
                    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) 
                else 
                    outputChatBox("You Don't Have Enough Money !" , player, 255, 0, 0) 
          end 
     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 
  

Posted
SCRIPT ERROR: (Sroam)Givemoney\script.lua:39: 'end' expected (to close 'if' at line 5) near '' 
[2014-09-16 06:58:33] ERROR: Loading script failed: (Sroam)Givemoney\script.lua:39: 'end' expected (to close 'if' at line 5) near '' 

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(player) 
            amount = tonumber(amount) 
            if targetplayer then 
                if string.find(tostring(amount), "-", true) then 
                    return outputChatBox("Sorry, you are not allowed to send negative money!", player ) 
                end 
                if money >= amount then 
                    givePlayerMoney(targetplayer, amount) 
                    takePlayerMoney(player, amount) 
                    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) 
                else 
                    outputChatBox("You Don't Have Enough Money !" , player, 255, 0, 0) 
               end  
         end 
     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 
  
  

Posted
function giveSomeoneMoney(player, cmd, target, amount) 
    if target then 
        if tonumber(amount) and tonumber(amount) > 0 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 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) 
                else 
                    outputChatBox("You Don't Have Enough Money !" , 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 

Posted
You Just Put Spaces -_-:lol:

I just put spaces? OH woah. You can't even fix a simple error. You don't even know how simple is it to fix the error. THE ERROR TELLS THAT ONE END IS MISSING SO I ADDED IT BY INDENTING THE CODE SO IT IS CLEAN.

Posted
You Just Put Spaces -_-:lol:

I just put spaces? OH woah. You can't even fix a simple error. You don't even know how simple is it to fix the error. THE ERROR TELLS THAT ONE END IS MISSING SO I ADDED IT BY INDENTING THE CODE SO IT IS CLEAN.

+1 He also doesn't know how to finish a string, lol.

Posted

My Code is :

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 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) 
                else 
                    outputChatBox("You Don't Have Enough Money !", player, 255, 0, 0) 
                end 
            else 
                outputChatBox("", player, 255, 0, 0) 
            end 
        else 
            outputChatBox("", player, 255, 0, 0) 
        end 
    else 
        outputChatBox("", 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 

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