Jump to content

Taquito

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by Taquito

  1. Here's points system I use on my DD server. Everything works good except one thing. Example: 5 players on the server 1. 4 points, 8$ - good 2. 4 points, 8$ - <=== wrong, should be 3 points, 6$ 3. 2 points, 4$ - good 4. 1 point, 2$ - good 5. Gets 0 points, 0 money - good What is wrong? What do I change to make it work properly? g_Root = getRootElement() -- Config section minPlayers = 5 soundsCount = 74 -- Script variables local totalPlayers = 0 local tripleDamages = false -- When our resource start and stop function resourceStart(res) sql = mysql_connect("censored") exports.scoreboard:scoreboardAddColumn("dd.points", g_Root, 70, "Points") exports.scoreboard:scoreboardAddColumn("dd.rank", g_Root, 70, "Rank") exports.scoreboard:scoreboardAddColumn("dd.money", g_Root, 70, "Money") exports.scoreboard:scoreboardSetSortBy("dd.points", false) totalPlayers = #getAlivePlayers() + #getDeadPlayers() end function resourceStop(res) mysql_close(sql) end -- When play connect to our server function playerJoin() -- Welcome message outputChatBox("[sERVER] #FFFF00Welcome \"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" />", source, 255, 0, 0, true) outputChatBox("Press to open:", source, 150, 255, 150, true) outputChatBox("F1 - User panel #007800|| #00E600F5 - Shader panel #007800|| #00E600F6 - Color panel", source, 0, 230, 0, true) -- outputChatBox("[sERVER] #FFFF00You have ".. (getElementData(source, "dd.points") or 0) .." points, and ".. (getElementData(source, "dd.money") or 0) .."$.", source, 255, 0, 0, true) -- Load data UtopiaDD.loadPlayer(source) -- Save join time local ctime = getRealTime() setElementData(source, "dd.stats.join_time", tonumber(ctime.timestamp)) end -- When player quit or die function playerQuit(quitType) -- Update played time statistics.addTime(source) end function playerSpawned(posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension) UtopiaDD.loadPlayer(source) -- Remove items setElementData(source, "dd.ghost", nil) end function playerWasted(ammo, attacker, weapon, bodypart) -- Get serial local playerSerial = getPlayerSerial(source) local escSerial = mysql_escape_string(sql, playerSerial) if (getPlayerIdleTime(source)> 15000) then return true end -- If there is more than two players if(totalPlayers > minPlayers-1) then -- Then give a point reward to dead player reward = totalPlayers - #getAlivePlayers() - 1 if(reward > 0) then local playerPoints = getElementData(source, "dd.points") local playerMoney = getElementData(source, "dd.money") setElementData(source, "dd.points", tonumber(playerPoints) + reward) setElementData(source, "dd.money", tonumber(playerMoney) + 2*reward) outputChatBox("[POINTS] #FFFF00You have now +".. reward .." points more! You have also earned ".. 2*reward .."$. Total points: "..getElementData(source, "dd.points"), source, 255, 0, 0, true) -- Save points mysql_query(sql, "UPDATE players SET points = points+".. reward ..", money = money+".. 2*reward .." WHERE serial = '".. escSerial .."'") else outputChatBox("[POINTS] #FFFF00You were first... you are out of luck. No points for you this time.", source, 255, 0, 0, true) end -- Or say so the point system is disabled now else outputChatBox ( "[POINTS] #FFFF00Need ".. minPlayers-totalPlayers.." more players to enable points system", source, 255, 0, 0, true ) end -- Refresh rank UtopiaDD.updatePlayerRank(source) end function playerFinished(rank) if rank < 4 then statistics.addWin(source, rank) end end function playerWon() --blowVehicle(getPedOccupiedVehicle(source)) killPed(source) statistics.addWin(source, 1) triggerClientEvent("onFinish", getRootElement(), "sounds/rs".. math.random(soundsCount) ..".mp3") end function enableTripleDamages() tripleDamages = true outputChatBox("[DD] #FFFF00Double damages enabled!", getRootElement(), 255, 0, 0, true) end function vehicleDamaged(damage) if tripleDamages then setElementHealth(source, getElementHealth(source) - damage) end end function removeRepairs() call(getResourceFromName("race"), "removeHealthPickups") outputChatBox("[DD] #FFFF00All repair pickups destroyed!", getRootElement(), 255, 0, 0, true) end function mapStarted(mapInfo, mapOptions, gameOptions) totalPlayers = #getAlivePlayers() + #getDeadPlayers() -- Remove repairs trigger if (isTimer(removeRepairsTrigger)) then killTimer(removeRepairsTrigger) end -- Triple damages trigger if (isTimer(tripleDamagesTrigger)) then killTimer(tripleDamagesTrigger) end tripleDamages = false removeRepairsTrigger = setTimer(removeRepairs, 60*1000, 1) tripleDamagesTrigger = setTimer(enableTripleDamages, 120*1000, 1) end function stateChanged(newState, oldState) -- Count a players if (newState == "GridCountdown") then totalPlayers = #getAlivePlayers() + #getDeadPlayers() end end -- Add all event hadlers addEventHandler("onResourceStart", getRootElement(), resourceStart) addEventHandler("onResourceStop", getRootElement(), resourceStop) addEventHandler("onPlayerJoin", getRootElement(), playerJoin) addEventHandler("onPlayerQuit", getRootElement(), playerQuit) addEventHandler("onPlayerSpawn", getRootElement(), playerSpawned) addEventHandler("onPlayerWasted", getRootElement(), playerWasted) addEventHandler("onPlayerFinishDD", getRootElement(), playerFinished) addEventHandler("onPlayerWinDD", getRootElement(), playerWon) addEventHandler("onVehicleDamage", getRootElement(), vehicleDamaged) addEventHandler("onMapStarting", getRootElement(), mapStarted) addEventHandler("onRaceStateChanging", getRootElement(), stateChanged)
  2. I'd like to ask for help, I have this text in the left bottom corner mapdisplay = dxText:create('#aeaeaeMap: none', 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/0.5, false, 'bankgothic', 0.7, 'left'), nextdisplay = dxText:create('#aeaeaeNext map: none', 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/1, false, 'bankgothic', 0.7, 'left') And I'd like to add some black outline to this text, how do I make it?
  3. Hey, I'm using race_nos2 script (https://community.multitheftauto.com/index.php?p= ... ls&id=2133) on my DD server but I want to change one thing. How do I change it so the default gauge visibility is set to off? I'm using another script for nitro bar so that's why I want to change it. If someone could help I'd be grateful.
  4. Hi, this is my rankingboard RankingBoard = {} RankingBoard.__index = RankingBoard RankingBoard.clientInstances = {} function RankingBoard:create() local result = { id = #RankingBoard.clientInstances + 1, items = {} } RankingBoard.clientInstances[result.id] = true clientCall(g_Root, 'RankingBoard.create', result.id) result.joinHandler = function() result:playerJoined(source) end addEventHandler('onPlayerJoin', getRootElement(), result.joinHandler) return setmetatable(result, self) end function RankingBoard:clientCall(player, fn, ...) clientCall(player, 'RankingBoard.call', self.id, fn, ...) end local savedplrcount = 1 function RankingBoard:setDirection(direction, plrcount) savedplrcount = plrcount if direction == 'up' or direction == 'down' then self.direction = direction self:clientCall(g_Root, 'setDirection', direction, plrcount ) end end function RankingBoard:add(player, time) local playerName = getPlayerName(player) if table.find(self.items, 'name', playerName) then return end table.insert(self.items, { name = playerName, time = time }) self:clientCall(g_Root, 'add', playerName, time) end function RankingBoard:playerJoined(player) clientCall(player, 'RankingBoard.create', self.id) if self.direction then self:clientCall(player, 'setDirection', self.direction, savedplrcount ) end self:clientCall(player, 'addMultiple', self.items) end function RankingBoard:clear() self:clientCall(g_Root, 'clear') self.items = {} end function RankingBoard:destroy() self:clientCall(g_Root, 'destroy') removeEventHandler('onPlayerJoin', getRootElement(), self.joinHandler) RankingBoard.clientInstances[self.id] = nil end and my rankingboard_client RankingBoard = {} RankingBoard.__index = RankingBoard RankingBoard.instances = {} local screenWidth, screenHeight = guiGetScreenSize() local topDistance = 250 local bottomDistance = 0.23*screenHeight local posLeftDistance = 30 local nameLeftDistance = 60 local labelHeight = 20 local maxPositions = math.floor((screenHeight - topDistance - bottomDistance)/labelHeight) function RankingBoard.create(id) RankingBoard.instances[id] = setmetatable({ id = id, direction = 'down', labels = {}, position = 0 }, RankingBoard) end function RankingBoard.call(id, fn, ...) RankingBoard[fn](RankingBoard.instances[id], ...) end function RankingBoard:setDirection(direction,plrcount) self.direction = direction if direction == 'up' then self.highestPos = plrcount self.position = self.highestPos + 1 end end function RankingBoard:add(name, time) local position local y local doBoardScroll = false if self.direction == 'down' then self.position = self.position + 1 if self.position > maxPositions then return end y = topDistance + (self.position-1)*labelHeight elseif self.direction == 'up' then self.position = self.position - 1 local labelPosition = self.position if self.highestPos > maxPositions then labelPosition = labelPosition - (self.highestPos - maxPositions) if labelPosition < 1 then labelPosition = 0 doBoardScroll = true end elseif labelPosition < 1 then return end y = topDistance + (labelPosition-1)*labelHeight end local posLabel, posLabelShadow = createShadowedLabelFromSpare(posLeftDistance, y, 20, labelHeight, tostring(self.position) .. ')', 'right') if time then if not self.firsttime then self.firsttime = time time = ': ' .. msToTimeStr(time) else time = ': +' .. msToTimeStr(time - self.firsttime) end else time = '' end local realName = name local theplayer = nil for _,ppp in ipairs(getElementsByType("player")) do if getPlayerName(ppp) == name then realName = _getPlayerName(ppp) theplayer = ppp local team = getPlayerTeam(ppp) if team then local r,g,b = getTeamColor(team) realName = RGBToHex(r,g,b)..realName end end end local playerLabel, playerLabelShadow = createShadowedLabelFromSpare(nameLeftDistance, y, 250, labelHeight, realName .. "#FFFFFF" .. time) setElementData( playerLabel, "spectatorLabel", theplayer ) table.insert(self.labels, posLabel) table.insert(self.labels, posLabelShadow) table.insert(self.labels, playerLabel) table.insert(self.labels, playerLabelShadow) playSoundFrontEnd(7) if doBoardScroll then guiSetAlpha(posLabel, 0) guiSetAlpha(posLabelShadow, 0) guiSetAlpha(playerLabel, 0) guiSetAlpha(playerLabelShadow, 0) local anim = Animation.createNamed('race.boardscroll', self) anim:addPhase({ from = 0, to = 1, time = 700, fn = RankingBoard.scroll, firstLabel = posLabel }) anim:addPhase({ fn = RankingBoard.destroyLastLabel, firstLabel = posLabel }) anim:play() end end function RankingBoard:scroll(param, phase) local firstLabelIndex = table.find(self.labels, phase.firstLabel) for i=firstLabelIndex,firstLabelIndex+3 do guiSetAlpha(self.labels[i], param) end local x, y for i=0,#self.labels/4-1 do for j=1,4 do x = (j <= 2 and posLeftDistance or nameLeftDistance) y = topDistance + ((maxPositions - i - 1) + param)*labelHeight if j % 2 == 0 then x = x + 1 y = y + 1 end guiSetPosition(self.labels[i*4+j], x, y, false) end end for i=1,4 do guiSetAlpha(self.labels[i], 1 - param) end end function RankingBoard:destroyLastLabel(phase) for i=1,4 do destroyElementToSpare(self.labels[1]) table.remove(self.labels, 1) end local firstLabelIndex = table.find(self.labels, phase.firstLabel) for i=firstLabelIndex,firstLabelIndex+3 do guiSetAlpha(self.labels[i], 1) end end function RankingBoard:addMultiple(items) for i,item in ipairs(items) do self:add(item.name, item.time) end end function RankingBoard:clear() table.each(self.labels, destroyElementToSpare) self.labels = {} end function RankingBoard:destroy() self:clear() RankingBoard.instances[self.id] = nil end -- -- Label cache -- local spareElems = {} local donePrecreate = false function RankingBoard.precreateLabels(count) donePrecreate = false while #spareElems/4 < count do local label, shadow = createShadowedLabel(10, 1, 20, 10, 'a' ) destroyElementToSpare(label) destroyElementToSpare(shadow) end donePrecreate = true end function destroyElementToSpare(elem) table.insertUnique( spareElems, elem ) guiSetVisible(elem, false) end function createShadowedLabelFromSpare(x, y, width, height, text, align) if #spareElems < 2 then if not donePrecreate then outputDebug( 'OPTIMIZATION', 'createShadowedLabel' ) end return createShadowedLabel(x, y, width, height, text, align) else local shadow = table.popLast( spareElems ) guiSetSize(shadow, width, height, false) --guiSetText(shadow, text) --guiLabelSetColor(shadow, 0, 0, 0) guiSetPosition(shadow, x + 1, y + 1, false) guiSetVisible(shadow, true) local label = table.popLast( spareElems ) guiSetSize(label, width, height, false) --guiSetText(label, text) setElementData( label, "dxlabel", text ) --guiLabelSetColor(label, 255, 255, 255) guiSetPosition(label, x, y, false) guiSetVisible(label, true) if align then guiLabelSetHorizontalAlign(shadow, align) guiLabelSetHorizontalAlign(label, align) else guiLabelSetHorizontalAlign(shadow, 'left') guiLabelSetHorizontalAlign(label, 'left') end return label, shadow end end This is how it looks in game: How do I edit this so the space between position and nickname is smaller and it displays the first 9 positions as 01-09 instead of 1-9?
  5. Hey - I'm making DD server and I have one question. How do I make it so it plays sounds at the end of every round?
  6. Hi, this is chat infobot I own -- wiadomosci local messages = { "Check out our forum - #fbaf17", "Type #ff5000/nos nfs #ffff00for NFS Nos, or #ff5000/nos normal #ffff00for Normal NOS", } local r,g,b = 255,255,0 -- default color; #ffff00 local stime = 210 -- time in seconds setTimer( function() local msg = messages[math.random(1,#messages)] outputChatBox( msg, getRootElement(), r, g, b, true ) end, stime*1000,0 ) This is how it works, it shows messages randomly How do I make it so it works like this?
  7. Hi, I'm making a server and I have a question, how do I turn those things off?
  8. Witam, jak w nazwie tematu, poszukuję osoby która potrafiłaby napisać kilka skryptów do serwera Destruction Derby. Jeśli ktoś jest zainteresowany i chciałby poznać szczegóły to prosiłbym o kontakt na skype: taquito.pl lub steam http://steamcommunity.com/id/t4quito
  9. Nie używając panelu, tylko komendy? Weźmy taki przykład: /mute nick powód 3600 - to mute na godzinę, a czas jest podany w sekundach. I teraz pytanie - czy idzie inaczej wpisać mutowanie na x minut, x godzin, x dni, czy można tylko sekundami?
  10. I want to reset all of my statistics. I want to be like new player on the server. Is it possible?
  11. I'd like to make a "new start" on some server (server doesn't require registration). Is it possible to reset my points without reinstalling my operating system? If it is: how?
  12. Witam, czy jest możliwość wyzerowania swoich punktów na danym serwerze (lub we wszystkich serwerach), bez potrzeby reinstalowania windowsa?
×
×
  • Create New...