Eshtiz Posted February 5, 2012 Posted February 5, 2012 (edited) I've been trying to make a command that takes money from a specific player ID/name here's what I got so far (I've checked wiki, didn't work well): function takeMoney(thePlayer, commandName, target, money) if (exports.global:isPlayerLeadAdmin(thePlayer)) then if not (target) then outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [Money]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target) if targetPlayer then local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) exports.logs:logMessage("[GIVE] " .. getPlayerName(thePlayer):gsub("_", " ") .. " gave " .. targetPlayerName .. " to $" .. money, 23) exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.") exports.global:takeMoney(targetPlayer, money) outputChatBox("Random text " .. targetPlayerName .. " $" .. money .. ".", thePlayer) outputChatBox("Admin " .. username .. " has taken $" .. money .. ".", targetPlayer) outputChatBox(" " .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " took " .. targetPlayerName .. " " .. money .. " dollars.", getRootElement(), 255, 0, 51) end end end end I reversed it from a 'givemoney' script/command and hoped for it to work, but doesn't, any suggestionss on how to? I checked this: https://wiki.multitheftauto.com/wiki/TakePlayerMoney didn't really work either. Edited February 7, 2012 by Guest
Eshtiz Posted February 5, 2012 Author Posted February 5, 2012 The whole script, it doesn't take money, no syntax, nothing.
Castillo Posted February 5, 2012 Posted February 5, 2012 You didn't add the command handler yet, or that's not the whole script?
Kenix Posted February 5, 2012 Posted February 5, 2012 Server side. function takeMoney( thePlayer, commandName, target, money ) if exports.global:isPlayerLeadAdmin( thePlayer ) then if not target then outputChatBox( "SYNTAX: /" .. commandName .. " [Partial Player Nick] [Money]", thePlayer, 255, 194, 14 ) else local username = getPlayerName(thePlayer) local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick( thePlayer, target ) if targetPlayer then local adminTitle = exports.global:getPlayerAdminTitle( thePlayer ) exports.logs:logMessage( "[GIVE] " .. getPlayerName(thePlayer):gsub("_", " ") .. "\ gave " .. targetPlayerName .. " to $" .. money, 23 ) exports.global:sendMessageToAdmins( "AdmCmd: " .. getPlayerName( thePlayer ) .. "\ gave " .. targetPlayerName .. " " .. money .. " dollars." ) exports.global:takeMoney( targetPlayer, tonumber( money ) ) outputChatBox( "Random text " .. targetPlayerName .. " $" .. money .. ".", thePlayer ) outputChatBox( "Admin " .. username .. " has taken $" .. money .. ".", targetPlayer ) outputChatBox( " " .. tostring( adminTitle ) .. "\ " .. getPlayerName( thePlayer ) .. " took " .. targetPlayerName .. "\ " .. money .. " dollars.", root, 255, 0, 51 ) end end else outputChatBox( ' not isPlayerLeadAdmin' ) end end addCommandHandler( 'takemoney',takeMoney ) cmd /takemoney [player][ money ]
Eshtiz Posted February 6, 2012 Author Posted February 6, 2012 You're not a lead admin then, Esh. I am, but as Solidsnake said, I forgot the command handler, stupid of me, sorry for wasting time. but I got something else , I'm trying to make the /givemoney command "globaly" remove the ID and give everyone online an amount of money. this is what I got so far: function giveAllMoney(thePlayer, commandName, money) if (exports.global:isPlayerLeadAdmin(thePlayer)) then if not (target) then outputChatBox("SYNTAX: /" .. commandName .. " [Money]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) if targetPlayer then local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) exports.logs:logMessage("[GIVE] " .. getPlayerName(thePlayer):gsub("_", " ") .. " gave " .. targetPlayerName .. " to $" .. money, 23) exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.") outputChatBox("You have given $" .. money .. " to all players ", thePlayer) outputChatBox("Admin " .. username .. " has given you $" .. money .. ".", targetPlayer) outputChatBox(" " .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.", getRootElement(), 255, 0, 51) end end end end addCommandHandler("giveallmoney", giveAllMoney, false, false) Only syntax shows but doesn't give money to anyone when it's supposed to give ALL online players.
Castillo Posted February 6, 2012 Posted February 6, 2012 function giveAllMoney(thePlayer, commandName, money) if (exports.global:isPlayerLeadAdmin(thePlayer)) then if (not money) then outputChatBox("SYNTAX: /" .. commandName .. " [Money]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.") outputChatBox("You have given $" .. money .. " to all players ", thePlayer) for index, player in ipairs(getElementsByType("player")) do exports.global:giveMoney( player, tonumber( money ) ) outputChatBox("Admin " .. username .. " has given you $" .. money .. ".", player) end outputChatBox(" " .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.", getRootElement(), 255, 0, 51) end end end addCommandHandler("giveallmoney", giveAllMoney, false, false)
Eshtiz Posted February 6, 2012 Author Posted February 6, 2012 Doesn't work, no syntax, no command, no money ;S Error message: ERROR: admin-system/Player/s_player_commands.lua:1791: attempt to concaenate local 'money'(a nil value)
Castillo Posted February 6, 2012 Posted February 6, 2012 Copy the script again, I've changed a few things.
Eshtiz Posted February 6, 2012 Author Posted February 6, 2012 Yeh, I'm back to page one. Only shows the syntax and doesn't hand out any money ;/ and yeh, I'm using it ServerSide & I have similar scripts to this one ServerSided, why wouldn't it work on ServerSide?
Castillo Posted February 6, 2012 Posted February 6, 2012 Eshtiz: Don't listen to Evil-Codr, he's a newbie, this is server side, not client side. And it should work, I don't know much about Valhalla Scripts.
Eshtiz Posted February 6, 2012 Author Posted February 6, 2012 Ah, I see, well I have this givemoney script/command directed for an(specific) ID/player. If it helps, function giveMoney(thePlayer, commandName, target, money) if (exports.global:isPlayerLeadAdmin(thePlayer)) then if not (target) then outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [Money]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target) if targetPlayer then local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) exports.logs:logMessage("[GIVE] " .. getPlayerName(thePlayer):gsub("_", " ") .. " gave " .. targetPlayerName .. " to $" .. money, 23) exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.") exports.global:giveMoney(targetPlayer, money) outputChatBox("You have given " .. targetPlayerName .. " $" .. money .. ".", thePlayer) outputChatBox("Admin " .. username .. " has given you $" .. money .. ".", targetPlayer) outputChatBox(" " .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave " .. targetPlayerName .. " " .. money .. " dollars.", getRootElement(), 255, 0, 51) end end end end addCommandHandler("givemoney", giveMoney, false, false) if not I'll try myself again people have been giving a lot of suggestions etc, nothing worked yet. anyways, there it is, might help to complete the giveallmoney script.
Castillo Posted February 7, 2012 Posted February 7, 2012 function giveAllMoney(thePlayer, commandName, money) if (exports.global:isPlayerLeadAdmin(thePlayer)) then if (not money) then outputChatBox("SYNTAX: /" .. commandName .. " [Money]", thePlayer, 255, 194, 14) else local username = getPlayerName(thePlayer) local adminTitle = exports.global:getPlayerAdminTitle(thePlayer) exports.global:sendMessageToAdmins("AdmCmd: " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.") outputChatBox("You have given $" .. money .. " to all players ", thePlayer) for index, player in ipairs(getElementsByType("player")) do exports.global:giveMoney( player, tonumber( money ) ) outputChatBox("Admin " .. username .. " has given you $" .. money .. ".", player) end outputChatBox(" " .. tostring(adminTitle) .. " " .. getPlayerName(thePlayer) .. " gave all players online " .. money .. " dollars.", getRootElement(), 255, 0, 51) end end end addCommandHandler("giveallmoney", giveAllMoney, false, false) I tested it and seems to work.
Eshtiz Posted February 7, 2012 Author Posted February 7, 2012 That one works well, but isn't it the same as the old one? (if it is, I guess I got an old one while you edited previous posts) >,< How do I edit the font style for it and any fonts for similar texts? can you link me something?
Castillo Posted February 7, 2012 Posted February 7, 2012 I have changed something, is not the same as the previous. You can't change the chatbox message fonts.
Eshtiz Posted February 7, 2012 Author Posted February 7, 2012 Aww, too bad ;s, is there any way to put shadow behind the text like in the chatbox on other texts then?
Castillo Posted February 7, 2012 Posted February 7, 2012 No, is not. The only way would be scripting your own CHAT BOX system, trust me, is not going to be easy .
Eshtiz Posted February 7, 2012 Author Posted February 7, 2012 Oh, haha okay. I want to feel like a burden nor a tool but my topic got outdated and I can't double post feel free to check it >.> viewtopic.php?f=91&t=39915&start=30
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