Nekem máshogy néz ki ez a dolog.
function givePlayerLicense(thePlayer, commandName, targetPlayerName, licenseType)
local logged = getElementData(thePlayer, \"loggedin\")
if (logged==1) then
local theTeam = getPlayerTeam(thePlayer)
local factionType = getElementData(theTeam, \"type\")
if (factionType==3) then
if not targetPlayerName or not (licenseType and (licenseType == \"1\" or licenseType == \"2\")) then
outputChatBox(\"Példa: /\" .. commandName .. \" [NévRészlet] [Típus]\", thePlayer, 255, 194, 14)
outputChatBox(\"Típus 1 = Jogosítvány\", thePlayer, 255, 194, 14)
outputChatBox(\"Típus 2 = Fegyverengedély\", thePlayer, 255, 194, 14)
else
local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerName)
if targetPlayer then
local logged = getElementData(targetPlayer, \"loggedin\")
price = 1000000
if (logged==0) then
outputChatBox(\"A játékos nincs bejelentkezve.\", thePlayer, 255, 0, 0)
elseif (logged==1) then
local licenseTypeOutput = licenseType == \"1\" and \"Jogosítvány\" or \"fegyver\"
licenseType = licenseType == \"1\" and \"car\" or \"gun\"
if getElementData(targetPlayer, \"license.\"..licenseType) == 1 then
outputChatBox(getPlayerName(thePlayer)..\"-nak már van \"..licenseTypeOutput..\" engedélye.\", thePlayer, 255, 255, 0)
else
local money = exports.global:getMoney(targetPlayer)
local bankmoney = getElementData(targetPlayer, \"bankmoney\")
if money + bankmoney < price then
outputChatBox(\"Játékosnak nincs elég pénze.\", thePlayer, 255, 0, 0)
return
else
local takeFromCash = math.min( money, price )
local takeFromBank = price - takeFromCash
exports.global:takeMoney(targetPlayer, takeFromCash)
if takeFromBank > 0 then
exports[\'anticheat-system\']:changeProtectedElementDataEx(targetPlayer, \"bankmoney\", bankmoney - takeFromBank)
end
exports.global:giveMoney( getTeamFromName(\"Országos Rendőr Fő-kapitányság\"), price + 50000 )
if (licenseType == \"gun\") then
exports[\'anticheat-system\']:changeProtectedElementDataEx(targetPlayer, \"license.\"..licenseType, 1)
mysql:query_free(\"UPDATE characters SET \"..mysql:escape_string(licenseType)..\"_license=\'1\' WHERE id = \"..mysql:escape_string(getElementData(targetPlayer, \"dbid\"))..\" LIMIT 1\")
outputChatBox(\"Játékos \"..targetPlayerName..\" kapott egy \"..licenseTypeOutput..\" engedélyt.\", thePlayer, 0, 255, 0)
outputChatBox(\"\"..getPlayerName(thePlayer):gsub(\"_\",\" \")..\" adott neked \"..licenseTypeOutput..\" engedélyt.\", targetPlayer, 0, 255, 0)
exports.global:SendMessageToTeam(\"Országos Rendőr Fő-kapitányság\",\"Játékos \"..targetPlayerName..\" kapott egy \"..licenseTypeOutput..\" engedélyt. \"..getPlayerName(thePlayer):gsub(\"_\",\" \")..\" által.\", 255, 124, 14)
exports.logs:logMessage(\"[/GIVELICENSE] \" .. getElementData(thePlayer, \"gameaccountusername\") .. \"/\".. getPlayerName(thePlayer) ..\" gave \".. targetPlayerName ..\" the following license:\"..licenseTypeOutput, 4)
else
exports[\'anticheat-system\']:changeProtectedElementDataEx(targetPlayer, \"license.\"..licenseType, 1)
mysql:query_free(\"UPDATE characters SET \"..mysql:escape_string(licenseType)..\"_license=\'1\' WHERE id = \"..mysql:escape_string(getElementData(targetPlayer, \"dbid\"))..\" LIMIT 1\")
outputChatBox(\"Játékos \"..targetPlayerName..\" kapott egy \"..licenseTypeOutput..\" engedélyt.\", thePlayer, 0, 255, 0)
outputChatBox(\"\"..getPlayerName(thePlayer):gsub(\"_\",\" \")..\" adott neked \"..licenseTypeOutput..\" engedélyt.\", targetPlayer, 0, 255, 0)
exports.global:SendMessageToTeam(\"Országos Rendőr Fő-kapitányság\",\"Játékos \"..targetPlayerName..\" kapott egy \"..licenseTypeOutput..\" engedélyt. \"..getPlayerName(thePlayer):gsub(\"_\",\" \")..\" által.\", 255, 124, 14)
exports.logs:logMessage(\"[/GIVELICENSE] \" .. getElementData(thePlayer, \"gameaccountusername\") .. \"/\".. getPlayerName(thePlayer) ..\" gave \".. targetPlayerName ..\" the following license:\"..licenseTypeOutput, 4)
end
end
end
end
end
end
else
outputChatBox(\" Csak rendőrségnek! \", thePlayer, 255,0,0)
end
end
end
addCommandHandler(\"givelicense\", givePlayerLicense)