Jump to content

/cash name


[DMC]

Recommended Posts

function checkMoney(thePlayer, command, who) 
if (who == nil ) or who == false then 
outputChatBox ("ERROR: You must insert a valid player name.", thePlayer, 255, 0, 0, false) 
else 
local money = getPlayerMoney(targetPlayerName)    
local Name = getPlayerName(targetPlayerName)  
local targetPlayerName = getPlayerFromName (who)                                                                                   outputChatBox("*"..who.." Has $"..getPlayerMoney(who).."",getRootElement(),255,255,0) 
end 
addCommandHandler("cash", checkMoney)  
       
  

And yes varez i first thought about it cuz first i had getPlayerMoney(thePlayer) and i know thats just wrong

Please any help its saying local money/name has bad arguments

Edited by Guest
Link to comment
function checkMoney2(thePlayer, command, who) 
if (who == nil ) or who == false then 
outputChatBox ("ERROR: You must insert a valid player name.", thePlayer, 255, 0, 0, false) 
else 
local who2 = getPlayerFromName(who) 
local Name = getPlayerName(who2) 
outputChatBox("*"..who.." Has $"..getPlayerMoney(who2).."",getRootElement(),255,255,0) 
end 
end 
addCommandHandler("cash", checkMoney2)  

you forgot to do getPlayerFromName

Link to comment

Looks like it is just layed out backwards there almost. Try something like this (Sorry if there are any errors, the wiki is down and i can't make 100% sure i put the exact right function)

  
function findPlayerMoney(player,command,player2) 
       if (player2) then 
              local name = getPlayerFromName(player2) 
              if (name) then 
                    local playerMoney = getPlayerMoney(name) 
                    outputChatBox(player2.." has $"..tostring(playerMoney),player,255,255,0) 
              else 
                     outputChatBox("No player found for "..player2,player,255,0,0) 
             end 
       else 
               outputChatBox("Player not specified. The proper command goes like: /cash player",player,255,0,0) 
       end 
end 
  
addCommandHandler("cash",findPlayerMoney) 
  

If you find the nickname autocomplete function, it makes this script a lot better too, since you don't have to type out people's whole names when looking them up in a command. I can't remember that off the top of my head, so this will do for now. Good luck with your scripting!

Link to comment

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