Opa cara, ajudou demais! Porém ao colocar a função de reparar não funcionou Consegue nos ajudar??
**Também queriamos colocar pra que apenas quem estiver no grupo da ACL "Mecanico" poderia usar este comando. Mas todos pudessem usar o /aceitar ou /recusar. Sabe se tem como??
function getPlayerFromPartialName (name)
local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
if name then
for _, player in ipairs(getElementsByType("player")) do
local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
if name_:find(name, 1, true) then
return player
end
end
end
end
function solicitaPay (thePlayer, cmd, user)
if not user then
outputChatBox ("Erro de sintaxe, use /consertar <nick>", thePlayer, 255, 255, 0)
elseif not getPlayerFromPartialName (user) then
outputChatBox ("Jogador não encontrado.", thePlayer, 255, 255, 0)
else
local theUser = getPlayerFromPartialName (user)
if getElementData (theUser, "mecanico.solicitation") then
outputChatBox ("Alguém já está solicitando pagamento mecânico a este jogador.", thePlayer, 255, 255, 0)
else
setElementData (theUser, "mecanico.solicitation", thePlayer)
outputChatBox ("Você solicitou pagamento para consertar o veículo de "..user, thePlayer, 0, 255, 0, true)
outputChatBox (getPlayerName (thePlayer).."#FFFF00 está pedindo $800 para consertar seu veículo. Use /aceitar ou /recusar", theUser, 255, 255, 255, true)
setTimer (function ()
if getElementData (theUser, "mecanico.solicitation") then
setElementData (theUser, "mecanico.solicitation", false)
outputChatBox ("O pedido de pagamento de "..getPlayerName (thePlayer).."#FFFF00 expirou.", theUser, 255, 255, 0, true)
end
end, 10000, 1)
end
end
end
addCommandHandler ("consertar", solicitaPay)
function aceitaPay (thePlayer, cmd)
if getElementData (thePlayer, "mecanico.solicitation") then
if getPlayerMoney (thePlayer) >= 800 then
takePlayerMoney (thePlayer, 800)
givePlayerMoney (getElementData (thePlayer, "mecanico.solicitation"), 800)
outputChatBox ("Seu pedido foi aceito. Voce recebeu $800 pelo conserto.", getElementData (thePlayer, "mecanico.solicitation"), 0, 255, 0)
function fix (playerSource)
local theVehicle = getPedOccupiedVehicle (playerSource)
if theVehicle and getVehicleController ( theVehicle ) == playerSource then
fixVehicle (theVehicle)
outputChatBox ("Your vehicle has been fixed !" , thePlayer)
end
end
addCommandHandler ("fix" , fix)
setElementData (thePlayer, "mecanico.solicitation", false)
outputChatBox ("Seu veículo foi consertado.", thePlayer, 0, 255, 0)
else
outputChatBox ("Você não tem dinheiro suficiente.", thePlayer, 255, 0, 0)
end
end
end
addCommandHandler ("aceitar", aceitaPay)
function recusaPay (thePlayer, cmd)
if getElementData (thePlayer, "mecanico.solicitation") then
outputChatBox ("Seu pedido foi recusado.", getElementData (thePlayer, "mecanico.solicitation"), 255, 0, 0)
setElementData (thePlayer, "mecanico.solicitation", false)
outputChatBox ("Você recusou o pagamento. Seu veículo não foi consertado.", thePlayer, 255, 0, 0)
end
end
addCommandHandler ("recusar", recusaPay)
Valeu DEMAIS!