Jump to content

Donator Group


papam77

Recommended Posts

Nothing work it ! :D He was unlogged :D

And one ask :D

I have this

--Vars 
--Author TwiX [[Don't Remove This Line]] 
local price = 500; 
  
addEventHandler ( 'onGamemodeMapStart', root, 
    function ( mapres ) 
        local txMapName = getResourceName ( mapres ); 
        pHasBought = false; 
        allGotVehicle = false; 
        getAliveGuys ( 3 ); 
        saveSqlPlayed ( txMapName ); 
    end 
) 
  
function rStart ( ) 
    pHasBought = false; 
    allGotVehicle = false; 
    executeSQLQuery ( "CREATE TABLE IF NOT EXISTS tx_MapShop ( mapName TEXT, played INTEGER )" ); 
    getAllMapsFromManager ( ); 
    txBMaps = { } 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource ( ) ), rStart ) 
  
function buyNextMap ( player, mapName ) 
    if not player or not mapName then return end 
    if ( isGuestAccount ( getPlayerAccount ( player ) ) == false ) then 
        if pHasBought == false then 
            local money = tonumber ( getPlayerMoney ( player ) ); 
            local theTime = getMsFromMin ( 10 ); 
            if money >= tonumber ( price ) then 
                if ( not txBMaps [ mapName ] ) then 
                    txBMaps [ mapName ] = true 
                    executeCommandHandler ( "bm", player, mapName ); --This function need admin rights 
                    pHasBought = player; 
                    setTimer ( removeMapFromList, theTime.ms, 1, mapName ); 
                else 
                    outputChatBox ( "* #ff0000'#ffffff" .. mapName .. "#ff0000' #ffffffwill be #abcdefavailable #ffffffin #abcdef10 #ffffffminutes", player, 255, 255, 255, true ); 
                end 
            else 
                outputChatBox ( "* You #abcdefdon't #ffffffhave enough #abcdefmoney #ffffffto buy the map!", player, 255, 255, 255, true ); 
            end 
        else 
            outputChatBox ( "* A #abcdefmap #ffffffis already bought at the moment! Please #abcdeftry #ffffffagain later", player, 255, 255, 255, true ); 
        end 
    else 
        outputChatBox ( "* You should be #abcdeflogged in to buy the map!", player, 255, 255, 255, true ); 
    end 
end 
addEvent ( "doBuyMap", true ) 
addEventHandler ( "doBuyMap", root, buyNextMap ) 
  
function removeMapFromList ( mapName ) 
    outputChatBox ( "* #abcdef" .. mapName .. " #ffffff - #ffffffis now #abcdefavailable #ffffffat the #abcdefMap Shop!", root, 255, 255, 255, true ); 
    txBMaps [ mapName ] = nil; 
end 
  
addEvent ( "onRaceStateChanging", true ) 
addEventHandler ( "onRaceStateChanging", root, 
    function ( newState ) 
        if  ( newState == "Running" ) then 
            for k,v in pairs ( getElementsByType ( "player" ) ) do 
                local hisVehicle = getPedOccupiedVehicle ( v ); 
                if not hisVehicle then return end 
                setElementData (v, "gotMoney", false ); 
                if isPedInVehicle ( v ) then 
                    allGotVehicle = true; 
                end 
            end 
            if allGotVehicle then 
                getAliveGuys ( 1 ); 
            end 
        end 
    end 
) 
  
addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        setElementData ( source, "gotMoney", false ); 
        --Atm only setElementData 
    end 
) 
  
--Functions by Admin Panel (lil_Toady) 
function getAllMaps ( loadList, s ) 
    local tableOut 
    if loadList then 
        tableOut = { }; 
        local gamemodes = { }; 
        gamemodes = call ( getResourceFromName ( "mapmanager" ), "getGamemodes" ); 
        for id, gamemode in ipairs ( gamemodes ) do 
            tableOut [ id ] = { }; 
            tableOut [ id ].name = getResourceInfo(gamemode,"name") or getResourceName(gamemode); 
            tableOut [ id ].resname = getResourceName(gamemode); 
            tableOut [ id ].maps = {}; 
            local maps = call ( getResourceFromName ( "mapmanager" ), "getMapsCompatibleWithGamemode", gamemode ); 
            for _, map in ipairs ( maps ) do 
                table.insert ( tableOut [ id ][ "maps" ],{ name = getResourceInfo ( map, "name" ) or getResourceName ( map ),resname = getResourceName ( map ) } ); 
            end 
            table.sort ( tableOut [ id ][ "maps" ],sortCompareFunction ); 
        end 
        table.sort ( ( tableOut ), sortCompareFunction ); 
        table.insert ( tableOut, { name = "no gamemode", resname = "no gamemode", maps = { } } ); 
        local countGmodes = #tableOut; 
        local maps = call ( getResourceFromName ( "mapmanager" ), "getMapsCompatibleWithGamemode" ); 
        for id, map in ipairs ( maps ) do 
            table.insert ( tableOut [ countGmodes ][ "maps" ],{ name = getResourceInfo ( map, "name" ) or getResourceName ( map ), resname = getResourceName (map ) } ); 
        end 
        table.sort ( tableOut [ countGmodes ][ "maps" ], sortCompareFunction ); 
    end 
    local map = call ( getResourceFromName ( "mapmanager" ), "getRunningGamemodeMap" ); 
    local gamemode = call ( getResourceFromName ( "mapmanager" ), "getRunningGamemode" ); 
    gamemode = gamemode and getResourceName ( gamemode ) or "N/A"; 
    map = map and getResourceName ( map ) or "N/A"; 
    triggerClientEvent ( "refreshCompleted", loadList, tableOut, gamemode, map, s ); 
end 
addEvent ( "doRefreshMapList", true ) 
addEventHandler ( "doRefreshMapList", root, getAllMaps ) 
  
function sortCompareFunction ( s1, s2 ) 
    if type ( s1 ) == "table" and type ( s2 ) == "table" then 
        s1, s2 = s1.name, s2.name; 
    end 
    s1, s2 = s1:lower ( ), s2:lower( ); 
    if s1 == s2 then 
        return false 
    end 
    local byte1, byte2 = string.byte ( s1:sub ( 1, 1 ) ), string.byte ( s2:sub ( 1, 1 ) ); 
    if not byte1 then 
        return true 
    elseif not byte2 then 
        return false 
    elseif byte1 < byte2 then 
        return true 
    elseif byte1 == byte2 then 
        return sortCompareFunction ( s1:sub ( 2 ), s2:sub ( 2 ) ); 
    else 
        return false 
    end 
end 
  
function getAliveGuys ( mode ) 
    if not mode then return end 
    if mode == 1 then 
        pAlive = { }; 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            if ( getElementData ( player, "state" ) == "alive" ) then 
                table.insert ( pAlive, player ); 
            end 
        end 
        return pAlive; 
    elseif mode == 2 then 
        return #pAlive; 
    elseif mode == 3 then 
        if pAlive then 
            pAlive = nil; 
        end 
        return false 
    end 
end 
  
function getDeadGuys ( ) 
    local pDead = 0 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if getElementData ( player, "state" ) == "dead" then 
            pDead = pDead + 1; 
        end 
    end 
    return pDead; 
end 
  
function giveMoneyWinDie ( ) 
    local account = getPlayerAccount ( source ); 
    local playersAlive = getAliveGuys ( 2 ); 
    local playersDead = getDeadGuys ( ); 
    local pAll = playersAlive + playersDead; 
    local checkYourPos = pAll - playersDead; 
    local pos = nil; 
    if tonumber ( checkYourPos ) == 1 then pos = 1 else pos = checkYourPos + 1; end 
    if tonumber ( checkYourPos ) == 2 then pos = 2; end 
    if pos == 1 or pos == 21 or pos == 31 then 
        posName = "st"; 
    elseif pos == 2 or pos == 22 or pos == 32 then 
        posName = "nd"; 
    elseif pos == 3 or pos == 23 or pos == 33 then 
        posName = "rd"; 
    else 
        posName = "th"; 
    end 
    if not getElementData ( source, "gotMoney" ) then 
        local money = math.ceil ( getPlayerCount ( ) * 50 / pos ); 
        givePlayerMoney ( source, money ); 
        outputChatBox ( "* You were #abcdef[#ff0000" .. pos .. posName .. "#abcdef]#ffffff and #abcdefearned #ffffff" .. money .. "#00ff00$!", source, 255, 255, 255, true ); 
        setElementData ( source, "gotMoney", true ); 
        if account then 
            setAccountData ( account, "money", tostring ( getPlayerMoney ( source ) ) ); 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", root , giveMoneyWinDie ) 
  

I need it only on command /dshop not bind

Link to comment

--Some vars 
--Author TwiX [[Don't Remove This Line]] 
local sW,sH = guiGetScreenSize ( ); 
local gUtils = { }; 
gUtils.guiW,gUtils.guiH = 398, 410; 
gUtils.posX,gUtils.posY = sW / 2 - gUtils.guiW / 2, sH / 2 - gUtils.guiH / 2; --Center of screen for all resolutions 
local gLabels = { }; 
local gButtons = { }; 
  
function createGui ( ) 
    gWindow = guiCreateWindow ( gUtils.posX, gUtils.posY, gUtils.guiW, gUtils.guiH, "Mini Map Shop v0.7", false ); 
    gLabels[1] = guiCreateLabel ( 206, 30, 161, 19, "Money:", false, gWindow ); 
    gLabels[2] = guiCreateLabel ( 206, 49, 100, 16, "Map Costs 5000$", false, gWindow ); 
    gLabels[3] = guiCreateLabel ( 206, 66, 82, 15, "Selected Map:", false, gWindow ); 
    gLabels[4] = guiCreateLabel ( 206, 145, 188, 22, "Buy Maps Shop by TwiX", false, gWindow ); 
    gLabels[5] = guiCreateLabel ( 206,165,67,22, "Search Map:", false, gWindow ); 
    gLabels[6] = guiCreateLabel ( 206,215,188,22, "Top 1: ", false, gWindow ); 
    gLabels[7] = guiCreateLabel ( 206,235,188,22, "Top 2: ", false, gWindow ); 
    gLabels[8] = guiCreateLabel ( 206,255,188,22, "Top 3: ", false, gWindow ); 
    gUtils[1] = guiCreateLabel ( 206, 86, 188, 16, "Please select any map", false, gWindow ); 
    gUtils[2] = guiCreateLabel ( 206, 106, 188, 16, "Played: N/A", false, gWindow ); 
    gUtils[3] = guiCreateLabel ( 206, 125, 188, 16, "Rating: N/A", false, gWindow ); 
    for _, label in ipairs ( gUtils ) do guiLabelSetColor ( label, 171, 205, 239 ); guiSetFont ( label, "default-bold-small" ); end 
    for _, label in ipairs ( gLabels ) do 
        guiSetFont ( label, "default-bold-small" ); 
        if label == gLabels[3] then 
            guiLabelSetColor ( gLabels[3], 0, 255, 0 ); 
        end 
    end 
    gButtons[1] = guiCreateButton ( 206, 366, 182, 35, "Buy as next map", false, gWindow ); 
    gButtons[2] = guiCreateButton ( 206, 277, 68, 21, "[DM]", false, gWindow ); 
    gButtons[3] = guiCreateButton ( 322, 277, 68, 21, "[DD]", false ,gWindow ); 
    gButtons[4] = guiCreateButton ( 206, 301, 68, 21, "[FUN]", false, gWindow ); 
    gButtons[5] = guiCreateButton ( 322, 301, 68, 21, "[TRIALS]", false, gWindow ); 
    gButtons[6] = guiCreateButton ( 260, 335, 68, 21, "[ALL]", false, gWindow ); 
    gGridList = guiCreateGridList ( 11, 32, 191, 395, false, gWindow ); 
    guiGridListSetSelectionMode ( gGridList, 2 ); 
    gColumn = guiGridListAddColumn ( gGridList, "Name:", 0.85 ); 
    guiWindowSetSizable ( gWindow, false ); 
    pEdit = guiCreateEdit ( 206, 185, 153, 26, "", false, gWindow ); 
    guiSetVisible ( gWindow, false ); 
    addEventHandler ( "onClientGUIClick", getResourceRootElement ( getThisResource ( ) ), somethingFromClick ); 
    addCommandHandler("dshop",showPanel) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement ( getThisResource ( ) ), createGui ) 
  
function showPanel ( ) 
    if guiGetVisible ( gWindow ) then 
        guiSetVisible ( gWindow, false ); 
        showCursor ( false ); 
        removeEventHandler ( "onClientGUIChanged", pEdit, startSearchMap ); 
    else 
        triggerServerEvent ( "doRefreshMapList", localPlayer, localPlayer ); 
        addEventHandler ( "onClientGUIChanged", pEdit, startSearchMap ); 
        guiSetVisible ( gWindow, true ); 
        showCursor ( true ); 
        local playerMoney = getPlayerMoney ( ); 
        guiSetText ( gLabels[1], "Money: [ " .. playerMoney .. " ]" ); 
    end 
end 
  
function somethingFromClick ( button, state ) 
    local row = guiGridListGetSelectedItem ( gGridList ); 
    if row == -1 then 
        guiSetText ( gUtils[1], "Error! Please Select any map" ); 
        guiSetText ( gUtils[2], "Played: N/A" ); 
        guiSetText ( gUtils[3], "Rating: N/A" ); 
        guiSetText ( gLabels[6], "Top 1: N/A" ); 
        guiSetText ( gLabels[7], "Top 2: N/A" ); 
        guiSetText ( gLabels[8], "Top 3: N/A" ); 
    end 
    if source == gButtons[1] then 
        local mName = guiGridListGetItemText ( gGridList, row, gColumn ); 
        triggerServerEvent ( "doBuyMap", localPlayer, localPlayer, mName ); 
    elseif source == gGridList then 
        local mapName = guiGridListGetItemText ( gGridList, row, gColumn ); 
        guiSetText ( gUtils[1], mapName ); 
        triggerServerEvent ( "doGetResultFormap", localPlayer, localPlayer, mapName ); 
    elseif source == gButtons[2] then 
        filterForMaps ( 1 ); 
    elseif source == gButtons[3] then 
        filterForMaps ( 2 ); 
    elseif source == gButtons[4] then 
        filterForMaps ( 3 ); 
    elseif source == gButtons[5] then 
        filterForMaps ( 4 ); 
    elseif source == gButtons[6] then 
        filterForMaps ( 5 ); 
    end 
end 
  
function setMapNameInGrid ( gamemodeMapTable, gamemode, map, s ) 
    guiGridListClear ( gGridList ); 
    if gamemodeMapTable then 
        aGamemodeMapTable = gamemodeMapTable; 
        for id, gamemode in pairs ( gamemodeMapTable ) do 
            if ( gamemode.name == "Race" ) then 
                for id, map in ipairs ( gamemode.maps ) do 
                    if s then 
                        if string.find ( string.lower ( map.name ), string.lower ( s ) ) then 
                            local row = guiGridListAddRow ( gGridList ); 
                            guiGridListSetItemText ( gGridList, row, gColumn, map.name, false, false ); 
                        end 
                    else 
                        local row = guiGridListAddRow ( gGridList ); 
                        guiGridListSetItemText ( gGridList, row, gColumn, map.name, false, false ); 
                    end 
                end 
            end 
        end 
    end 
end 
addEvent ( "refreshCompleted", true ) 
addEventHandler ( "refreshCompleted", root, setMapNameInGrid ) 
  
function startSearchMap ( ) 
    if not source == pEdit then return end 
    guiGridListClear ( gGridList ); 
    if guiGetText ( pEdit ) ~= "" then 
        local found = 0; 
        for id, gamemode in pairs ( aGamemodeMapTable ) do 
            if ( gamemode.name == "Race" ) then 
                for id, map in ipairs ( gamemode.maps ) do 
                    if string.find ( string.lower ( map.name ), string.lower ( guiGetText(pEdit):lower ( ) ), 0, true ) ~= nil then 
                        local row = guiGridListAddRow ( gGridList ); 
                        guiGridListSetItemText ( gGridList, row, 1, map.name, false, false ); 
                        found = found + 1; 
                    end 
                end 
            end 
        end 
        if found == 0 then 
            local row = guiGridListAddRow ( gGridList ); 
            guiGridListSetItemText ( gGridList, row, 1, "Map not found", false, false ); 
            guiGridListSetItemColor ( gGridList, row, 1, 255, 0, 0 ); 
        end 
    else 
        for id, gamemode in pairs ( aGamemodeMapTable ) do 
            if ( gamemode.name == "Race" ) then 
                for id, map in ipairs ( gamemode.maps ) do 
                    local row = guiGridListAddRow ( gGridList ); 
                    guiGridListSetItemText ( gGridList, row, 1, map.name, false, false ); 
                end 
            end 
        end 
    end 
end 
  
function filterForMaps ( mode ) -- Bad function will loop all maps. I don't recommend, only if you want this 
    local mode = tonumber ( mode ); 
    guiGridListClear ( gGridList ); 
    for id, gamemode in pairs ( aGamemodeMapTable ) do 
        if ( gamemode.name == "Race" ) then 
            for id, map in ipairs ( gamemode.maps ) do 
                if mode == 1 then 
                    if string.find ( map.name, "[DM]", 1, true ) then 
                        local gRow = guiGridListAddRow ( gGridList ); 
                        guiGridListSetItemText ( gGridList, gRow, gColumn, map.name, false, false ); 
                    end 
                elseif mode == 2 then 
                    if string.find ( map.name, "[DD]", 1, true ) then 
                        local gRow = guiGridListAddRow ( gGridList ); 
                        guiGridListSetItemText ( gGridList, gRow, gColumn, map.name, false, false ); 
                    end 
                elseif mode == 3 then 
                    if string.find ( map.name, "[FUN]", 1, true ) then 
                        local gRow = guiGridListAddRow ( gGridList ); 
                        guiGridListSetItemText ( gGridList, gRow, gColumn, map.name, false, false ); 
                    end 
                elseif mode == 4 then 
                    if string.find ( map.name, "[TRIALS]", 1, true ) then 
                        local gRow = guiGridListAddRow ( gGridList ); 
                        guiGridListSetItemText ( gGridList, gRow, gColumn, map.name, false, false ); 
                    end 
                elseif mode == 5 then 
                    local gRow = guiGridListAddRow ( gGridList ); 
                    guiGridListSetItemText ( gGridList, gRow, gColumn, map.name, false, false ); 
                end 
            end 
        end 
    end 
end 
  
function guiSetMapText ( played, rating, count, name1, theTime1, name2, theTime2, name3, theTime3 ) 
    if played == 1 then 
        p = "Played: First time"; 
    else 
        p = "Played: ["..played.." times]"; 
    end 
    guiSetText ( gUtils[2], p ); 
    if count == 1 then prefix = ""; else prefix = "'s"; end 
    if rating then 
        text = "Rating: [" .. rating .. "/10] by ( " .. count .. " ) player" .. prefix; 
    else 
        text = "Not Rated Yet"; 
    end 
    guiSetText ( gUtils[3], text ); 
    if name1 and theTime1 then 
        guiSetText ( gLabels[6], "Top 1: " .. name1 .. " - " .. theTime1 ); 
    else 
        guiSetText ( gLabels[6], "Top 1: N/A" ); 
    end 
    if name2 and theTime2 then 
        guiSetText ( gLabels[7], "Top 2: " .. name2 .. " - " .. theTime2 ); 
    else 
        guiSetText ( gLabels[7], "Top 2: N/A" ); 
    end 
    if name3 and theTime3 then 
        guiSetText ( gLabels[8], "Top 3: " .. name3 .. " - " .. theTime3 ); 
    else 
        guiSetText ( gLabels[8], "Top 3: N/A" ); 
    end 
end 
addEvent ( "doUpdateLabels", true ) 
addEventHandler ( "doUpdateLabels", root, guiSetMapText ) 
  
fileDelete ( "tx_mapsShop_c.lua" ); 
  

Please Replace This Code On This File : tx_mapsShop_c.lua

and change the command @ line @ 43

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...