ViRuZGamiing Posted December 12, 2013 Share Posted December 12, 2013 Hello Community, This is my first long self-written script i've went to wiki pretty much and wrote this.. It seems to work I also debugged it and removed errors before posting here. Now i want to ask you guys how to continue? What needs to happen? /bounty : Outputs "write /setbounty to set a bounty" /setbounty : should set a bounty of an amount on a player Setbounty explained Player 1 writes "/setbounty Player2 Amount" the amount will be taken from Player 1 Player 2 gets set in the team Bounty, A red nametag also appears. The first one who kills Player 2 gets the money and the nametag and team will be set to normal. Extra: People cannot set more then 1 bounty in 5 minutes < antispam local antispam = {} local bountyTeam = createTeam ( "Bounty" ) function bountySet (thePlayer, command, amount ) local money = getPlayerMoney(thePlayer) if getPlayerTeam == bounty then outputChatBox("You cannot set a bounty on a bounty!", player, 225, 0, 0) end if (money > bountyPay) then takePlayerMoney ( thePlayer, tonumber(amount) ) setPlayerNametagColor (thePlayer, 225, 0, 0) setPlayerTeam(target, Bounty) outputChatBox("A bounty of has been set on"..getPlayerName(thePlayer), thePlayer) end end function bountyInfo () outputChatBox("write /setbounty to set a bounty", player, 225, 0, 0) if ( antispam[getPlayerSerial(player)] ) and ( getTickCount()-antispam[getPlayerSerial(player)] < 300000 ) then outputChatBox( "You can't use /kill multiple Times", player, 225, 0, 0) outputChatBox( "Only once every 5 minutes!", player, 225, 0, 0) end end function bountyKill (ammo, killer, killerweapon, bodypart) if (killer) and (killer ~= source) then if getPlayerTeam == bounty then givePlayerMoney(killer, amount) end -- Part for return Team and Nametag end end addCommandHandler ("bounty", bountyInfo) addCommandHandler ("setbounty", bountySet) addEventHandler ("onPlayerWasted", getRootElement(), bountyKill) I hope you guys understand what i mean it's a bit like GTA Online but with commands. Link to comment
TAPL Posted December 12, 2013 Share Posted December 12, 2013 Not Tested. local bountyTeam = createTeam("Bounty") function bountySet(player, cmd, amount, target) local amount = tonumber(amount) local target = getPlayerFromName(target) if target and amount then local team = getPlayerTeam(target) if team ~= bountyTeam then local money = getPlayerMoney(player) if (money >= amount) then local r, g, b = getPlayerNametagColor(target) setElementData(target, "Bounty", {amount, team, r, g, b}) takePlayerMoney(player, amount) setPlayerTeam(target, bountyTeam) setPlayerNametagColor(target, 225, 0, 0) outputChatBox("A bounty of has been set on "..getPlayerName(target), player) else outputChatBox("You don't have this amount.", player, 225, 0, 0) end else outputChatBox("You cannot set a bounty on a bounty!", player, 225, 0, 0) end end end addCommandHandler("setbounty", bountySet) function bountyKill(ammo, killer, killerweapon, bodypart) if (killer) and getElementType(killer) == "player" and (killer ~= source) then if getPlayerTeam(source) == bountyTeam then local BountyTable = getElementData(source, "Bounty") if BountyTable then givePlayerMoney(killer, BountyTable[1]) setPlayerTeam(source, BountyTable[2]) setPlayerNametagColor(source, BountyTable[3], BountyTable[4], BountyTable[5]) setElementData(source, "Bounty", false) end end end end addEventHandler("onPlayerWasted", root, bountyKill) --[[ I don't understand what are you trying to do here. local antispam = {} function bountyInfo () outputChatBox("write /setbounty to set a bounty", player, 225, 0, 0) if ( antispam[getPlayerSerial(player)] ) and ( getTickCount()-antispam[getPlayerSerial(player)] < 300000 ) then outputChatBox( "You can't use /kill multiple Times", player, 225, 0, 0) outputChatBox( "Only once every 5 minutes!", player, 225, 0, 0) end end addCommandHandler ("bounty", bountyInfo) ]] Link to comment
ViRuZGamiing Posted December 12, 2013 Author Share Posted December 12, 2013 The part you didn't understand is to prevent Spamming the command and not using the setbounty more then once every 5 minutes... The first output is just to tell people they can use setbounty Link to comment
Moderators IIYAMA Posted December 14, 2013 Moderators Share Posted December 14, 2013 Not tested function bountyInfo (player) outputChatBox("write /setbounty to set a bounty", player, 225, 0, 0) local playerSerial = getPlayerSerial(player) if not playerSerial then return false end local timeNow = getTickCount() local playerTickCountInfo = antispam[playerSerial] if not playerTickCountInfo or timeNow > playerTickCountInfo then antispam[playerSerial] = timeNow+300000 return true else outputChatBox( "You can't use /kill multiple Times", player, 225, 0, 0) outputChatBox( "Only once every 5 minutes!", player, 225, 0, 0) return false end end addEventHandler("onPlayerQuit",root, -- very important to clean up the table.......... function () local playerSerial = getPlayerSerial(player) if antispam[playerSerial] then antispam[playerSerial] = nil end end) Link to comment
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