Apo Posted May 7, 2016 Share Posted May 7, 2016 hi guys please help me for make command for targetplayer for accept pay money if target player no accept ticket player no pay money script 100% work only i need accept command for targetplayer for pay money function ticket(thePlayer, commandName, targetPlayerNick, price, ...) local logged = getElementData(thePlayer, "login") local targetPlayer, targetPlayerName =findPlayerByPartialNick(thePlayer, targetPlayerNick) local hoursplayed = getElementData(targetPlayer, "hoursplay") if targetPlayer then if (logged==1) then local theTeam = getPlayerTeam(thePlayer) local factionType = getElementData(theTeam, "type") if (factionType==2) then if not (targetPlayerNick) or not (price) or not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick] [Amount] [Reason]", thePlayer, 255, 194, 14) elseif hoursplayed<= 2 then outputChatBox("This person is less then hoursplayed!", thePlayer, 255, 0, 0) else price= tonumber(price) if (price>= 61) then outputChatBox("This is too much to ask for.", thePlayer, 255, 0, 0) else local x, y, z = getElementPosition(thePlayer) local tx, ty, tz = getElementPosition(targetPlayer) local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) if (distance >= 10) then outputChatBox("You are too far away '".. targetPlayerName .."'.", thePlayer, 255, 0, 0) else local reason = table.concat({...}, " ") local money = getMoney(targetPlayer) local bankmoney = getElementData(targetPlayer, "bankmoney") if money + bankmoney >= 1 then if money + bankmoney < amount then outputChatBox("The player cannot afford the ticket(not money).", thePlayer, 255, 0, 0) else local takeFromCash = math.min( money, amount ) local takeFromBank = amount - takeFromCash takeMoney(targetPlayer, takeFromCash) -- Distribute money between the PD and Government local tax = exports.global:getTaxAmount() giveMoney( theTeam, math.ceil((1-tax)*price) ) giveMoney( getTeamFromName("Government of Los Santos"), math.ceil(tax*amount) ) outputChatBox("You ticketed " .. targetPlayerName .. " for " .. formatMoney(amount) .. ". Reason: " .. reason .. ".", thePlayer) outputChatBox("You were ticketed for " .. formatMoney(amount) .. " by " .. getPlayerName(thePlayer) .. ". Reason: " .. reason .. ".", targetPlayer) if takeFromBank > 0 then outputChatBox("Since you don't have enough money with you, $" .. formatMoney(takeFromBank) .. " have been taken from your bank account.", targetPlayer) end end end end end end end end end end addCommandHandler("ticket", ticket, false, false) Link to comment
Dimos7 Posted May 8, 2016 Share Posted May 8, 2016 function ticket(thePlayer, commandName, targetPlayerNick, price, ...) local logged = getElementData(thePlayer, "login") local targetPlayer, targetPlayerName =findPlayerByPartialNick(thePlayer, targetPlayerNick) local hoursplayed = getElementData(targetPlayer, "hoursplay") if targetPlayer then if (logged==1) then local theTeam = getPlayerTeam(thePlayer) local factionType = getElementData(theTeam, "type") if (factionType==2) then if not (targetPlayerNick) or not (price) or not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick] [Amount] [Reason]", thePlayer, 255, 194, 14) elseif hoursplayed<= 2 then outputChatBox("This person is less then hoursplayed!", thePlayer, 255, 0, 0) else price= tonumber(price) if (price>= 61) then outputChatBox("This is too much to ask for.", thePlayer, 255, 0, 0) else local x, y, z = getElementPosition(thePlayer) local tx, ty, tz = getElementPosition(targetPlayer) local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) if (distance >= 10) then outputChatBox("You are too far away '".. targetPlayerName .."'.", thePlayer, 255, 0, 0) else local reason = table.concat({...}, " ") local money = getMoney(targetPlayer) local bankmoney = getElementData(targetPlayer, "bankmoney") if money + bankmoney >= 1 then if money + bankmoney < amount then outputChatBox("The player cannot afford the ticket(not money).", thePlayer, 255, 0, 0) else local takeFromCash = math.min( money, amount ) local takeFromBank = amount - takeFromCash if commandName == "accept" then takeMoney(targetPlayer, takeFromCash) end -- Distribute money between the PD and Government local tax = exports.global:getTaxAmount() giveMoney( theTeam, math.ceil((1-tax)*price) ) giveMoney( getTeamFromName("Government of Los Santos"), math.ceil(tax*amount) ) outputChatBox("You ticketed " .. targetPlayerName .. " for " .. formatMoney(amount) .. ". Reason: " .. reason .. ".", thePlayer) outputChatBox("You were ticketed for " .. formatMoney(amount) .. " by " .. getPlayerName(thePlayer) .. ". Reason: " .. reason .. ".", targetPlayer) if takeFromBank > 0 then outputChatBox("Since you don't have enough money with you, $" .. formatMoney(takeFromBank) .. " have been taken from your bank account.", targetPlayer) end end end end end end end end end end addCommandHandler("ticket", ticket, false, false) Link to comment
Apo Posted May 8, 2016 Author Share Posted May 8, 2016 i need command for target player if accepttickect theplayer pay money else no pay money Link to comment
Dimos7 Posted May 8, 2016 Share Posted May 8, 2016 function ticket(thePlayer, commandName, targetPlayerNick, price, ...) local logged = getElementData(thePlayer, "login") local targetPlayer, targetPlayerName =findPlayerByPartialNick(thePlayer, targetPlayerNick) local hoursplayed = getElementData(targetPlayer, "hoursplay") if targetPlayer then if (logged==1) then local theTeam = getPlayerTeam(thePlayer) local factionType = getElementData(theTeam, "type") if (factionType==2) then if not (targetPlayerNick) or not (price) or not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick] [Amount] [Reason]", thePlayer, 255, 194, 14) elseif hoursplayed<= 2 then outputChatBox("This person is less then hoursplayed!", thePlayer, 255, 0, 0) else price= tonumber(price) if (price>= 61) then outputChatBox("This is too much to ask for.", thePlayer, 255, 0, 0) else local x, y, z = getElementPosition(thePlayer) local tx, ty, tz = getElementPosition(targetPlayer) local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) if (distance >= 10) then outputChatBox("You are too far away '".. targetPlayerName .."'.", thePlayer, 255, 0, 0) else local reason = table.concat({...}, " ") local money = getMoney(targetPlayer) local bankmoney = getElementData(targetPlayer, "bankmoney") if money + bankmoney >= 1 then if money + bankmoney < amount then outputChatBox("The player cannot afford the ticket(not money).", thePlayer, 255, 0, 0) else local takeFromCash = math.min( money, amount ) local takeFromBank = amount - takeFromCash if targetPlayer and commandName == "accept" then takeMoney(targetPlayer, takeFromCash) end -- Distribute money between the PD and Government local tax = exports.global:getTaxAmount() giveMoney( theTeam, math.ceil((1-tax)*price) ) giveMoney( getTeamFromName("Government of Los Santos"), math.ceil(tax*amount) ) outputChatBox("You ticketed " .. targetPlayerName .. " for " .. formatMoney(amount) .. ". Reason: " .. reason .. ".", thePlayer) outputChatBox("You were ticketed for " .. formatMoney(amount) .. " by " .. getPlayerName(thePlayer) .. ". Reason: " .. reason .. ".", targetPlayer) if takeFromBank > 0 then outputChatBox("Since you don't have enough money with you, $" .. formatMoney(takeFromBank) .. " have been taken from your bank account.", targetPlayer) end end end end end end end end end end addCommandHandler("ticket", ticket, false, false) Link to comment
Apo Posted May 8, 2016 Author Share Posted May 8, 2016 function ticket(thePlayer, commandName, targetPlayerNick, price, ...) local logged = getElementData(thePlayer, "login") local targetPlayer, targetPlayerName =findPlayerByPartialNick(thePlayer, targetPlayerNick) local hoursplayed = getElementData(targetPlayer, "hoursplay") if targetPlayer then if (logged==1) then local theTeam = getPlayerTeam(thePlayer) local factionType = getElementData(theTeam, "type") if (factionType==2) then if not (targetPlayerNick) or not (price) or not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick] [Amount] [Reason]", thePlayer, 255, 194, 14) elseif hoursplayed<= 2 then outputChatBox("This person is less then hoursplayed!", thePlayer, 255, 0, 0) else price= tonumber(price) if (price>= 61) then outputChatBox("This is too much to ask for.", thePlayer, 255, 0, 0) else local x, y, z = getElementPosition(thePlayer) local tx, ty, tz = getElementPosition(targetPlayer) local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz) if (distance >= 10) then outputChatBox("You are too far away '".. targetPlayerName .."'.", thePlayer, 255, 0, 0) else local reason = table.concat({...}, " ") local money = getMoney(targetPlayer) local bankmoney = getElementData(targetPlayer, "bankmoney") if money + bankmoney >= 1 then if money + bankmoney < amount then outputChatBox("The player cannot afford the ticket(not money).", thePlayer, 255, 0, 0) else local takeFromCash = math.min( money, amount ) local takeFromBank = amount - takeFromCash if targetPlayer and commandName == "accept" then takeMoney(targetPlayer, takeFromCash) end -- Distribute money between the PD and Government local tax = exports.global:getTaxAmount() outputChatBox("You ticketed " .. targetPlayerName .. " for " .. formatMoney(amount) .. ". Reason: " .. reason .. ".", thePlayer) outputChatBox("You were ticketed for " .. formatMoney(amount) .. " by " .. getPlayerName(thePlayer) .. ". Reason: " .. reason .. ".", targetPlayer) if takeFromBank > 0 then outputChatBox("Since you don't have enough money with you, $" .. formatMoney(takeFromBank) .. " have been taken from your bank account.", targetPlayer) end end end end end end end end end end addCommandHandler("ticket", ticket, false, false) next report man please no paste my code in the post no spam 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