Pedro001

Members
  • Content Count

    40
  • Joined

  • Last visited

Community Reputation

1 Neutral

About Pedro001

  • Rank
    Rat

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Pedro001

    HOW TO FIX THIS

    como está nomeado o executavel do gta sa? deve ser gta_sa.exe
  2. Pedro001

    Exporting to the scoreboard.

    MAAAAAAAAAN! I WORKED!!! Thank you sooo much! I was almost giving it up! Thank you very much for that!! I really appreciate it!
  3. Pedro001

    Exporting to the scoreboard.

    I did it, I don't get eny errors, but nothing is shown on the scoreboard though.
  4. Pedro001

    Exporting to the scoreboard.

    Thank you for responding. but where do I put this? I guess I found it, But I still get the number on the scoreboard. Is it really possible to get the name shown instead of the number? I don't wanna bother you guys.
  5. Pedro001

    Exporting to the scoreboard.

    '<name>' expected near '#' on line 13 attempt to index global 'clanRankNames' (a nil value) on line 161
  6. Pedro001

    Exporting to the scoreboard.

    Hii. I tried this one, but now it shows nothing, it stays blank.
  7. Pedro001

    Exporting to the scoreboard.

    No I've got another one, do you need it? MAX_PRIRORITY_SLOT = 500 scoreboardColumns = { { ["name"] = "ID", ["width"] = 20, ["friendlyName"] = "ID", ["priority"] = 1 }, { ["name"] = "name", ["width"] = 200, ["friendlyName"] = "Name", ["priority"] = 2 }, { ["name"] = "fps", ["width"] = 50, ["friendlyName"] = "FPS", ["priority"] = 3 }, --{ ["name"] = "country", ["width"] = 100, ["friendlyName"] = "Country", ["priority"] = MAX_PRIRORITY_SLOT-1 }, { ["name"] = "ping", ["width"] = 30, ["friendlyName"] = "Ping", ["priority"] = MAX_PRIRORITY_SLOT } } resourceColumns = {} function toboolean( bool ) bool = tostring( bool ) if bool == "true" then return true elseif bool == "false" then return false else return nil end end forceShowTeams = toboolean( get( "forceShowTeams" ) ) or false forceHideTeams = toboolean( get( "forceHideTeams" ) ) or false allowColorcodedNames = toboolean( get( "allowColorcodedNames" ) ) or false scrollStep = tonumber( get( "scrollStep" ) ) or 1 local function iif( cond, arg1, arg2 ) if cond then return arg1 end return arg2 end function scoreboardAddColumn( name, forElement, width, friendlyName, priority ) if type( name ) == "string" then width = tonumber( width ) or 70 friendlyName = friendlyName or name priority = tonumber( priority ) or getNextFreePrioritySlot( scoreboardGetColumnPriority( "name" ) ) fixPrioritySlot( priority ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then for key, value in ipairs( scoreboardColumns ) do if name == value.name then return false end end table.insert( scoreboardColumns, { ["name"] = name, ["width"] = width, ["friendlyName"] = friendlyName, ["priority"] = priority } ) table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end ) if sourceResource then if not resourceColumns[sourceResource] then resourceColumns[sourceResource] = {} end table.insert ( resourceColumns[sourceResource], name ) end return triggerClientEvent( getRootElement(), "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource ) end else return triggerClientEvent( forElement, "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource ) end end return false end function scoreboardRemoveColumn( name, forElement ) if type( name ) == "string" then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then for key, value in ipairs( scoreboardColumns ) do if name == value.name then table.remove( scoreboardColumns, key ) for resource, content in pairs( resourceColumns ) do table.removevalue( content, name ) end return triggerClientEvent( getRootElement(), "doScoreboardRemoveColumn", getRootElement(), name ) end end else return triggerClientEvent( forElement, "doScoreboardRemoveColumn", getRootElement(), name ) end end return false end function scoreboardClearColumns( forElement ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then while ( scoreboardColumns[1] ) do table.remove( scoreboardColumns, 1 ) resourceColumns = {} end return triggerClientEvent( getRootElement(), "doScoreboardClearColumns", getRootElement() ) else return triggerClientEvent( forElement, "doScoreboardClearColumns", getRootElement() ) end end function scoreboardResetColumns( forElement ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then while ( scoreboardColumns[1] ) do table.remove( scoreboardColumns, 1 ) resourceColumns = {} end local result = triggerClientEvent( getRootElement(), "doScoreboardResetColumns", getRootElement() ) if result then scoreboardAddColumn( "name", 200, "Name" ) scoreboardAddColumn( "ping", 40, "Ping" ) end return result else return triggerClientEvent( forElement, "doScoreboardResetColumns", getRootElement(), false ) end end function scoreboardSetForced( forced, forElement ) if type( forced ) == "boolean" then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) return triggerClientEvent( forElement, "doScoreboardSetForced", getRootElement(), forced ) else return false end end function scoreboardSetSortBy( name, desc, forElement ) if type( name ) == "string" or name == nil then if name == nil then forElement = iif( type( desc ) == "userdata" and isElement( desc ), desc, getRootElement() ) else forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) end desc = iif( type( desc ) == "boolean", desc, true ) return triggerClientEvent( forElement, "doScoreboardSetSortBy", getRootElement(), name, desc ) else return false end end function scoreboardGetColumnPriority( name ) if type( name ) == "string" then for key, value in ipairs( scoreboardColumns ) do if name == value.name then return value.priority end end end return false end function scoreboardSetColumnPriority( name, priority, forElement ) if type( name ) == "string" and type( priority ) == "number" then if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then local columnIndex = false for key, value in ipairs( scoreboardColumns ) do if name == value.name then columnIndex = key end end if columnIndex then scoreboardColumns[columnIndex].priority = -1 -- To empty out the current priority fixPrioritySlot( priority ) scoreboardColumns[columnIndex].priority = priority table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end ) return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority ) end else return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority ) end end end return false end function scoreboardForceTeamsVisible( enabled ) if type( enabled ) == "boolean" then forceShowTeams = enabled return true end return false end function scoreboardForceTeamsHidden( enabled ) if type( enabled ) == "boolean" then forceHideTeams = enabled return true end return false end function scoreboardGetColumnCount() return #scoreboardColumns end function onClientDXScoreboardResourceStart() for key, column in ipairs( scoreboardColumns ) do triggerClientEvent( client, "doScoreboardAddColumn", getRootElement(), column.name, column.width, column.friendlyName, column.priority ) end end addEvent( "onClientDXScoreboardResourceStart", true ) addEventHandler( "onClientDXScoreboardResourceStart", getResourceRootElement( getThisResource() ), onClientDXScoreboardResourceStart ) function requestServerInfoHandler() local mapmanager = getResourceFromName( "mapmanager" ) local output = {} output.forceshowteams = forceShowTeams output.forcehideteams = forceHideTeams output.allowcolorcodes = allowColorcodedNames output.scrollStep = scrollStep output.server = getServerName() output.players = getMaxPlayers() output.gamemode = false output.map = false if mapmanager and getResourceState( mapmanager ) == "running" then local gamemode = exports.mapmanager:getRunningGamemode() if gamemode then output.gamemode = getResourceInfo( gamemode, "name" ) or getResourceName( gamemode ) end local map = exports.mapmanager:getRunningGamemodeMap() if map then output.map = getResourceInfo( map, "name" ) or getResourceName( map ) end end triggerClientEvent( source, "sendServerInfo", getRootElement(), output ) end addEvent( "requestServerInfo", true ) addEventHandler( "requestServerInfo", getRootElement(), requestServerInfoHandler ) function removeResourceScoreboardColumns( resource ) if resourceColumns[resource] then while resourceColumns[resource][1] do local success = scoreboardRemoveColumn( resourceColumns[resource][1], getRootElement() ) if not success then break end end resourceColumns[resource] = nil end end addEventHandler( "onResourceStop", getRootElement(), removeResourceScoreboardColumns ) -- Compability addScoreboardColumn = function( name, forElement, position, size ) if type( size ) == "number" and size >= 0 and size <= 1.0 then size = size*700 end return scoreboardAddColumn( name, forElement, size, name, position ) end removeScoreboardColumn = scoreboardRemoveColumn resetScoreboardColumns = scoreboardResetColumns setPlayerScoreboardForced = function( forElement, forced ) return scoreboardSetForced( forced, forElement ) end --[[function onPlayerJoinToServer() if source then findIDForPlayer(source) local country = call(getResourceFromName("admin"),"getPlayerCountry",source) if country then setElementData(source,"country",country) else setElementData(source,"country","?") end end end addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoinToServer)]]-- function findIDForPlayer(thePlayer) if thePlayer and not getElementData(thePlayer,"ID") then local i = 0 local players = getElementsByType("player") repeat local foundID = false i = i + 1 for _,player in pairs(players) do if player ~= thePlayer then local playerID = tonumber(getElementData(player,"ID")) if playerID == i then foundID = true break end end end until not foundID setElementData(thePlayer,"ID",i) end end --[[function onServerIDStart() for i,thePlayer in pairs(getElementsByType("player")) do findIDForPlayer(thePlayer) local country = call(getResourceFromName("admin"),"getPlayerCountry",source) if country then setElementData(source,"country",country) else setElementData(source,"country","?") end end end addEventHandler("onResourceStart",resourceRoot,onServerIDStart) ]]---
  8. Pedro001

    Exporting to the scoreboard.

    dxscoreboard_exports.lua ? I don't get it.
  9. Pedro001

    Exporting to the scoreboard.

    It's a script for creating gangs, I wanted to show the rank of the player in the gang on the scorebord. the rank names are in the Ranknames file, which is this one clanRankNames = { [1] = "Aprendiz", [2] = "Membro", [3] = "Treinador", [4] = "Sub-Comandante", [5] = "Comandante", [6] = "Líder" } But instead of getting shown "Comandante" on the scoreboard, I get the number 5 shown. I wanted the rank name shown.
  10. Pedro001

    Exporting to the scoreboard.

    Server local clanDB = nil local clanTable = {} zp = 300000 function initDatabase() clanDB = dbConnect( "sqlite", "clans.db" ) dbExec(clanDB, "CREATE TABLE IF NOT EXISTS Clans (Name PRIMARY KEY, Color, Members, X, Y, Z, Cash)") end initDatabase() function fillClanTable() local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans"),-1) if result and type(result) == "table" then clanTable = {} for k,v in pairs(result) do v["Color"] = fromJSON(v["Color"]) v["Members"] = fromJSON(v["Members"]) for key,val in pairs(v["Members"]) do if val[2] == 6 then v["Leader"] = val[1] end end table.insert(clanTable,v) createTeam( v["Name"], unpack(v["Color"]) ) end end end fillClanTable() function createClan(name,r,g,b) local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Name = ?", name),-1) local resultt = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Members = ?", getAccountName(getPlayerAccount(source))),-1) if resultt and #resultt <= 0 then if result and #result <= 0 then if name and #name <= 15 then local accName = getAccountName(getPlayerAccount(source)) if r and g and b then if tonumber(getPlayerMoney(source, localPlayer)) >= 20000000 then setPlayerMoney(source, tonumber(getPlayerMoney(source, localPlayer)) - 20000000) local color = {tonumber(r),tonumber(g),tonumber(b)} dbExec(clanDB, "INSERT INTO Clans VALUES(?,?,?,?,?,?,?)",name,toJSON(color),toJSON({{accName,6}}),0,0,0,0) local team = createTeam(name,unpack(color)) setPlayerTeam(source,team) local oldName = getPlayerName(source) fillClanTable() setElementData(source,"faction", name) outputChatBox("#FF0000[GANG]: #FFFFFFVoce criou a facção #FF0000"..name.." #FFFFFFcom sucesso",source,255, 0, 0, true) else outputChatBox("#FF0000[GANG]: #FFFFFFParece que voce nao tem dinheiro o suficiente", source, 255, 0, 0, true) outputChatBox("#FF0000[GANG]: #FFFFFFPara poder criar uma você precisa de #00800030,000,000$", source, 255, 0, 0, true) return end end else outputChatBox("#ff0000[GANG] #ffffffO nome é muito longo!",source) end else outputChatBox("#ff0000[GANG]: #ffffffO facção já existe !",source) end end end addEvent( "createNewClan", true ) addEventHandler("createNewClan", root, createClan) function getFreeID() local result = dbPoll(dbQuery(clanDB, "SELECT ID FROM Clans ORDER BY ID ASC"), -1) newID = false for i, id in pairs (result) do if id["ID"] ~= i then newID = i break end end if newID then return newID else return #result + 1 end end function was () local faction, rank = getPlayerFaction(source) local data = getFactionData(faction) if faction and rank then if data["X"] ~= 0 or 0 and data["Y"] ~= 0 or 0 and data["Z"] ~= 0 or 20 then spawnPlayer(source,data["X"],data["Y"],data["Z"]+0.2) setTimer (spawnPlayer, 1000, 1, source, data["X"],data["Y"],data["Z"]+0.2, 0, getPedSkin (source), 0, 0, getPlayerTeam(source)) end end end addEventHandler("onPlayerWasted", getRootElement(), was) function initClanCreationWindow(ply) local accName = getAccountName ( getPlayerAccount ( ply ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Console" ) ) then triggerClientEvent( ply, "initClanCreationWindow", ply, clanTable ) end end addCommandHandler("gangs",initClanCreationWindow) function getPlayerFaction(ply) local accName = getAccountName ( getPlayerAccount ( ply ) ) for k,v in pairs(clanTable) do for key,val in pairs(v["Members"]) do if val[1] == accName then return v["Name"], val[2] end end end end function getFactionData(name) for k,v in pairs(clanTable) do if v["Name"] == name then return v end end end function setFactionOnLogin() local faction, rank = getPlayerFaction(source) local data = getFactionData(faction) if faction and rank then setElementData(source,"faction",faction) setElementData(source,"GangRank",rank) if getTeamFromName (faction) then setPlayerTeam(source,getTeamFromName (faction)) else local team = createTeam(faction,unpack(data["Color"])) setPlayerTeam(source,team) end local oldName = getPlayerName(source) local newName = "["..faction.."]"..oldName setPlayerName(source, newName ) if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then setElementPosition(source,data["X"],data["Y"],data["Z"]+0.2) end end end addEventHandler("onPlayerLogin",root,setFactionOnLogin) function setFactionOnStart() GangRank = clanRankNames[rank] exports.scoreboard:addScoreboardColumn("GangRank") for i, v in ipairs (getElementsByType ("player")) do local acc = getPlayerAccount (v) if not isGuestAccount (acc) then local faction, rank = getPlayerFaction(v) local data = getFactionData(faction) if faction and rank then setElementData(v,"faction",faction) setElementData(v,"GangRank",rank) if getTeamFromName (faction) then setPlayerTeam(v,getTeamFromName (faction)) else local team = createTeam(faction,unpack(data["Color"])) setPlayerTeam(v,team) end local oldName = getPlayerName(v) local newName = "["..faction.."]"..oldName setPlayerName(v, newName ) if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then setElementPosition(v,data["X"],data["Y"],data["Z"]+0.2) end end end end end addEventHandler("onResourceStart",resourceRoot,setFactionOnStart) function deleteClan(name) local clan = getFactionData(name) for k,v in pairs(clan["Members"]) do local acc = getAccount(v[1]) local ply = getAccountPlayer( acc ) if ply then removeElementData(ply,"faction") removeElementData(ply,"GangRank") setPlayerTeam(ply,nil) outputChatBox("#FF0000[GANG]: #FFFFFFSua gang #FF0000"..name.." #FFFFFFfoi excluida por um de nossos #FF0000ADMINISTRADORES", ply, 255, 0, 0, true) end end dbExec(clanDB, "DELETE FROM Clans WHERE Name = ?",name) fillClanTable() end addEvent( "deleteClan", true ) addEventHandler("deleteClan", root, deleteClan) function inviteToClan(ply) if not getElementData(ply,"faction") then if not isGuestAccount (getPlayerAccount (ply)) then local clan = getFactionData(getElementData(source,"faction")) triggerClientEvent(ply,"clanInvitation",source,clan) else outputChatBox("#ff0000[GANG]: #ffffffO jogador ainda não esta logado no servidor.",source, 255, 255, 255,true) end else outputChatBox("#32CD32[GANG]: #ffffffO jogador já está na facção.",source, 255, 0, 0) end end addEvent( "inviteToClan", true ) addEventHandler("inviteToClan", root, inviteToClan) function acceptInvite(clan) setElementData(source,"faction", clan["Name"]) setElementData(source,"GangRank", 1) setPlayerTeam(source,getTeamFromName (clan["Name"])) local newMembers = clan["Members"] local accName = getAccountName ( getPlayerAccount ( source ) ) table.insert(newMembers,{accName,1}) dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"]) fillClanTable() end addEvent( "acceptInvite", true ) addEventHandler("acceptInvite", root, acceptInvite) function kickFromClan(login) if getElementData(source,"GangRank") == 6 or getElementData(source,"GangRank") == 5 then local acc = getAccount( login ) local clan = getFactionData(getElementData(source,"faction")) local newMembers = clan["Members"] for k,v in pairs(clan["Members"]) do if v[1] == login and v[2] < 6 then table.remove(newMembers,k) else end end dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"]) local ply = getAccountPlayer( acc ) if ply then removeElementData(ply,"faction") removeElementData(ply,"GangRank") outputChatBox("#ff0000[GANG]: #ffffffVocê foi excluído da facção.",ply) end fillClanTable() end end addEvent( "kickFromClan", true ) addEventHandler("kickFromClan", root, kickFromClan) function leaveClan() local clan = getFactionData(getElementData(source,"faction")) local newMembers = clan["Members"] local login = getAccountName(getPlayerAccount(source)) for k,v in pairs(clan["Members"]) do if v[1] == login and v[2] < 10 then table.remove(newMembers,k) end end dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"]) removeElementData(source,"faction") removeElementData(source,"GangRank") setPlayerTeam(source,nil) fillClanTable() end addEvent( "leaveClan", true ) addEventHandler("leaveClan", root, leaveClan) function changeClanCash(state,count) local clan = getFactionData(getElementData(source,"faction")) if clan then if state == "take" then if clan["Cash"] >= count then outputChatBox("#ff0000[GANG]: #ffffffVocê retirou com sucesso "..count.." #32CD32reais #ffffffda conta da facção!",source,255,255,255,true) givePlayerMoney(source,count) dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",clan["Cash"]-count, clan["Name"]) fillClanTable() end elseif state == "give" then if getPlayerMoney(source) >= count then outputChatBox("#32CD32[GANG]: #ffffffVocê adicionou "..count.." #32CD32reias #ffffffpara sua facção!",source,255,255,255,true) takePlayerMoney(source,count) dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",clan["Cash"]+count, clan["Name"]) fillClanTable() end end end end addEvent( "changeClanCash", true ) addEventHandler("changeClanCash", root, changeClanCash) function changeClanSpawnPoint(state) local x,y,z = getElementPosition(source) local clan = getElementData(source,"faction") if state then dbExec(clanDB, "UPDATE Clans SET X = ?, Y = ?, Z = ? WHERE Name = ? ",x,y,z, clan) fillClanTable() else dbExec(clanDB, "UPDATE Clans SET X = ?, Y = ?, Z = ? WHERE Name = ? ",0,0,0, clan) fillClanTable() end end addEvent( "changeClanSpawnPoint", true ) addEventHandler("changeClanSpawnPoint", root, changeClanSpawnPoint) function setNewClanRank(login,rank) if getElementData(source,"GangRank") == 6 or getElementData(source,"GangRank") == 5 then local acc = getAccount( login ) local clan = getFactionData(getElementData(source,"faction")) local newMembers = clan["Members"] for k,v in pairs(clan["Members"]) do if v[1] == login then if v[2] < 6 then v[2] = rank else return end end end dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"]) local ply = getAccountPlayer( acc ) if ply then removeElementData(ply,"faction") removeElementData(ply,"GangRank") setPlayerTeam(ply,nil) outputChatBox("#32CD32[GANG]: #ffffffSua nova classificação: #32CD32"..rank,ply,255,255,255,true) end fillClanTable() end end addEvent( "setNewClanRank", true ) addEventHandler("setNewClanRank", root, setNewClanRank) function playerQuit() local team = getPlayerTeam(source) setPlayerTeam(source,nil) if team then local teamCount = getPlayersInTeam(team) outputServerLog( "CONTAGEM DE EQUIPE: "..#teamCount ) if #teamCount <= 1 then destroyElement(team) end end end addEventHandler("onPlayerQuit",root,playerQuit) setTimer(function() for _,v in pairs(getElementsByType ("pickup")) do data = getElementData(v,"teamZone") if data then local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Name = ?",data),-1) if result and #result ~= 0 then cash1 = result[1].Cash cash2 = tonumber(cash1 + zp) dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",cash2,data) fillClanTable() end end end end,3600000,0) Client local scx,scy = guiGetScreenSize() local px = scx/1920 local sizeX, sizeY = 400*px,600*px local posX,posY = 10*px,scy-sizeY-100*px local screen = dxCreateScreenSource( scx,scy ) local selectionsi_player_list_clan = 0 local presi_player_list_clan = false local scrollsi_player_list_clan = 0 local scrollMaxsi_player_list_clan = 0 local rtsi_player_list_clan = dxCreateRenderTarget( 280,160, true ) local clksi_player_list_clan = false local selectionsi_piglos = 0 local presi_piglos = false local scrollsi_piglos = 0 local scrollMaxsi_piglos = 0 local rtsi_piglos = dxCreateRenderTarget( 190,170, true ) local clksi_piglos = false local clanTable = nil local myClanTable = nil local creationWindow = nil local newClanWindow = nil local clanWindow = nil local font = guiCreateFont( "font.ttf", 32 ) local blipos = createBlip(2318.49194, 75.57992, 26.48438,60) setBlipVisibleDistance(blipos, 300) local marketbuy = createMarker(2318.49194, 75.57992, 25.48438, "cylinder", 1.5, 0, 255, 106, 50 ) function openNewClanWindows (element) if element == localPlayer then if stat_create_clan_mark == false then stat_create_clan_mark = true showCursor(true) addEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, true) guiSetInputMode("no_binds_when_editing", true) end end end addEventHandler( "onClientMarkerHit", marketbuy, openNewClanWindows ) function initClanCreationWindow(clans) if isElement(creationWindow) then showCursor(false) destroyElement(creationWindow) else clanTable = clans showCursor(true) creationWindow = guiCreateWindow(0.3,0.25,0.3,0.5,"Lista de Gangs - Servidor", true) local clanlist = guiCreateGridList(0.1,0.1,0.8,0.7,true,creationWindow) guiGridListAddColumn( clanlist, "Nome",0.5 ) guiGridListAddColumn( clanlist, "Lider",0.45 ) for k,v in pairs(clans) do local row = guiGridListAddRow(clanlist) guiGridListSetItemText(clanlist,row,1,v["Name"],false,false) guiGridListSetItemText(clanlist,row,2,v["Leader"],false,false) end local btnCreate = guiCreateButton(0.7,0.85,0.2,0.1,"Criar",true,creationWindow) local btnDelete = guiCreateButton(0.4,0.85,0.2,0.1,"Excluir",true,creationWindow) local btnClose = guiCreateButton(0.1,0.85,0.2,0.1,"Fechar",true,creationWindow) addEventHandler("onClientGUIClick",creationWindow,function() if source == btnCreate then initClanCreationWindow() if stat_create_clan_mark == false then stat_create_clan_mark = true showCursor(true) addEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, true) guiSetInputMode("no_binds_when_editing", true) else stat_create_clan_mark = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, false) guiSetInputMode("no_binds_when_editing", false) end elseif source == btnDelete then local clanName = guiGridListGetItemText( clanlist, guiGridListGetSelectedItem( clanlist ) ) triggerServerEvent( "deleteClan", localPlayer,clanName ) outputChatBox("#FF0000[GANG]: #FFFFFFVocê excluiu #FF0000"..clanName.." #FFFFFFcom sucesso", 255, 0, 0, true) initClanCreationWindow() elseif source == btnClose then initClanCreationWindow() end end) end end addEvent( "initClanCreationWindow", true ) addEventHandler("initClanCreationWindow", root, initClanCreationWindow) function isClanExists(name) for k,v in pairs(clanTable) do if v["Name"] == name then return true end end end function isRGB(str) local s = tonumber(str) if s and s >= 0 and s <= 255 then return true else return false end end stat_create_clan_mark = false name_clan = "Digite o nome da gang" scrolR_1 = scx / 2 + 127.5 ProcentR_1 = 1 visualPocentClan_1 = 0 scrolG_2 = scx / 2 + 127.5 ProcentG_2 = 1 visualPocentClan_2 = 0 scrolB_3 = scx / 2 + 127.5 ProcentB_3 = 1 visualPocentClan_3 = 0 edit = guiCreateEdit(scx / 2 - 145, scy / 2 - 15, 290, 20,name_clan,false) guiSetVisible(edit, false) function wnd_create_clan_mark () dxDrawWindow( scx / 2 - 150 , scy / 2 - 150, 300, 235, "Painel - Criar Gang") dxDrawScrollBarR(scx / 2 - 127.5, scy / 2 - 90, 255, 10, scrolR_1, "Vermelho "..math.floor(visualPocentClan_1 / 2.55).." %", ProcentR_1) dxDrawScrollBarG(scx / 2 - 127.5, scy / 2 - 65, 255, 10, scrolG_2, "Verde "..math.floor(visualPocentClan_2 / 2.55).." %", ProcentG_2) dxDrawScrollBarB(scx / 2 - 127.5, scy / 2 - 40, 255, 10, scrolB_3, "Azul "..math.floor(visualPocentClan_3 / 2.55).." %", ProcentB_3) dxDrawButtonText_pas(scx / 2 - 150, scy / 2 - 120, 300, 20, "Nome: "..name_clan, 1, 1) dxDrawButtonText(scx / 2 - 145, scy / 2 + 10, 290, 20, "Valor: 30 000 000$", 1, 1) dxDrawButton( scx / 2 - 145, scy / 2 + 35, 290, 20, "Criar") dxDrawButton( scx / 2 - 145, scy / 2 + 60, 290, 20, "Fechar") name_clan = guiGetText(edit) end addEventHandler( "onClientClick", root, function(button, state) if stat_create_clan_mark == true then if button == "left" and state == "down" then local x, y, w, h = scx / 2 - 127.5, scy / 2 - 90, 255, 10 if cursorPosition( scrolR_1, y-5, 10, h+10 ) then scrollMovingR_1 = true else if scrolR_1 <= x then if cursorPosition( x, y-5, 10, h+10 ) then scrollMovingR_1 = true end else if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then scrollMovingR_1 = true end end end elseif button == "left" and state == "up" then if scrollMovingR_1 then scrollMovingR_1 = false end end if button == "left" and state == "down" then local x, y, w, h = scx / 2 - 127.5, scy / 2 - 65, 255, 10 if cursorPosition( scrolG_2, y-5, 10, h+10 ) then scrollMovingG_2 = true else if scrolG_2 <= x then if cursorPosition( x, y-5, 10, h+10 ) then scrollMovingG_2 = true end else if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then scrollMovingG_2 = true end end end elseif button == "left" and state == "up" then if scrollMovingG_2 then scrollMovingG_2 = false end end if button == "left" and state == "down" then local x, y, w, h = scx / 2 - 127.5, scy / 2 - 40, 255, 10 if cursorPosition( scrolB_3, y-5, 10, h+10 ) then scrollMovingB_3 = true else if scrolB_3 <= x then if cursorPosition( x, y-5, 10, h+10 ) then scrollMovingB_3 = true end else if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then scrollMovingB_3 = true end end end elseif button == "left" and state == "up" then if scrollMovingB_3 then scrollMovingB_3 = false end end end end) addEventHandler( "onClientCursorMove", getRootElement( ), function ( _, _, xMove ) if scrollMovingR_1 then scrolR_1 = xMove end if scrollMovingG_2 then scrolG_2 = xMove end if scrollMovingB_3 then scrolB_3 = xMove end end) function click_clan_mark (button, state) if stat_create_clan_mark == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 145, scy / 2 - 15, 290, 20) then guiSetText(edit, "") end if cursorPosition(scx / 2 - 145, scy / 2 + 36, 290, 20) then if name_clan and #name_clan >= 2 and #name_clan <=15 then local Color_1 = getElementData(localPlayer, "ColorRclan") or 255 local Color_2 = getElementData(localPlayer, "ColorGclan") or 255 local Color_3 = getElementData(localPlayer, "ColorBclan") or 255 triggerServerEvent( "createNewClan", localPlayer, name_clan, Color_1, Color_2, Color_3 ) else outputChatBox("#FF0000[GANG]: #FFFFFFNome invalido. O comprimento mínimo do nome é de 2 caracteres, o máximo é de 15 caracteres..", 255, 0, 0, true) end stat_create_clan_mark = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, false) guiSetInputMode("no_binds_when_editing", false) end if cursorPosition(scx / 2 - 145, scy / 2 + 60, 290, 20) then stat_create_clan_mark = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, false) guiSetInputMode("no_binds_when_editing", false) end end end end addEventHandler("onClientClick", root, click_clan_mark) function open_wnd_clan_mark () if stat_create_clan_mark == false then stat_create_clan_mark = true showCursor(true) addEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, true) guiSetInputMode("no_binds_when_editing", true) else stat_create_clan_mark = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, false) guiSetInputMode("no_binds_when_editing", false) end end clans = "" memberName = nil stat_create_clan_upravlenie = false function wnd_create_clan_upravlenie () local rank = getElementData(localPlayer,"factionrank") dxDrawWindow( scx / 2 - 150 , scy / 2 - 155, 300, 330, "Gang : "..clans["Name"].." | Rank : "..clanRankNames[rank]) dxDrawRectangle(scx / 2 - 140,scy / 2 - 125,280,170,tocolor(0,0,0,200)) dxDrawButton( scx / 2 - 145, scy / 2 + 50, 290, 20, "Banir jogador da gang") dxDrawButton( scx / 2 - 145, scy / 2 + 75, 290, 20, "Alterar a classificação do jogador") dxDrawButton( scx / 2 - 145, scy / 2 + 100, 290, 20, "Convidar jogador para a gang") dxDrawButton( scx / 2 - 145, scy / 2 + 125, 142.5, 20, "Definir Spawn") dxDrawButton( scx / 2 + 2.5, scy / 2 + 125, 142.5, 20, "Remover Spawn") dxDrawButton( scx / 2 - 145, scy / 2 + 150, 142.5, 20, "Abandonar a gang") dxDrawButton( scx / 2 + 2.5, scy / 2 + 150, 142.5, 20, "$ Tesouro da gang $") local CRL = getElementData(localPlayer, "ColorR") or standartR local CGL = getElementData(localPlayer, "ColorG") or standartG local CBL = getElementData(localPlayer, "ColorB") or standartB dxUpdateScreenSource( screen ) dxSetRenderTarget( rtsi_player_list_clan,true ) if scrollsi_player_list_clan < 0 then scrollsi_player_list_clan = 0 elseif scrollsi_player_list_clan >= scrollMaxsi_player_list_clan then scrollsi_player_list_clan = scrollMaxsi_player_list_clan end local sy = 0 for k,v in pairs(clans["Members"]) do if k == selectionsi_player_list_clan then yes_cl_w = 280 yes_cl_x = 0 dxDrawRectangle(yes_cl_x,sy-scrollsi_player_list_clan,yes_cl_w,15,tocolor(CRL, CGL, CBL, 255)) else no_cl_w = 270 no_cl_x = 5 dxDrawRectangle(no_cl_x,sy-scrollsi_player_list_clan,no_cl_w,15,tocolor(200, 200, 200, 200)) end dxDrawText("Login : "..v[1],10,sy-scrollsi_player_list_clan - 10,490,sy-scrollsi_player_list_clan+26,tocolor(255,255,255),1,1,"default-bold","left","center") dxDrawText("Rank : "..clanRankNames[v[2]],155,sy-scrollsi_player_list_clan - 10,490,sy-scrollsi_player_list_clan+26,tocolor(255,255,255),1,1,"default-bold","left","center") sy = sy + 16 end dxSetRenderTarget() dxDrawImage( scx / 2 - 140,scy / 2 - 120,280,160,rtsi_player_list_clan) if sy >= 160 then scrollMaxsi_player_list_clan = sy-160 local size = 160/sy*160 end local spy = 0 for k,v in pairs(clans["Members"]) do if cursorPosition(scx / 2 - 140,scy / 2 - 120,280,170) then if cursorPosition( scx / 2 - 140,scy / 2 - 120+spy-scrollsi_player_list_clan,280,15) then if getKeyState("mouse1") and not clksi_player_list_clan then selectionsi_player_list_clan = k memberName = v[1] end end end spy = spy + 16 end if getKeyState("mouse1") then clksi_player_list_clan = true else clksi_player_list_clan = false end end stat_set_rank = false edit_rank = guiCreateEdit(scx / 2 - 80, scy / 2 - 205, 160, 20,"Nova classificação (1a5)",false) guiSetVisible(edit_rank, false) function set_rank () dxDrawWindow( scx / 2 - 85 , scy / 2 - 235, 170, 80, "Alterar Classificação") dxDrawButton( scx / 2 - 80, scy / 2 - 180, 160, 20, "Confirmar") end function click_clan_set_rank (button, state) if stat_set_rank == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 80, scy / 2 - 205, 160, 20) then guiSetText(edit_rank, "") end if cursorPosition(scx / 2 - 80, scy / 2 - 180, 160, 20) then if selectionsi_player_list_clan == 1 then outputChatBox("#ff0000[GANG]: #ffffffVocê não pode mudar a sua classificação.!",255,0,0,true) else local text = guiGetText(edit_rank) if tonumber(text) and tonumber(text) >= 1 and tonumber(text) <= 5 then local rank = tonumber(text) outputChatBox("#32cd32[GANG]: #ffffffVocê alterou com sucesso a classificação do jogador: #32CD32"..memberName.."#ffffff!",0,255,0,true) triggerServerEvent( "setNewClanRank", localPlayer, memberName, rank ) stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) else outputChatBox("Valor inválido.",255,0,0) end end end end end end addEventHandler("onClientClick", root, click_clan_set_rank) function click_clan_upravlenie (button, state) if stat_create_clan_upravlenie == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 145, scy / 2 + 50, 290, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 or rank == 5 then if memberName then if selectionsi_player_list_clan == 1 then outputChatBox("#FF0000[GANG]: #FFFFFFO lider da #FF0000[GANG] #FFFFFFnão pode ser banido", 255, 0, 0, true) else if cc == 5 then outputChatBox("#ff0000[GANG]: #ffffffVocê não pode se banir, você só pode deixar a facção!",255,255,255) else triggerServerEvent( "kickFromClan", localPlayer, memberName ) outputChatBox("#32cd32[GANG] #ffffffVocê excluiu com sucesso um jogador!",255,255,255,true) end end else outputChatBox("#ff0000[GANG]: #ffffffNenhum jogador selecionado!",255,255,255,true) end else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 - 145, scy / 2 + 75, 290, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 or rank == 5 then if memberName then if stat_exit == true then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end if stat_set_rank == false then stat_set_rank = true addEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, true) guiSetInputMode("no_binds_when_editing", true) else stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end else outputChatBox("#ff0000[GANG]: #ffffffNenhum jogador selecionado!",255,255,255,true) end else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 - 145, scy / 2 + 100, 290, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 or rank == 5 then if stat_exit == true then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == false then stat_piglos = true addEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 else stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 - 145, scy / 2 + 125, 142.5, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 then outputChatBox("#32cd32[GANG]: #ffffffVocê adicionou um ponto de renacimento para sua facção!!",255,255,255,true) triggerServerEvent("changeClanSpawnPoint",localPlayer,true) else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 + 2.5, scy / 2 + 125, 142.5, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 then triggerServerEvent("changeClanSpawnPoint",localPlayer,false) outputChatBox("#ff0000[GANG]: #ffffffVocê removeu o ponto de renacimento de sua facção!!",255,255,255,true) else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 + 2.5, scy / 2 + 150, 142.5, 20) then if stat_exit == true then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == false then stat_kazna = true addEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, true) guiSetInputMode("no_binds_when_editing", true) else stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end end if cursorPosition(scx / 2 - 145, scy / 2 + 150, 142.5, 20) then if stat_exit == false then stat_exit = true addEventHandler("onClientRender", root, wnd_exit) else stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end end end end end addEventHandler("onClientClick", root, click_clan_upravlenie) stat_exit = false function wnd_exit () dxDrawWindow( scx / 2 - 150 , scy / 2 - 235, 300, 80, "Pense bem antes de abandonar, nao tera volta.") dxDrawButtonText(scx / 2 - 150 , scy / 2 - 205, 300, 20, "Tem certeza que voce quer abandonar a gang?\n"..clans["Name"].." ??", 1, 1) dxDrawButton( scx / 2 - 145, scy / 2 - 180, 142.5, 20, "Sim, Abandonar") dxDrawButton( scx / 2 + 2.5, scy / 2 - 180, 142.5, 20, "Não, Fechar") end function click_clan_exit(button, state) if stat_exit == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 145, scy / 2 - 180, 142.5, 20) then triggerServerEvent( "leaveClan", localPlayer) stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) outputChatBox("Você deixou o clã com sucesso",0,255,0) stat_create_clan_upravlenie = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end end if cursorPosition(scx / 2 + 2.5, scy / 2 - 180, 142.5, 20) then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end end end end addEventHandler("onClientClick", root, click_clan_exit) stat_kazna = false edit_kazna = guiCreateEdit(scx / 2 - 100, scy / 2 - 205, 198.5, 20,"0",false) guiSetVisible(edit_kazna, false) function wnd_kazna () dxDrawWindow( scx / 2 - 102.5 , scy / 2 - 235, 205, 80, "Tesouro do clã : "..clans["Cash"]) dxDrawButton( scx / 2 - 98.5, scy / 2 - 180, 95, 20, "Colocar") dxDrawButton( scx / 2 + 2.5 , scy / 2 - 180, 95, 20, "Retirar") end function click_clan_kazna(button, state) if stat_kazna == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 100, scy / 2 - 205, 198.5, 20) then guiSetText(edit_kazna, "") end if cursorPosition(scx / 2 - 98.5, scy / 2 - 180, 95, 20) then local cashText = guiGetText(edit_kazna) if tonumber(cashText) and tonumber(cashText) <= getPlayerMoney(localPlayer) then if ( string.find ( tonumber(cashText), '-' ) ) then outputChatBox("Valor errado",255,0,0) else triggerServerEvent( "changeClanCash", localPlayer, "give", tonumber(cashText) ) stat_create_clan_upravlenie = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end end end end if cursorPosition(scx / 2 + 2.5 , scy / 2 - 180, 95, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 or rank == 5 then local cashText = guiGetText(edit_kazna) if tonumber(cashText) and tonumber(cashText) <= clans["Cash"] then if ( string.find ( tonumber(cashText), '-' ) ) then outputChatBox("Valor inválido",255,0,0) else triggerServerEvent( "changeClanCash", localPlayer, "take", tonumber(cashText) ) stat_create_clan_upravlenie = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end end else outputChatBox("#ff0000[GANG]: #ffffffQuantidade inválida!",255,255,255,true) end else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end end end end addEventHandler("onClientClick", root, click_clan_kazna) stat_piglos = false function wnd_rpiglos () dxDrawWindow( scx / 2 + 155 , scy / 2 - 155, 200, 235, "Lista de jogadores") dxDrawButton( scx / 2 + 160, scy / 2 + 55, 190, 20, "Convidar") dxDrawRectangle(scx / 2 + 160 , scy / 2 - 125,190,175,tocolor(0,0,0,200)) local CRL = getElementData(localPlayer, "ColorR") or standartR local CGL = getElementData(localPlayer, "ColorG") or standartG local CBL = getElementData(localPlayer, "ColorB") or standartB dxUpdateScreenSource( screen ) dxSetRenderTarget( rtsi_piglos,true ) if scrollsi_piglos < 0 then scrollsi_piglos = 0 elseif scrollsi_piglos >= scrollMaxsi_piglos then scrollsi_piglos = scrollMaxsi_piglos end local sy = 0 for k,player in pairs(getElementsByType("player")) do if not getElementData(player,"faction") then if k == selectionsi_piglos then yes_cl_w = 190 yes_cl_x = 0 dxDrawRectangle(yes_cl_x,sy-scrollsi_piglos,yes_cl_w,15,tocolor(CRL, CGL, CBL, 255)) else no_cl_w = 180 no_cl_x = 5 dxDrawRectangle(no_cl_x,sy-scrollsi_piglos,no_cl_w,15,tocolor(200, 200, 200, 200)) end local nick = getPlayerName(player) dxDrawText(string.gsub( nick, "#%x%x%x%x%x%x", "", 1 ),0,sy-scrollsi_piglos - 10,190,sy-scrollsi_piglos+26,tocolor(255,255,255),1,1,"default-bold","center","center") sy = sy + 16 end end dxSetRenderTarget() dxDrawImage(scx / 2 + 160, scy / 2 - 120,190,170,rtsi_piglos) if sy >= 170 then scrollMaxsi_piglos = sy-170 local size = 170/sy*170 end local spy = 0 for k,player in pairs(getElementsByType("player")) do if not getElementData(player,"faction") then if cursorPosition(scx / 2 + 160, scy / 2 - 120,190,170) then if cursorPosition(scx / 2 + 160, scy / 2 - 120+spy-scrollsi_piglos,190,15) then if getKeyState("mouse1") and not clksi_piglos then if k == 1 then outputChatBox("você não pode se convidar") else selectionsi_piglos = k igrok = player end end end end spy = spy + 16 end end if getKeyState("mouse1") then clksi_piglos = true else clksi_piglos = false end end function click_clan_invite (button, state) if stat_piglos == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 + 160, scy / 2 + 55, 190, 20) then if selectionsi_piglos == 0 then outputChatBox("Você não selecionou um jogador",255,0,0) else triggerServerEvent( "inviteToClan", localPlayer, igrok ) outputChatBox("Convite para o jogador enviado com sucesso",0,255,0) selectionsi_piglos = 0 end end end end end addEventHandler("onClientClick", root, click_clan_invite) addEventHandler("onClientKey",root,function(key,presi_piglos) if presi_piglos then if not stat_piglos then return end if key == "mouse_wheel_down" then scrollsi_piglos = scrollsi_piglos + 12 elseif key == "mouse_wheel_up" then scrollsi_piglos = scrollsi_piglos - 12 end end end) addEventHandler("onClientKey",root,function(key,presi_player_list_clan) if presi_player_list_clan then if not stat_create_clan_upravlenie then return end if key == "mouse_wheel_down" then scrollsi_player_list_clan = scrollsi_player_list_clan + 12 elseif key == "mouse_wheel_up" then scrollsi_player_list_clan = scrollsi_player_list_clan - 12 end end end) function open_wnd_clan_upravlenie (clan) clans = clan if stat_create_clan_upravlenie == false then stat_create_clan_upravlenie = true showCursor(true) addEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 else stat_create_clan_upravlenie = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end if stat_exit == true then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end end end addEvent( "openClanWindow", true ) addEventHandler("openClanWindow", root, open_wnd_clan_upravlenie) function bindd_wnd_clan_upravlenie () if not getElementData(localPlayer,"faction") then outputChatBox("#FF0000[ACESSO-NEGAGO]: #FFFFFFPara acessar esse painel, voce precisa estar em uma #FF0000[GANG]", 255, 0, 0, true) else triggerServerEvent("openClanWindowS", localPlayer) end end bindKey("F7","down",bindd_wnd_clan_upravlenie) local inviteWindow = nil function clanInvitation(clan) if not isElement(inviteWindow) then inviteWindow = guiCreateWindow(0.35,0.4,0.25,0.1,"Convite para gang",true,inviteWindow) local btnClose = guiCreateButton(0.1,0.6,0.3,0.3,"Negar",true,inviteWindow) local btnAccept = guiCreateButton(0.6,0.6,0.3,0.3,"Aceitar",true,inviteWindow) addEventHandler("onClientGUIClick",inviteWindow,function() if source == btnClose then showCursor(false) destroyElement(inviteWindow) elseif source == btnAccept then showCursor(false) destroyElement(inviteWindow) triggerServerEvent( "acceptInvite", localPlayer, clan ) end end) local label = guiCreateLabel(0,0.3,1,0.2,"Você quer se juntar a gang "..clan["Name"],true,inviteWindow) guiLabelSetHorizontalAlign( label, "center" ) end end addEvent( "clanInvitation", true ) addEventHandler("clanInvitation", root, clanInvitation) Ranknames clanRankNames = { [1] = "Aprendiz", [2] = "Membro", [3] = "Treinador", [4] = "Sub-Comandante", [5] = "Comandante", [6] = "Líder" } please, help me out
  11. Pedro001

    Exporting to the scoreboard.

    Please! Someone help me with this!
  12. Pedro001

    Exporting to the scoreboard.

    Hi guys, I'm trying to export the info of this function here clanRankNames = { [1] = "Aprendiz", [2] = "Membro", [3] = "Treinador", [4] = "Sub-Comandante", [5] = "Comandante", [6] = "Líder" } into the scoreboard using this GangRank = clanRankNames[rank] exports.scoreboard:addScoreboardColumn("GangRank") but instead of getting the text in the quotes, i'm getting the number in brackets. How can I get the text in the scoreboard?
  13. Pedro001

    Check ACL on driver seat.

    Wow! That was fast! hehe, Thank you very much my friend!! ❣️
  14. Pedro001

    Check ACL on driver seat.

    Hey guys, how can I check if someone in an ACL is the one trying to get in the driver's seat. so only him could drive this car, but other could seat on the other seats of the vehicle?
  15. Please, Could someone help me find out why can't players buy the properties in this script? I mean, part of it works just fine, I can create the properties, and everything is ok, but the other players on the server, can't buy the properties, because the windows won't pop up for them when they press the letter N. I went through the script and I can't figure out why this happens. core.client.lua local screen_width, screen_height = GuiElement.getScreenSize(); local is_cursor_over_gui = false; local action; local settings = {}; GuiElement.setInputMode("no_binds_when_editing"); addEvent("business.showCreateBusinessWindow", true); addEventHandler("business.showCreateBusinessWindow", root, function() gui.cb.window.visible = true; showCursor(true); end ); function outputMessage(message, r, g, b) triggerServerEvent("business.outputMessage", localPlayer, message, r, g, b); end addEventHandler("onClientRender", root, function() for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); local x, y, z = b_marker.position.x, b_marker.position.y, b_marker.position.z; local cam_x, cam_y, cam_z = getCameraMatrix(); if getDistanceBetweenPoints3D(cam_x, cam_y, cam_z, x, y, z) < 15 then local screen_x, screen_y = getScreenFromWorldPosition(x, y, z + 1.6); if screen_x then local scale = 1920 / screen_width; local width = 80 / scale; dxDrawImage(screen_x - width / 2, screen_y - screen_height / 10, width, 80, "files/business.png"); end if settings.show_business_info_on_marker then screen_x, screen_y = getScreenFromWorldPosition(x, y, z + 1.4); if screen_x then if #tostring(id) == 1 then id = "0"..tostring(id) end dxDrawFramedText("ID: #"..id, screen_x, screen_y, screen_x, screen_y, tocolor(255, 255, 255, 255), 1.0, "default-bold", "center", "center", false, false, false); end screen_x, screen_y = getScreenFromWorldPosition(x, y, z + 1.2); if screen_x then dxDrawFramedText("Nome: "..name, screen_x, screen_y, screen_x, screen_y, tocolor(255, 255, 255, 255), 1.0, "default-bold", "center", "center", false, false, false); end screen_x, screen_y = getScreenFromWorldPosition(x, y, z + 1.0); if screen_x then dxDrawFramedText("Dono: "..owner, screen_x, screen_y, screen_x, screen_y, tocolor(255, 255, 255, 255), 1.0, "default-bold", "center", "center", false, false, false); end screen_x, screen_y = getScreenFromWorldPosition(x, y, z + 0.8); if screen_x then dxDrawFramedText("Custo: $"..cost, screen_x, screen_y, screen_x, screen_y, tocolor(255, 255, 255, 255), 1.0, "default-bold", "center", "center", false, false, false); end screen_x, screen_y = getScreenFromWorldPosition(x, y, z + 0.6); if screen_x then dxDrawFramedText("Pagamento: $"..payout, screen_x, screen_y, screen_x, screen_y, tocolor(255, 255, 255, 255), 1.0, "default-bold", "center", "center", false, false, false); end screen_x, screen_y = getScreenFromWorldPosition(x, y, z + 0.4); if screen_x then dxDrawFramedText("Tempo de Pagamento: "..payout_otime.." "..payout_unit, screen_x, screen_y, screen_x, screen_y, tocolor(255, 255, 255, 255), 1.0, "default-bold", "center", "center", false, false, false); end screen_x, screen_y = getScreenFromWorldPosition(x, y, z + 0.2); if screen_x then dxDrawFramedText("Banco: $"..bank, screen_x, screen_y, screen_x, screen_y, tocolor(255, 255, 255, 255), 1.0, "default-bold", "center", "center", false, false, false); end end end end end ); addEvent("business.showInstructions", true); addEventHandler("business.showInstructions", root, function() addEventHandler("onClientRender", root, showInstructions); end ); function showInstructions() if settings.key then dxDrawText("Use",(screen_width / 1400) * 550,(screen_height / 900) * 450,(screen_width / 1440) * 100,(screen_height / 900) * 100, tocolor(255, 255, 255, 255),(screen_width / 1440) * 2.0); dxDrawText(settings.key:upper(),(screen_width / 1440) * 615,(screen_height / 900) * 450,(screen_width / 1440) * 100,(screen_height / 900) * 100, tocolor(255, 0, 0, 255),(screen_width / 1440) * 2.0); dxDrawText(" Para abrir o Negocio",(screen_width / 1440) * 630,(screen_height / 900) * 450,(screen_width / 1440) * 100,(screen_height / 900) * 100, tocolor(255, 255, 255, 255),(screen_width / 1440) * 2.0); end end addEvent("business.hideInstructions", true); addEventHandler("business.hideInstructions", root, function() removeEventHandler("onClientRender", root, showInstructions); end ); addEvent("business.showBusinessWindow", true); addEventHandler("business.showBusinessWindow", root, function(b_marker, is_owner, is_admin) local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); local x, y, z = b_marker.position; if #tostring(id) == 1 then id = "0"..tostring(id) end gui.b.window.text = name; gui.b.label.id.text = "ID: #"..id; gui.b.label.name.text = "Nome: "..name; gui.b.label.owner.text = "Dono: "..owner; gui.b.label.cost.text = "Custo: $"..cost; gui.b.label.payout.text = "Pagamento: $"..payout; gui.b.label.payout_time.text = "Tempo de Pagamento: "..payout_otime.." "..payout_unit; gui.b.label.location.text = "Localização: "..getZoneName(x, y, z, false).."("..getZoneName(x, y, z, true)..")"; gui.b.label.bank.text = "Banco: $"..bank; if is_admin and is_owner then gui.b.tab.action.enabled = true; gui.b.button.sell.enabled = true; gui.b.button.deposit.enabled = true; gui.b.button.withdraw.enabled = true; gui.b.button.set_name.enabled = true; gui.b.button.set_owner.enabled = true; gui.b.button.set_cost.enabled = true; gui.b.button.set_bank.enabled = true; gui.b.button.buy.enabled = false; elseif is_admin and not is_owner and owner ~= "For Sale" then gui.b.tab.action.enabled = true; gui.b.button.set_name.enabled = true; gui.b.button.set_owner.enabled = true; gui.b.button.set_cost.enabled = true; gui.b.button.set_bank.enabled = true; gui.b.button.sell.enabled = true; gui.b.button.buy.enabled = false; gui.b.button.deposit.enabled = false; gui.b.button.withdraw.enabled = false; elseif is_admin and not is_owner and owner == "For Sale" then gui.b.tab.action.enabled = true; gui.b.button.set_name.enabled = true; gui.b.button.set_owner.enabled = true; gui.b.button.set_cost.enabled = true; gui.b.button.set_bank.enabled = true; gui.b.button.sell.enabled = false; gui.b.button.buy.enabled = true; gui.b.button.deposit.enabled = false; gui.b.button.withdraw.enabled = false; elseif not is_admin and is_owner then gui.b.tab.action.enabled = true; gui.b.button.set_name.enabled = false; gui.b.button.set_owner.enabled = false; gui.b.button.set_cost.enabled = false; gui.b.button.set_bank.enabled = false; gui.b.button.sell.enabled = true; gui.b.button.deposit.enabled = true; gui.b.button.withdraw.enabled = true; gui.b.button.buy.enabled = false; elseif not is_admin and not is_owner and owner ~= "For Sale" then gui.b.tab.action.enabled = false; gui.b.tab_panel:setSelectedTab(gui.b.tab.info); elseif not is_admin and not is_owner and owner == "For Sale" then gui.b.tab.action.enabled = true; gui.b.button.set_name.enabled = false; gui.b.button.set_owner.enabled = false; gui.b.button.set_cost.enabled = false; gui.b.button.set_bank.enabled = false; gui.b.button.accept.enabled = false; gui.b.button.sell.enabled = false; gui.b.button.deposit.enabled = false; gui.b.button.withdraw.enabled = false; gui.b.button.buy.enabled = true; end gui.b.window.visible = true; showCursor(true); removeEventHandler("onClientRender", root, showInstructions) end ); addEventHandler("onClientResourceStart", resourceRoot, function() triggerServerEvent("business.getSettings", localPlayer); end ); addEvent("business.getSettings", true); addEventHandler("business.getSettings", root, function(_settings) settings = _settings; end ); core.server.lua local _settings = get(""); local settings = {}; for k, v in pairs(_settings) do k = split(k, ".")[2]; settings[k] = v; end if (settings.key:len() < 1 or settings.key:len() > 1) then settings.key = "N"; end if (not settings.blip or tonumber(settings.blip) == nil) then settings.blip = false; end addEventHandler("onResourceStart", resourceRoot, function() if (settings.database == "mysql") then local host, db, username, password, port, socket = unpack(settings.database_data); if not (host and db and username and password) then outputDebugString("Business: Failed to connect to the MySQL server - The data is invalid"); return; end if (tonumber(port)) then port = "port="..port..";"; else port = ""; end if (socket and socket ~= "") then socket = "socket="..socket..";"; else socket = ""; end database = Connection("mysql", "host="..host..";dbname="..db..";"..port..socket, username, password); if (not database) then outputDebugString("Business: Failed to connect to the MySQL server"); return; end else database = Connection("sqlite", "files/business.db"); if (not database) then outputDebugString("Business: Failed to connect to the SQLite file"); return; end end database:exec("CREATE TABLE IF NOT EXISTS business(id INT, name TEXT, owner TEXT, cost INT, pos TEXT, payout INT, payout_time INT, payout_otime INT, payout_unit TEXT, payout_cur_time INT, bank INT)"); database:query(dbCreateBusinessesCallback, "SELECT * FROM business"); end); function dbCreateBusinessesCallback(query_handle) local sql = query_handle:poll(0); if (sql and #sql > 0) then for index, row in ipairs(sql) do local pos = split(row["pos"], ","); local b_marker = Marker(pos[1], pos[2], pos[3], "cylinder", 1.5, settings.marker_color[1], settings.marker_color[2], settings.marker_color[3], settings.marker_color[4]); b_marker.interior = pos[4]; b_marker.dimension = pos[5]; if (settings.blip ~= false) then if (row["owner"] == "For Sale") then local b_blip = Blip.createAttachedTo(b_marker, settings.blip, 2, 255, 0, 0, 255, 0, 100.0); b_blip.interior = pos[4]; b_blip.dimension = pos[5]; else local b_blip = Blip.createAttachedTo(b_marker, settings.blip, 2, 255, 0, 0, 255, 0, 100.0); b_blip.interior = pos[4]; b_blip.dimension = pos[5]; end end addEventHandler("onMarkerHit", b_marker, onBusinessMarkerHit); addEventHandler("onMarkerLeave", b_marker, onBusinessMarkerLeave); local timer = Timer(businessPayout, row["payout_cur_time"] , 1, b_marker); b_marker:setData("b_data", {row["id"], row["name"], row["owner"], row["cost"], row["payout"], row["payout_time"], row["payout_otime"], row["payout_unit"], row["bank"], timer}); end end end addCommandHandler("negocios", function(player) if (ACL.hasObjectPermissionTo(player, "function.banPlayer")) then triggerClientEvent(player, "business.showCreateBusinessWindow", player); else player:outputMessage("Negocios: Voce nao tem acesso a este comando.", 255, 0, 0); end end); function Player:outputMessage(message, r, g, b) if (settings.info_messages_type == "dx") then dxOutputMessage(message, self, r, g, b); else self:outputChat(message, r, g, b, true); end end function outputMessage(message, player, r, g, b) if (settings.info_messages_type == "dx") then dxOutputMessage(message, player, r, g, b); else player:outputChat(message, r, g, b, true); end end function dxOutputMessage(message, player, r, g, b) triggerClientEvent(player, "business.dxOutputMessage", player, message, r, g, b); end addEvent("business.outputMessage", true); addEventHandler("business.outputMessage", root, function(message, r, g, b) source:outputMessage(message, r, g, b); end); addEvent("business.createBusiness", true); addEventHandler("business.createBusiness", root, function(x, y, z, interior, dimension, name, cost, payout, payout_time, payout_unit) database:query(dbCreateBusinessCallback, {client, x, y, z, interior, dimension, name, cost, payout, payout_time, payout_unit}, "SELECT * FROM business"); end); function dbCreateBusinessCallback(query_handle, client, x, y, z, interior, dimension, name, cost, payout, payout_time, payout_unit) local sql = query_handle:poll(0); if (sql) then local id; if (#sql > 0) then id = sql[#sql]["id"] + 1; else id = 1; end local unit; if (payout_unit == "Segundos") then unit = 1000; elseif (payout_unit == "Minutos") then unit = 60000; elseif (payout_unit == "Horas") then unit = 3600000; elseif (payout_unit == "Dias") then unit = 86400000; end x = tonumber(x); y = tonumber(y); z = tonumber(z); interior = tonumber(interior); dimension = tonumber(dimension); cost = tonumber(cost); payout = tonumber(payout); payout_time = tonumber(payout_time); z = z - 1; database:exec("INSERT INTO business(id,name,owner,cost,pos,payout,payout_time,payout_otime,payout_unit,payout_cur_time,bank) VALUES(?,?,?,?,?,?,?,?,?,?,?)", id, name, "For Sale", cost, x..","..y..","..z..","..interior..","..dimension, payout, payout_time * unit, payout_time, payout_unit, payout_time * unit, 0); local b_marker = Marker(x, y, z, "cylinder", 1.5, settings.marker_color[1], settings.marker_color[2], settings.marker_color[3], settings.marker_color[4]); b_marker.interior = interior; b_marker.dimension = dimension; if (settings.blip ~= false) then local b_blip = Blip.createAttachedTo(b_marker, settings.blip, 2, 255, 0, 0, 255, 0, 100.0); b_blip.interior = interior; b_blip.dimension = dimension; end local timer = Timer(businessPayout, payout_time * unit , 1, b_marker); b_marker:setData("b_data", {id, name, "For Sale", cost, payout, payout_time * unit, payout_time, payout_unit, 0, timer}); addEventHandler("onMarkerHit", b_marker, onBusinessMarkerHit); addEventHandler("onMarkerLeave", b_marker, onBusinessMarkerLeave); if (#tostring(id) == 1) then id = "0".. tostring(id) end client:outputMessage("Negocios: Negocio(ID #"..id..") foi criado com sucesso", 0, 255, 0); end end function onBusinessMarkerHit(hElement, mDim) if (hElement:getType() ~= "player") then return; end if (hElement:isInVehicle()) then return; end if (not mDim) then return; end triggerClientEvent(hElement, "business.showInstructions", hElement); end function onBusinessMarkerLeave(hElement, mDim) if (hElement:getType() ~= "player") then return; end if (hElement:isInVehicle()) then return; end if (not mDim) then return; end triggerClientEvent(hElement, "business.hideInstructions", hElement); end function businessPayout(b_marker) local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (owner ~= "For Sale") then bank = bank + payout; database:exec("UPDATE business SET bank = ? WHERE id = ?", bank, id); if (settings.inform_player_of_payout) then local account = Account(owner); if (account) then local player = account:getPlayer(); if (player and player.isElement) then player:outputMessage("Negocios: Negocio \" "..name.." \" pagou($"..payout..")", 0, 255, 0); end end end end timer = Timer(businessPayout, payout_time, 1, b_marker); b_marker:setData("b_data", {id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); end addEventHandler("onResourceStop", resourceRoot, function() for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (timer and timer:isValid()) then local left = timer:getDetails(); if (left >= 50) then database:exec("UPDATE business SET payout_cur_time = ? WHERE id = ?", left, id); else database:exec("UPDATE business SET payout_cur_time = ? WHERE id = ?", payout_time, id); end end end end); function Ped:isInMarker(marker) local colshape = marker.colShape; return self:isWithinColShape(colshape); end addEventHandler("onResourceStart", resourceRoot, function() for index, player in ipairs(Element.getAllByType("player")) do bindKey(player, settings.key, "up", onPlayerAttemptToOpenBusiness); end end); addEventHandler("onPlayerJoin", root,function() bindKey(source, settings.key, "up", onPlayerAttemptToOpenBusiness); end); function onPlayerAttemptToOpenBusiness(player) for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do if (player:isInMarker(b_marker)) then local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); triggerClientEvent(player, "business.showBusinessWindow", player, b_marker, getAccountName(getPlayerAccount(player)) == owner, ACL.hasObjectPermissionTo(player, "function.banPlayer")); break; end end end function Ped:getMarker() for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do if (self:isInMarker(b_marker)) then return b_marker; end end end addEvent("business.buy", true); addEventHandler("business.buy", root, function() local account = client.account; if (not account or account:isGuest()) then client:outputMessage("Business: You are not logged in", 255, 0, 0) return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (owner ~= "For Sale") then client:outputMessage("Business: This business is owned", 255, 0, 0); return; end database:query(dbBuyBusinessCallback, {client, b_marker, id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}, "SELECT * FROM business WHERE owner = ?", account.name); end); addEvent("business.sell", true); addEventHandler("business.sell", root, function() local account = client.account; if (not account or account:isGuest()) then return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (owner ~= account.name) then if (ACL.hasObjectPermissionTo(client, "function.banPlayer")) then database:exec("UPDATE business SET owner = ? WHERE id = ?", "For Sale", id); b_marker:setData("b_data", {id, name, "For Sale", cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); client:outputMessage("Negocios: Voce vendeu o Negocio com Sucesso", 0, 255, 0); return; else client:outputMessage("Negocios: Voce nao e proprietario deste Negocio", 255, 0, 0); return; end end database:exec("UPDATE business SET owner = ?, bank = ? WHERE id = ?", "For Sale", 0, id); client:giveMoney(tonumber(("%.f"):format(cost / 2))); client:giveMoney(bank); b_marker:setData("b_data", {id, name, "For Sale", cost, payout, payout_time, payout_otime, payout_unit, 0}); client:outputMessage("Negocios: Voce vendeu o Negocio com Sucesso, todo o dinheiro no banco foi pago para você.", 0, 255, 0); end); addEvent("business.deposit", true); addEventHandler("business.deposit", root, function(amount) local account = client.account; if (not account or account:isGuest()) then return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (not tonumber(amount)) then client:outputMessage("Negocios: Quantidade invalida", 255, 0, 0); return; end if (owner ~= account.name) then client:outputMessage("Negocios: Você não é o proprietário deste Negocio", 255, 0, 0); return; end if (client.money < amount) then client:outputMessage("Negocios: Você não tem dinheiro suficiente", 255, 0, 0); return; end database:exec("UPDATE business SET bank = ? WHERE id = ?", bank + amount, id); client:takeMoney(amount); b_marker:setData("b_data", {id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank + amount, timer}); client:outputMessage("Negocios: Você depositou com sucesso $"..amount.." no negócio", 0, 255, 0); end); addEvent("business.withdraw", true); addEventHandler("business.withdraw", root, function(amount) local account = client.account; if (not account or account:isGuest()) then return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (not tonumber(amount)) then client:outputMessage("Negocios: Quantidade Invalida", 255, 0, 0); return; end if (owner ~= account.name) then client:outputMessage("Negocios: Voce nao e o dono do negocio", 255, 0, 0); return; end if (bank < amount) then client:outputMessage("Negocios: Voce nao tem muito no Banco de Negocios", 255, 0, 0); return; end database:exec("UPDATE business SET bank = ? WHERE id = ?", bank - amount, id); client:giveMoney(amount); b_marker:setData("b_data", {id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank - amount, timer}); client:outputMessage("Negocios: Voce retirou com sucesso $"..amount.." do Negocio", 0, 255, 0); end); addEvent("business.setName", true); addEventHandler("business.setName", root, function(new_name) if (new_name == "" or #new_name > 30) then client:outputMessage("Negocios: Valor Invalido", 255, 0, 0); return; end if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); database:exec("UPDATE business SET name = ? WHERE id = ?", new_name, id); b_marker:setData("b_data", {id, new_name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); client:outputMessage("Negocios: Voce renomeou com sucesso o negocio", 0, 255, 0); end); addEvent("business.setOwner", true); addEventHandler("business.setOwner", root, function(new_owner) if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); database:exec("UPDATE business SET owner = ? WHERE id = ?", new_owner, id); b_marker:setData("b_data", {id, name, new_owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); client:outputMessage("Negocios: Voce mudou com sucesso o proprietario da empresa", 0, 255, 0); end); addEvent("business.setCost", true); addEventHandler("business.setCost", root, function(amount) if (tonumber(amount) == nil) then client:outputMessage("Negocios: Valor Invalido", 255, 0, 0); return; end amount = tonumber(amount); if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); database:exec("UPDATE business SET cost = ? WHERE id = ?", amount, id); b_marker:setData("b_data", {id, name, owner, amount, payout, payout_time, payout_otime, payout_unit, bank, timer}); client:outputMessage("Negocios: Voce mudou com sucesso o custo do negocio", 0, 255, 0); end); addEvent("business.setBank", true); addEventHandler("business.setBank", root, function(amount) if (tonumber(amount) == nil) then client:outputMessage("Negocios: Valor Invalido", 255, 0, 0); return; end amount = tonumber(amount); if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); database:exec("UPDATE business SET bank = ? WHERE id = ?", amount, id); b_marker:setData("b_data", {id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, amount, timer}); client:outputMessage("Negocios: Voce mudou com sucesso a quantidade de banco comercial", 0, 255, 0); end); addEvent("business.destroy", true); addEventHandler("business.destroy", root, function() if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (timer and timer:isValid()) then timer:destroy() end database:exec("DELETE FROM business WHERE id = ?", id); b_marker:destroyAttachedBlips(); b_marker:destroy(); client:outputMessage("Negocios: Voce destruiu com sucesso o negocio", 0, 255, 0); triggerClientEvent(client, "business.hideInstructions", client); database:query(dbReOrderBusinessesCallback, "SELECT * FROM business"); end); function dbBuyBusinessCallback(query_handle, source, b_marker, id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer) local sql = query_handle:poll(0); if (#sql == settings.owned_businesses) then source:outputMessage("Negocios: Voce ja possui "..#sql.." negocios , que e o valor maximo", 255, 0, 0); return; end local money = source.money; if (money < cost) then source:outputMessage("Negocios: Voce nao tem dinheiro suficiente", 255, 0, 0) return end database:exec("UPDATE business SET owner = ? WHERE id = ?", source.account.name, id); source:takeMoney(cost); source:outputMessage("Negocios: Voce comprou com sucesso neste negocio", 0, 255, 0); b_marker:setData("b_data", {id, name, source.account.name, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); end function dbReOrderBusinessesCallback(query_handle) local sql = query_handle:poll(0); if (sql and #sql > 0) then for index, row in ipairs(sql) do database:exec("UPDATE business SET id = ? WHERE id = ?", index, row["id"]); end for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do database:query(dbUpdateBusinessesIDsCallback, {b_marker, index}, "SELECT id FROM business WHERE id = ?", index); end end end function dbUpdateBusinessesIDsCallback(query_handle, b_marker, index) local sql = query_handle:poll(0); local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); b_marker:setData("b_data", {index, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); end function Element:destroyAttachedBlips() if (not self) then return; end for index, element in pairs(self:getAttachedElements()) do if (element and element.isElement) then element:destroy(); end end end addEvent("business.getSettings", true); addEventHandler("business.getSettings", root, function() triggerClientEvent(source, "business.getSettings", source, settings); end); dxoutput.client local _settings = get(""); local settings = {}; for k, v in pairs(_settings) do k = split(k, ".")[2]; settings[k] = v; end if (settings.key:len() < 1 or settings.key:len() > 1) then settings.key = "N"; end if (not settings.blip or tonumber(settings.blip) == nil) then settings.blip = false; end addEventHandler("onResourceStart", resourceRoot, function() if (settings.database == "mysql") then local host, db, username, password, port, socket = unpack(settings.database_data); if not (host and db and username and password) then outputDebugString("Business: Failed to connect to the MySQL server - The data is invalid"); return; end if (tonumber(port)) then port = "port="..port..";"; else port = ""; end if (socket and socket ~= "") then socket = "socket="..socket..";"; else socket = ""; end database = Connection("mysql", "host="..host..";dbname="..db..";"..port..socket, username, password); if (not database) then outputDebugString("Business: Failed to connect to the MySQL server"); return; end else database = Connection("sqlite", "files/business.db"); if (not database) then outputDebugString("Business: Failed to connect to the SQLite file"); return; end end database:exec("CREATE TABLE IF NOT EXISTS business(id INT, name TEXT, owner TEXT, cost INT, pos TEXT, payout INT, payout_time INT, payout_otime INT, payout_unit TEXT, payout_cur_time INT, bank INT)"); database:query(dbCreateBusinessesCallback, "SELECT * FROM business"); end); function dbCreateBusinessesCallback(query_handle) local sql = query_handle:poll(0); if (sql and #sql > 0) then for index, row in ipairs(sql) do local pos = split(row["pos"], ","); local b_marker = Marker(pos[1], pos[2], pos[3], "cylinder", 1.5, settings.marker_color[1], settings.marker_color[2], settings.marker_color[3], settings.marker_color[4]); b_marker.interior = pos[4]; b_marker.dimension = pos[5]; if (settings.blip ~= false) then if (row["owner"] == "For Sale") then local b_blip = Blip.createAttachedTo(b_marker, settings.blip, 2, 255, 0, 0, 255, 0, 100.0); b_blip.interior = pos[4]; b_blip.dimension = pos[5]; else local b_blip = Blip.createAttachedTo(b_marker, settings.blip, 2, 255, 0, 0, 255, 0, 100.0); b_blip.interior = pos[4]; b_blip.dimension = pos[5]; end end addEventHandler("onMarkerHit", b_marker, onBusinessMarkerHit); addEventHandler("onMarkerLeave", b_marker, onBusinessMarkerLeave); local timer = Timer(businessPayout, row["payout_cur_time"] , 1, b_marker); b_marker:setData("b_data", {row["id"], row["name"], row["owner"], row["cost"], row["payout"], row["payout_time"], row["payout_otime"], row["payout_unit"], row["bank"], timer}); end end end addCommandHandler("negocios", function(player) if (ACL.hasObjectPermissionTo(player, "function.banPlayer")) then triggerClientEvent(player, "business.showCreateBusinessWindow", player); else player:outputMessage("Negocios: Voce nao tem acesso a este comando.", 255, 0, 0); end end); function Player:outputMessage(message, r, g, b) if (settings.info_messages_type == "dx") then dxOutputMessage(message, self, r, g, b); else self:outputChat(message, r, g, b, true); end end function outputMessage(message, player, r, g, b) if (settings.info_messages_type == "dx") then dxOutputMessage(message, player, r, g, b); else player:outputChat(message, r, g, b, true); end end function dxOutputMessage(message, player, r, g, b) triggerClientEvent(player, "business.dxOutputMessage", player, message, r, g, b); end addEvent("business.outputMessage", true); addEventHandler("business.outputMessage", root, function(message, r, g, b) source:outputMessage(message, r, g, b); end); addEvent("business.createBusiness", true); addEventHandler("business.createBusiness", root, function(x, y, z, interior, dimension, name, cost, payout, payout_time, payout_unit) database:query(dbCreateBusinessCallback, {client, x, y, z, interior, dimension, name, cost, payout, payout_time, payout_unit}, "SELECT * FROM business"); end); function dbCreateBusinessCallback(query_handle, client, x, y, z, interior, dimension, name, cost, payout, payout_time, payout_unit) local sql = query_handle:poll(0); if (sql) then local id; if (#sql > 0) then id = sql[#sql]["id"] + 1; else id = 1; end local unit; if (payout_unit == "Segundos") then unit = 1000; elseif (payout_unit == "Minutos") then unit = 60000; elseif (payout_unit == "Horas") then unit = 3600000; elseif (payout_unit == "Dias") then unit = 86400000; end x = tonumber(x); y = tonumber(y); z = tonumber(z); interior = tonumber(interior); dimension = tonumber(dimension); cost = tonumber(cost); payout = tonumber(payout); payout_time = tonumber(payout_time); z = z - 1; database:exec("INSERT INTO business(id,name,owner,cost,pos,payout,payout_time,payout_otime,payout_unit,payout_cur_time,bank) VALUES(?,?,?,?,?,?,?,?,?,?,?)", id, name, "For Sale", cost, x..","..y..","..z..","..interior..","..dimension, payout, payout_time * unit, payout_time, payout_unit, payout_time * unit, 0); local b_marker = Marker(x, y, z, "cylinder", 1.5, settings.marker_color[1], settings.marker_color[2], settings.marker_color[3], settings.marker_color[4]); b_marker.interior = interior; b_marker.dimension = dimension; if (settings.blip ~= false) then local b_blip = Blip.createAttachedTo(b_marker, settings.blip, 2, 255, 0, 0, 255, 0, 100.0); b_blip.interior = interior; b_blip.dimension = dimension; end local timer = Timer(businessPayout, payout_time * unit , 1, b_marker); b_marker:setData("b_data", {id, name, "For Sale", cost, payout, payout_time * unit, payout_time, payout_unit, 0, timer}); addEventHandler("onMarkerHit", b_marker, onBusinessMarkerHit); addEventHandler("onMarkerLeave", b_marker, onBusinessMarkerLeave); if (#tostring(id) == 1) then id = "0".. tostring(id) end client:outputMessage("Negocios: Negocio(ID #"..id..") foi criado com sucesso", 0, 255, 0); end end function onBusinessMarkerHit(hElement, mDim) if (hElement:getType() ~= "player") then return; end if (hElement:isInVehicle()) then return; end if (not mDim) then return; end triggerClientEvent(hElement, "business.showInstructions", hElement); end function onBusinessMarkerLeave(hElement, mDim) if (hElement:getType() ~= "player") then return; end if (hElement:isInVehicle()) then return; end if (not mDim) then return; end triggerClientEvent(hElement, "business.hideInstructions", hElement); end function businessPayout(b_marker) local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (owner ~= "For Sale") then bank = bank + payout; database:exec("UPDATE business SET bank = ? WHERE id = ?", bank, id); if (settings.inform_player_of_payout) then local account = Account(owner); if (account) then local player = account:getPlayer(); if (player and player.isElement) then player:outputMessage("Negocios: Negocio \" "..name.." \" pagou($"..payout..")", 0, 255, 0); end end end end timer = Timer(businessPayout, payout_time, 1, b_marker); b_marker:setData("b_data", {id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); end addEventHandler("onResourceStop", resourceRoot, function() for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (timer and timer:isValid()) then local left = timer:getDetails(); if (left >= 50) then database:exec("UPDATE business SET payout_cur_time = ? WHERE id = ?", left, id); else database:exec("UPDATE business SET payout_cur_time = ? WHERE id = ?", payout_time, id); end end end end); function Ped:isInMarker(marker) local colshape = marker.colShape; return self:isWithinColShape(colshape); end addEventHandler("onResourceStart", resourceRoot, function() for index, player in ipairs(Element.getAllByType("player")) do bindKey(player, settings.key, "up", onPlayerAttemptToOpenBusiness); end end); addEventHandler("onPlayerJoin", root,function() bindKey(source, settings.key, "up", onPlayerAttemptToOpenBusiness); end); function onPlayerAttemptToOpenBusiness(player) for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do if (player:isInMarker(b_marker)) then local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); triggerClientEvent(player, "business.showBusinessWindow", player, b_marker, getAccountName(getPlayerAccount(player)) == owner, ACL.hasObjectPermissionTo(player, "function.banPlayer")); break; end end end function Ped:getMarker() for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do if (self:isInMarker(b_marker)) then return b_marker; end end end addEvent("business.buy", true); addEventHandler("business.buy", root, function() local account = client.account; if (not account or account:isGuest()) then client:outputMessage("Business: You are not logged in", 255, 0, 0) return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (owner ~= "For Sale") then client:outputMessage("Business: This business is owned", 255, 0, 0); return; end database:query(dbBuyBusinessCallback, {client, b_marker, id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}, "SELECT * FROM business WHERE owner = ?", account.name); end); addEvent("business.sell", true); addEventHandler("business.sell", root, function() local account = client.account; if (not account or account:isGuest()) then return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (owner ~= account.name) then if (ACL.hasObjectPermissionTo(client, "function.banPlayer")) then database:exec("UPDATE business SET owner = ? WHERE id = ?", "For Sale", id); b_marker:setData("b_data", {id, name, "For Sale", cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); client:outputMessage("Negocios: Voce vendeu o Negocio com Sucesso", 0, 255, 0); return; else client:outputMessage("Negocios: Voce nao e proprietario deste Negocio", 255, 0, 0); return; end end database:exec("UPDATE business SET owner = ?, bank = ? WHERE id = ?", "For Sale", 0, id); client:giveMoney(tonumber(("%.f"):format(cost / 2))); client:giveMoney(bank); b_marker:setData("b_data", {id, name, "For Sale", cost, payout, payout_time, payout_otime, payout_unit, 0}); client:outputMessage("Negocios: Voce vendeu o Negocio com Sucesso, todo o dinheiro no banco foi pago para você.", 0, 255, 0); end); addEvent("business.deposit", true); addEventHandler("business.deposit", root, function(amount) local account = client.account; if (not account or account:isGuest()) then return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (not tonumber(amount)) then client:outputMessage("Negocios: Quantidade invalida", 255, 0, 0); return; end if (owner ~= account.name) then client:outputMessage("Negocios: Você não é o proprietário deste Negocio", 255, 0, 0); return; end if (client.money < amount) then client:outputMessage("Negocios: Você não tem dinheiro suficiente", 255, 0, 0); return; end database:exec("UPDATE business SET bank = ? WHERE id = ?", bank + amount, id); client:takeMoney(amount); b_marker:setData("b_data", {id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank + amount, timer}); client:outputMessage("Negocios: Você depositou com sucesso $"..amount.." no negócio", 0, 255, 0); end); addEvent("business.withdraw", true); addEventHandler("business.withdraw", root, function(amount) local account = client.account; if (not account or account:isGuest()) then return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (not tonumber(amount)) then client:outputMessage("Negocios: Quantidade Invalida", 255, 0, 0); return; end if (owner ~= account.name) then client:outputMessage("Negocios: Voce nao e o dono do negocio", 255, 0, 0); return; end if (bank < amount) then client:outputMessage("Negocios: Voce nao tem muito no Banco de Negocios", 255, 0, 0); return; end database:exec("UPDATE business SET bank = ? WHERE id = ?", bank - amount, id); client:giveMoney(amount); b_marker:setData("b_data", {id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank - amount, timer}); client:outputMessage("Negocios: Voce retirou com sucesso $"..amount.." do Negocio", 0, 255, 0); end); addEvent("business.setName", true); addEventHandler("business.setName", root, function(new_name) if (new_name == "" or #new_name > 30) then client:outputMessage("Negocios: Valor Invalido", 255, 0, 0); return; end if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); database:exec("UPDATE business SET name = ? WHERE id = ?", new_name, id); b_marker:setData("b_data", {id, new_name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); client:outputMessage("Negocios: Voce renomeou com sucesso o negocio", 0, 255, 0); end); addEvent("business.setOwner", true); addEventHandler("business.setOwner", root, function(new_owner) if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); database:exec("UPDATE business SET owner = ? WHERE id = ?", new_owner, id); b_marker:setData("b_data", {id, name, new_owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); client:outputMessage("Negocios: Voce mudou com sucesso o proprietario da empresa", 0, 255, 0); end); addEvent("business.setCost", true); addEventHandler("business.setCost", root, function(amount) if (tonumber(amount) == nil) then client:outputMessage("Negocios: Valor Invalido", 255, 0, 0); return; end amount = tonumber(amount); if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); database:exec("UPDATE business SET cost = ? WHERE id = ?", amount, id); b_marker:setData("b_data", {id, name, owner, amount, payout, payout_time, payout_otime, payout_unit, bank, timer}); client:outputMessage("Negocios: Voce mudou com sucesso o custo do negocio", 0, 255, 0); end); addEvent("business.setBank", true); addEventHandler("business.setBank", root, function(amount) if (tonumber(amount) == nil) then client:outputMessage("Negocios: Valor Invalido", 255, 0, 0); return; end amount = tonumber(amount); if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); database:exec("UPDATE business SET bank = ? WHERE id = ?", amount, id); b_marker:setData("b_data", {id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, amount, timer}); client:outputMessage("Negocios: Voce mudou com sucesso a quantidade de banco comercial", 0, 255, 0); end); addEvent("business.destroy", true); addEventHandler("business.destroy", root, function() if (not ACL.hasObjectPermissionTo(client, "function.banPlayer")) then client:outputMessage("Negocios: Voce nao tem acesso para fazer isso", 255, 0, 0); return; end local b_marker = client:getMarker(); if (not isElement(b_marker)) then return; end local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); if (timer and timer:isValid()) then timer:destroy() end database:exec("DELETE FROM business WHERE id = ?", id); b_marker:destroyAttachedBlips(); b_marker:destroy(); client:outputMessage("Negocios: Voce destruiu com sucesso o negocio", 0, 255, 0); triggerClientEvent(client, "business.hideInstructions", client); database:query(dbReOrderBusinessesCallback, "SELECT * FROM business"); end); function dbBuyBusinessCallback(query_handle, source, b_marker, id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer) local sql = query_handle:poll(0); if (#sql == settings.owned_businesses) then source:outputMessage("Negocios: Voce ja possui "..#sql.." negocios , que e o valor maximo", 255, 0, 0); return; end local money = source.money; if (money < cost) then source:outputMessage("Negocios: Voce nao tem dinheiro suficiente", 255, 0, 0) return end database:exec("UPDATE business SET owner = ? WHERE id = ?", source.account.name, id); source:takeMoney(cost); source:outputMessage("Negocios: Voce comprou com sucesso neste negocio", 0, 255, 0); b_marker:setData("b_data", {id, name, source.account.name, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); end function dbReOrderBusinessesCallback(query_handle) local sql = query_handle:poll(0); if (sql and #sql > 0) then for index, row in ipairs(sql) do database:exec("UPDATE business SET id = ? WHERE id = ?", index, row["id"]); end for index, b_marker in ipairs(Element.getAllByType("marker", resourceRoot)) do database:query(dbUpdateBusinessesIDsCallback, {b_marker, index}, "SELECT id FROM business WHERE id = ?", index); end end end function dbUpdateBusinessesIDsCallback(query_handle, b_marker, index) local sql = query_handle:poll(0); local b_data = b_marker:getData("b_data"); local id, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer = unpack(b_data); b_marker:setData("b_data", {index, name, owner, cost, payout, payout_time, payout_otime, payout_unit, bank, timer}); end function Element:destroyAttachedBlips() if (not self) then return; end for index, element in pairs(self:getAttachedElements()) do if (element and element.isElement) then element:destroy(); end end end addEvent("business.getSettings", true); addEventHandler("business.getSettings", root, function() triggerClientEvent(source, "business.getSettings", source, settings); end); ui.client gui = {}; local screen_width, screen_height = GuiElement.getScreenSize(); addEventHandler("onClientResourceStart", resourceRoot, function() -- Create Business Window gui.cb = {text = {}, edit = {}, button = {}}; local width, height = 511, 530; local x, y = math.floor((screen_width / 2) - (width / 2)), math.floor(screen_height/2 - height/2); gui.cb.window = dxWindow(x, y, width, height, "Criar Négocios - (Traduzido por +YuMi~')"); gui.cb.window.visible = false; gui.cb.text.info = dxText(0, 25, 511, 51, "Colete as coordenadas e insira os dados para criar o negócio", gui.cb.window); gui.cb.text.posx = dxText(10, 75, 101, 20, "Posição X", gui.cb.window); gui.cb.text.posy = dxText(140, 75, 101, 20, "Posição Y", gui.cb.window); gui.cb.text.posz = dxText(270, 75, 101, 20, "Posição Z", gui.cb.window); gui.cb.text.intdim = dxText(400, 75, 101, 20, "Interior,Dimensão", gui.cb.window); gui.cb.text.info:setAlignX("center"); gui.cb.text.info:setAlignY("center"); gui.cb.text.info:setColor(0, 173, 0); gui.cb.text.posx:setAlignX("center"); gui.cb.text.posx:setAlignY("center"); gui.cb.text.posy:setAlignX("center"); gui.cb.text.posy:setAlignY("center"); gui.cb.text.posz:setAlignX("center"); gui.cb.text.posz:setAlignY("center"); gui.cb.text.intdim:setAlignX("center"); gui.cb.text.intdim:setAlignY("center"); gui.cb.edit.intdim = dxEditField(400, 105, 101, 21, "", gui.cb.window); gui.cb.edit.posx = dxEditField(10, 105, 101, 21, "", gui.cb.window); gui.cb.edit.posy = dxEditField(140, 105, 101, 21, "", gui.cb.window); gui.cb.edit.posz = dxEditField(270, 105, 101, 21, "", gui.cb.window); gui.cb.edit.intdim:setReadOnly(true); gui.cb.edit.posx:setReadOnly(true); gui.cb.edit.posy:setReadOnly(true); gui.cb.edit.posz:setReadOnly(true); gui.cb.button.pickup = dxButton(60, 145, 391, 41, "Pegar Cordenadas", gui.cb.window); gui.cb.button.pickup:setColor(125, 0, 0); gui.cb.text.name = dxText(0, 225, 141, 31, "Nome do Négocio:", gui.cb.window); gui.cb.text.cost = dxText(0, 265, 141, 31, "Custo do Négocio:", gui.cb.window); gui.cb.text.payout = dxText(0, 305, 141, 31, "Pagamento do Négocio:", gui.cb.window); gui.cb.text.payout_time = dxText(0, 345, 141, 31, "Tempo de Pagamento:", gui.cb.window); gui.cb.text.name:setAlignX("center"); gui.cb.text.name:setAlignY("center"); gui.cb.text.cost:setAlignX("center"); gui.cb.text.cost:setAlignY("center"); gui.cb.text.payout:setAlignX("center"); gui.cb.text.payout:setAlignY("center"); gui.cb.text.payout_time:setAlignX("center"); gui.cb.text.payout_time:setAlignY("center"); gui.cb.edit.name = dxEditField(160, 225, 281, 31, "", gui.cb.window); gui.cb.edit.cost = dxEditField(160, 265, 281, 31, "", gui.cb.window); gui.cb.edit.payout = dxEditField(160, 305, 281, 31, "", gui.cb.window); gui.cb.edit.payout_time = dxEditField(160, 345, 191, 31, "", gui.cb.window); gui.cb.unit = dxComboBox(360, 345, 141, nil, gui.cb.window); gui.cb.unit:addItem("Segundos"); gui.cb.unit:addItem("Minutos"); gui.cb.unit:addItem("Horas"); gui.cb.unit:addItem("Dias"); gui.cb.unit:setSelected(2); gui.cb.button.clear = dxButton(10, 490, 111, 31, "Limpar", gui.cb.window); gui.cb.button.cancel = dxButton(390, 490, 111, 31, "Cancelar", gui.cb.window); gui.cb.button.create = dxButton(140, 490, 231, 31, "Criar Négocio", gui.cb.window); gui.cb.button.clear:setColor(125, 0, 0); gui.cb.button.cancel:setColor(125, 0, 0); gui.cb.button.create:setColor(125, 0, 0); gui.cb.button.pickup.func = function(state) if (state ~= "up") then return; end local pos = localPlayer.position; local int = localPlayer.interior; local dim = localPlayer.dimension; local x, y, z = string.format("%.2f", pos.x), string.format("%.2f", pos.y), string.format("%.2f", pos.z); gui.cb.edit.posx.text = x; gui.cb.edit.posy.text = y; gui.cb.edit.posz.text = z; gui.cb.edit.intdim.text = int..","..dim; end gui.cb.button.clear.func = function(state) if (state ~= "up") then return; end gui.cb.edit.posx.text = ""; gui.cb.edit.posy.text = ""; gui.cb.edit.posz.text = ""; gui.cb.edit.intdim.text = ""; gui.cb.edit.name.text = ""; gui.cb.edit.cost.text = ""; gui.cb.edit.payout.text = ""; gui.cb.edit.payout_time.text = ""; gui.cb.unit:setSelected(2); end gui.cb.button.cancel.func = function(state) if (state ~= "up") then return; end gui.cb.window.visible = false; showCursor(false); end gui.cb.button.create.func = function(state) if (state ~= "up") then return; end local x, y, z, intdim = gui.cb.edit.posx.text, gui.cb.edit.posy.text, gui.cb.edit.posz.text, gui.cb.edit.intdim.text; local name = gui.cb.edit.name.text; local cost = gui.cb.edit.cost.text; local payout = gui.cb.edit.payout.text; local payout_time = gui.cb.edit.payout_time.text; -- local payout_unit = gui.cb.unit:getItemText(gui.cb.unit:getSelected()); if x ~= "" and name ~= "" and cost ~= "" and tonumber(cost) ~= nil and payout ~= "" and tonumber(payout) ~= nil and payout_time ~= "" and tonumber(payout_time) ~= nil and tonumber(payout_time) > 0 and tonumber(cost) > 0 and tonumber(payout) > 0 then if #name > 30 then outputMessage("BUSINESS: Business name must not be more than 30 characters", 255, 0, 0); return; end local zone = getZoneName(tonumber(x), tonumber(y), tonumber(z), false); if zone == "Unknown" then zone = "the middle of no where" end; local interior = tonumber(gettok(intdim, 1, ",")); local dimension = tonumber(gettok(intdim, 2, ",")); dxPrompt("Tem certeza de que deseja criar o negócio '"..name.."' em "..zone, function() Sound("files/cash.mp3", false); showCursor(false); local x, y, z, intdim = gui.cb.edit.posx.text, gui.cb.edit.posy.text, gui.cb.edit.posz.text, gui.cb.edit.intdim.text; local interior, dimension = unpack(split(intdim, ",")); local name = gui.cb.edit.name.text; local cost = gui.cb.edit.cost.text; local payout = gui.cb.edit.payout.text; local payout_time, payout_unit = gui.cb.edit.payout_time.text, gui.cb.unit:getItemText(gui.cb.unit:getSelected()); triggerServerEvent("business.createBusiness", root, x, y, z, interior, dimension, name, cost, payout, payout_time, payout_unit); gui.cb.button.clear.func("up"); gui.cb.window.visible = false; end); else outputMessage("BUSINESS: The data isn't correct, please correct it", 255, 0, 0); end end -- Business Window gui.b = {label = {}, tab = {}, edit = {}, button = {}}; local width, height = 524, 300; local x = screen_width/2 - width/2; local y = screen_height/2 - height/2; gui.b.window = dxWindow(x, y, width, height, "Business Name", false); gui.b.window.visible = false; gui.b.window:setTitleColor(125, 0, 0); gui.b.tab_panel = dxTabPanel(5, 50, 511, 231, gui.b.window); gui.b.tab.info = dxTab("Informações", gui.b.tab_panel); gui.b.label.id = dxText(10, 20, 81, 16, "ID: #", gui.b.tab.info); gui.b.label.name = dxText(10, 70, 241, 16, "Name:", gui.b.tab.info); gui.b.label.owner = dxText(10, 120, 231, 16, "Owner: ", gui.b.tab.info); gui.b.label.cost = dxText(10, 170, 191, 16, "Cost: ", gui.b.tab.info); gui.b.label.payout = dxText(290, 20, 211, 16, "Payout: ", gui.b.tab.info); gui.b.label.payout_time = dxText(290, 70, 211, 16, "Payout Time:", gui.b.tab.info); gui.b.label.location = dxText(290, 120, 211, 16, "Location:", gui.b.tab.info); gui.b.label.bank = dxText(290, 170, 211, 16, "Bank:", gui.b.tab.info); gui.b.label.id:setAlignX("left", false); gui.b.label.id:setAlignY("center"); gui.b.label.name:setAlignX("left", false); gui.b.label.name:setAlignY("center"); gui.b.label.owner:setAlignX("left", false); gui.b.label.owner:setAlignY("center"); gui.b.label.cost:setAlignX("left", false); gui.b.label.cost:setAlignY("center"); gui.b.label.payout:setAlignX("left", false); gui.b.label.payout:setAlignY("center"); gui.b.label.payout_time:setAlignX("left", false); gui.b.label.payout_time:setAlignY("center"); gui.b.label.location:setAlignX("left", false); gui.b.label.location:setAlignY("center"); gui.b.label.bank:setAlignX("left", false); gui.b.label.bank:setAlignY("center"); gui.b.tab.action = dxTab("Ações", gui.b.tab_panel); gui.b.button.buy = dxButton(10, 10, 101, 31, "Comprar", gui.b.tab.action); gui.b.button.sell = dxButton(10, 60, 101, 31, "Vender", gui.b.tab.action); gui.b.button.deposit = dxButton(10, 110, 101, 31, "Deposito", gui.b.tab.action); gui.b.button.withdraw = dxButton(10, 160, 101, 31, "Retirar", gui.b.tab.action); gui.b.button.set_name = dxButton(390, 10, 101, 31, "Mudar Nome", gui.b.tab.action); gui.b.button.set_owner = dxButton(390, 60, 101, 31, "Mudar Dono", gui.b.tab.action); gui.b.button.set_cost = dxButton(390, 110, 101, 31, "Mudar Custo", gui.b.tab.action); gui.b.button.set_bank = dxButton(390, 160, 101, 31, "Mudar Banco", gui.b.tab.action); gui.b.button.destroy = dxButton(130, 155, 241, 41, "Deletar", gui.b.tab.action); gui.b.button.x = dxButton(480, 25, 31, 31, "X", gui.b.window); gui.b.button.x.func = function(state) if (state ~= "up") then return; end gui.b.window.visible = false; showCursor(false); end gui.b.button.buy.func = function(state) if (state ~= "up") then return; end dxPrompt("Tem certeza de que quer comprar este negócio?", function() triggerServerEvent("business.buy", root); gui.b.window.visible = false; showCursor(false); end); end gui.b.button.sell.func = function(state) if (state ~= "up") then return; end dxPrompt("Tem certeza de que quer vender esse negócio?", function() triggerServerEvent("business.sell", root); gui.b.window.visible = false; showCursor(false); end); end; gui.b.button.deposit.func = function(state) if (state ~= "up") then return; end dxPrompt("Digite o valor a depositar", function(amount) amount = tonumber(amount); if (not amount) then outputMessage("You must enter a correct amount", 255, 0, 0); return; end triggerServerEvent("business.deposit", root, amount); gui.b.window.visible = false; showCursor(false); end, nil, true); end; gui.b.button.withdraw.func = function(state) if (state ~= "up") then return; end dxPrompt("Digite o valor a retirar", function(amount) amount = tonumber(amount); if (not amount) then outputMessage("You must enter a correct amount", 255, 0, 0); return; end triggerServerEvent("business.withdraw", root, amount); gui.b.window.visible = false; showCursor(false); end, nil, true); end; gui.b.button.set_name.func = function(state) if (state ~= "up") then return; end dxPrompt("Digite o novo nome", function(name) if (name == "" or name:len() < 4) then outputMessage("Name must be at least 4 characters long", 255, 0, 0); return; end triggerServerEvent("business.setName", root, name); gui.b.window.visible = false; showCursor(false); end, nil, true); end; gui.b.button.set_owner.func = function(state) if (state ~= "up") then return; end dxPrompt("Digite o nome da conta do novo proprietário", function(owner) if (owner == "") then outputMessage("Owner's account name must be at least 1 character long", 255, 0, 0); return; end triggerServerEvent("business.setOwner", root, owner); gui.b.window.visible = false; showCursor(false); end, nil, true); end; gui.b.button.set_cost.func = function(state) if (state ~= "up") then return; end dxPrompt("Digite o valor para definir o custo", function(amount) amount = tonumber(amount); if (not amount) then outputMessage("You must enter a correct amount", 255, 0, 0); return; end triggerServerEvent("business.setCost", root, amount); gui.b.window.visible = false; showCursor(false); end, nil, true); end; gui.b.button.set_bank.func = function(state) if (state ~= "up") then return; end dxPrompt("Digite o valor para definir o banco", function(amount) amount = tonumber(amount); if (not amount) then outputMessage("You must enter a correct amount", 255, 0, 0); return; end triggerServerEvent("business.setBank", root, amount); gui.b.window.visible = false; showCursor(false); end, nil, true); end; gui.b.button.destroy.func = function(state) if (state ~= "up") then return; end dxPrompt("Tem certeza de que quer destruir o negócio", function() triggerServerEvent("business.destroy", root); gui.b.window.visible = false; showCursor(false); end); end; end);