Jump to content

Mario222

Members
  • Posts

    14
  • Joined

  • Last visited

Everything posted by Mario222

  1. The resource called race_scoringsystem https://community.multitheftauto.com/index.php?p=resources&s=details&id=1073 have some error in s_main because in console says ERROR: race_scoringsystem\s_main.lua:86 attempt to perform arithmetic on fiel 'ratio_opponentrank' (a nil value). And resource doesn't work. What happend here? PlayerData = {} function ResetPlayerData(player) local playerName = getPlayerName(player or source) PlayerData[playerName] = { Streaks = 0 } end addEventHandler("onPlayerJoin", root, ResetPlayerData) addEventHandler("onResourceStart", resourceRoot, function() for _,player in ipairs(getElementsByType("player")) do ResetPlayerData(player) end end ) addEvent("onPlayerRaceWinStreak") addEvent("onPlayerAwardPoints") addEvent("onPlayerStatsUpdate") addEventHandler("onPlayerStatsUpdate", root, function(playerName, key, value, oldValue) value = value or 0 oldvalue = oldvalue or 0 local delta = value - oldValue if delta == 0 then return end local points = g_Settings[g_AutoPointSettings[key]] if points and points ~= 0 then exports["race_playerstats"]:IncrementPlayerStat(source, STAT.POINTS, points) if g_SettingLabels[key] then triggerEvent("onPlayerAwardPoints", source, points, g_SettingLabels[key]) end end -- the following require players local players = getElementsByType("player") if key == STAT.TIMES_DIED then local pointsDeath = g_Settings["ratio_death"] exports["race_playerstats"]:IncrementPlayerStat(source, STAT.POINTS, pointsDeath) triggerEvent("onPlayerAwardPoints", source, pointsDeath, g_SettingLabels[STAT.TIMES_DIED]) local pointsOpponentDeath = g_Settings["ratio_opponentdeath"] if pointsOpponentDeath == 0 then return end for _,player in ipairs(players) do if player ~= source then exports["race_playerstats"]:IncrementPlayerStat(player, STAT.POINTS, pointsOpponentDeath) triggerEvent("onPlayerAwardPoints", player, pointsOpponentDeath, string.format("%s wasted!", playerName)) end end return end -- count opponent ranks and points if key == STAT.RACES_FINISHED then local playerRank = getElementData(source, "race rank", false) --local playerPoints = exports["race_playerstats"]:GetPlayerStatValue(source, STAT.POINTS) or 0 local pointsFinish = g_Settings["ratio_racefinish"] exports["race_playerstats"]:IncrementPlayerStat(source, STAT.POINTS, pointsFinish) triggerEvent("onPlayerAwardPoints", source, pointsFinish, g_SettingLabels[STAT.RACES_FINISHED]) if g_Settings["ratio_opponentrank"] == 0 and g_Settings["ratio_opponentpoints"] == 0 then return end local myPoints = exports["race_playerstats"]:GetPlayerStatValue(source, STAT.POINTS) or 0 local ranks = 0 local points = 0 local oppPoints = 0 for _,player in ipairs(players) do -- opponents if player ~= source then local opponentRank = getElementData(player, "race rank", false) or 999 if opponentRank > playerRank then ranks = ranks + 1 local opponentPoints = exports["race_playerstats"]:GetPlayerStatValue(player, STAT.POINTS) or 0 local weight = myPoints / (myPoints + opponentPoints) if weight > 1 then weight = 1 end oppPoints = oppPoints + (1-weight) * g_Settings["ratio_opponentpoints"] end end end local rankPoints = ranks * g_Settings["ratio_opponentrank"] if rankPoints >= 1 then exports["race_playerstats"]:IncrementPlayerStat(source, STAT.POINTS, rankPoints) triggerEvent("onPlayerAwardPoints", source, rankPoints, getRankText(playerRank)) end if oppPoints >= 1 then exports["race_playerstats"]:IncrementPlayerStat(source, STAT.POINTS, oppPoints) triggerEvent("onPlayerAwardPoints", source, oppPoints, "Beaten Racers") end return end -- count streaks if key == STAT.RACES_WON then local playerName = getPlayerName(source) if not PlayerData[playerName] then ResetPlayerData(source) end -- but only if there is a quorum local minPlayers = g_Settings["winning_streak_quorum"] or 0 if #players < minPlayers then PlayerData[playerName].Streaks = 0 return end local wins = PlayerData[playerName].Streaks or 0 wins = wins + 1 if wins > 1 then exports["race_playerstats"]:IncrementPlayerStat(source, STAT.POINTS, g_Settings["ratio_winstreak"]) triggerEvent("onPlayerRaceWinStreak", source, wins) triggerEvent("onPlayerAwardPoints", source, g_Settings["ratio_winstreak"], string.format("Winning Streak x%u!", wins)) end local previousStreaks = exports["race_playerstats"]:GetPlayerStatValue(source, STAT.MAX_STREAKS) or 0 if wins > previousStreaks then exports["race_playerstats"]:IncrementPlayerStat(source, STAT.MAX_STREAKS, 1) end PlayerData[playerName].Streaks = wins -- clear opponents streak for _,player in ipairs(players) do if player ~= source then local oppName = getPlayerName(player) if PlayerData[oppName] then PlayerData[oppName].Streaks = 0 end end end return end end )
  2. This resource with this code not shows the points in scoreboard, i need help. g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) STAT = { --Player TIMES_DIED = 135, -- Races CHECKPOINTS_COLLECTED = 1024, TOTAL_RACES = 148, RACES_FINISHED = 1025, RACES_WON = 1026, TOPTIMES_SET = 1027, MAX_STREAKS = 1028, -- Scoring POINTS = 2010 } g_AutoPointSettings = { [121] = "ratio_kill", [1024] = "ratio_checkpoint", [148] = "ratio_racestart", [1026] = "ratio_win", [1027] = "ratio_toptime" } addEventHandler('onGamemodeStart', g_ResRoot, function() outputDebugString('Race onGamemodeStart') addRaceScoreboardColumns() if not g_GameOptions then cacheGameOptions() end end ) function addRaceScoreboardColumns() exports.scoreboard:addScoreboardColumn('Points') end -- -- SETTINGS -- function getString(var, default) local result = get(var) if not result then return default end return tostring(result) end function getNumber(var, default) local result = get(var) if not result then return default end return tonumber(result) end function getBool(var, default) local result = get(var) if not result then return default end return result or tostring(result) == 'true' end -- -- TABLES -- function table.dump(t, caption, depth) if not depth then depth = 1 end if depth == 1 and caption then outputDebugString(caption .. ':') end if not t then outputDebugString('Table is nil') elseif type(t) ~= 'table' then outputDebugString('Argument passed is of type ' .. type(t)) local str = tostring(t) if str then outputDebugString(str) end else local braceIndent = string.rep(' ', depth-1) local fieldIndent = braceIndent .. ' ' outputDebugString(braceIndent .. '{') for k,v in pairs(t) do if type(v) == 'table' and k ~= 'siblings' and k ~= 'parent' then outputDebugString(fieldIndent .. tostring(k) .. ' = ') table.dump(v, nil, depth+1) else outputDebugString(fieldIndent .. tostring(k) .. ' = ' .. tostring(v)) end end outputDebugString(braceIndent .. '}') end end function explode(div,str) if (div=='') then return false end local pos,arr = 0,{} -- for each divider found for st,sp in function() return string.find(str,div,pos,true) end do table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider pos = sp + 1 -- Jump past current divider end table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider return arr end -- -- DEBUG -- function alert(message, channel) message = g_ResName..": "..tostring(message) if channel == "console" then outputConsole(message) return end if channel == "chat" then outputChatBox(message) return end outputDebugString(message) end -- -- PLAYER -- -- remove color coding from string function removeColorCoding (name) return type(name)=="string" and string.gsub(name, "#%x%x%x%x%x%x", "") or name end -- getPlayerName with color coding removed local _getPlayerName = getPlayerName function getPlayerName(player) return removeColorCoding (_getPlayerName(player)) end -- -- MISC -- function randomize() -- set a random seed based on server tick count, wrap around each 20 days math.randomseed(getTickCount()) end function getRankText(rank) local ordinal = "th" local unit = rank % 10 if unit == 1 then ordinal = "st" elseif unit == 2 then ordinal = "nd" elseif unit == 3 then ordinal = "rd" end return string.format("%i%s", rank, ordinal) end
  3. I need a Rank-Points system that can be displayed on the scoreboard for a server with maps of Race and DD-DM-Shooter. Composed as follow. Number 1 - Win 20 Points. Number 2 - Win 10 Points. Number 3 - Win 5 Points. Number 4 to down - 2 Points. And the number of rank based on the number of existing accounts and who have more rank based on his points, and the one who has more points the higher his rank will be the largest being the number 1.
  4. I wanna kill a last survivor in DD or Fun maps before when is the last survivor like 2 seconds after but i don't know how to do it.
  5. Yes i didn't saw that i fixed the problem. How to make it give money to the player regardless of whether it is a DD map or a race I can use the function of getAlivePlayers getDeadPlayers ???
  6. I have this resource that gives money to players based on their rank that I configure and adapt for only 20 players (maximum limit that I put on my server), it is a DD server but also a race and some from FunDD. So, the resource doesn't work, I have maps of both types and I need it to work in terms of rank but with the number of people left as I configure it, but that the winner, when no one is left alive, can take their money but I can't achieve how do it, I'm sorry if I bother but I'm still new to this Lua. -- # Server Side ! local Ranks = { {1,400}, {2,200}, {3,100}, {4,80}, {5,50}, {6,30}, {7,20}, {8,20}, {9,20}, {10,10} {11,10} {12,10} {13,10} {14,10} {15,10} {16,5} {17,5} {18,5} {19,5} {20,5} } addEventHandler("onPlayerWasted",root, function ( ) for _,v in ipairs ( Ranks ) do if ( exports["race"]:getPlayerRank( source ) == v[1] ) then givePlayerMoney ( source,v[2] ) end end end )
  7. 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 ( 1 ); 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() local alivePlayers = 0 for index,player in ipairs(getElementsByType("player")) do if getElementData(player,"state") == "alive" then alivePlayers = alivePlayers + 1 end end return alivePlayers end function getDeadGuys() local deadPlayers = 0 for index,player in ipairs(getElementsByType("player")) do if getElementData(player,"state") == "dead" then deadPlayers = deadPlayers + 1 end end return deadPlayers end function giveMoneyWinDie ( ) local account = getPlayerAccount ( source ); local playersAlive = getAliveGuys ( 1 ); local playersDead = getDeadGuys ( ); local checkYourPos = playersAlive + 1 local pos = nil; if not (checkYourPos <= 0) then if tonumber ( checkYourPos ) == 1 then pos = 1 else pos = checkYourPos; 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 outputDebugString( "pos: " .. tostring(pos) ); local money = math.ceil ( getPlayerCount ( ) * 50 / pos ); outputDebugString( "money: " .. tostring(money) ); 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 outputDebugString( "player money: " .. tostring(getPlayerMoney(source)) ); setAccountData ( account, "money", tostring ( getPlayerMoney ( source ) ) ); end end end end addEventHandler ( "onPlayerWasted", root , giveMoneyWinDie ) I'm sorry for not giving complete info, it's a shopmap panel, and I tried to modify it to avoid giving negative numbers, that is, when a player loses in the first place, he gives him $ 50, but instead of giving them the $ 50, he You remove them, and if you have 0, you end up with -50 $.
  8. I have a problem, this is a part of my resource that gives money to players based on their position, but instead of giving them money, it subtracts that amount, I don't know how to solve it. function giveMoneyWinDie ( ) local account = getPlayerAccount ( source ); local playersAlive = getAliveGuys ( 1 ); local playersDead = getDeadGuys ( ); local checkYourPos = playersAlive + 1 local pos = nil; if not (checkYourPos <= 0) then if tonumber ( checkYourPos ) == 1 then pos = 1 else pos = checkYourPos; 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 end addEventHandler ( "onPlayerWasted", root , giveMoneyWinDie )
  9. I want to see, if i can to create teams from admin panel, and those teams could be saved in SQL. My teams are deleted when my server is restarted.
  10. How to configure the admin panel so that the teams are not deleted when the server is restarted and save the teams in sql?
  11. I used to enter in that server in 2012-2013. But i don't know what happened, but the staff banned some countries including venezuela, and i remember in those years, watch a lot of players from latinamerica, that server used to have 30/40 players every day, but after banning some countries i think that server is a little bit dead. I enter for nostalgic because i remember some friends of my, like winter and mike. I like this sv and i enter every day.
  12. I want to know how to save teams, maybe in SQL, I am not an expert, I just want some help for a server that I am building, I have teams through a script but with teams related to the acl, but I want to know if there is a method to save The teams even though the server is restarted and create them from the admin panel perhaps, and also that the players are saved in the team.
×
×
  • Create New...