myyusuf Posted March 4, 2012 Share Posted March 4, 2012 Hello scripters, i just found this awesome scrores script. i have an idea but idk it can be possible. local root = getRootElement() local scoresRoot = getResourceRootElement(getThisResource()) local scoreboard = getResourceFromName("scoreboard") local scoreColumns = {"kills", "deaths", "self", "ratio", "status"} local isColumnActive = {} local KDR_DECIMAL_PLACES = 2 --http://lua-users.org/wiki/SimpleRound local function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end local function setScoreData (element, column, data) if isColumnActive[column] then setElementData(element, column, data) end end local function resetScores (element) setScoreData(element, "kills", 0) setScoreData(element, "deaths", 0) setScoreData(element, "self", 0) setScoreData(element, "ratio", "-") local status = "" if isPedDead(element) then status = "Dead" end setScoreData(element, "status", status) end local function updateRatio (element) local deaths = getElementData(element, "deaths") if deaths == 0 then setScoreData(element, "ratio", "-") else local kdr = round(getElementData(element, "kills") / deaths, KDR_DECIMAL_PLACES) setScoreData(element, "ratio", tostring(kdr)) end end function updateActiveColumns () for i, column in ipairs(scoreColumns) do if get(column) then isColumnActive[column] = true call(scoreboard, "addScoreboardColumn", column) elseif isColumnActive[column] then isColumnActive[column] = false call(scoreboard, "removeScoreboardColumn", column) end end end addEventHandler("onResourceStart", scoresRoot, function () updateActiveColumns() for i, player in ipairs(getElementsByType("player")) do resetScores(player) end end ) addEventHandler("onResourceStop", scoresRoot, function () for i, column in ipairs(scoreColumns) do if isColumnActive[column] then call(scoreboard, "removeScoreboardColumn", column) end end end ) addEventHandler("onPlayerJoin", root, function () resetScores(source) end ) addEventHandler("onPlayerWasted", root, function (ammo, killer, weapon) if killer then if killer ~= source then -- killer killed victim setScoreData(killer, "kills", getElementData(killer, "kills") + 1) setScoreData(source, "deaths", getElementData(source, "deaths") + 1) if isColumnActive["ratio"] then updateRatio(killer) updateRatio(source) end else -- victim killed himself setScoreData(source, "self", getElementData(source, "self") + 1) end else -- victim died setScoreData(source, "deaths", getElementData(source, "deaths") + 1) if isColumnActive["ratio"] then updateRatio(source) end end setScoreData(source, "status", "Dead") end ) addEventHandler("onPlayerSpawn", root, function () setScoreData(source, "status", "") end ) addCommandHandler("score", function (player) if player then for i, column in ipairs(scoreColumns) do if column == "status" then break end if isColumnActive[column] then call(scoreboard, "addScoreboardColumn", column) outputConsole(column .. ": " .. getElementData(player, column), player) end end end end ) - "erorr404,jbeta" version="1.0.0" description="Basic scores" /> resource="scoreboard" /> this is working for play mode. killer fuction is for play mode. is that posible to make that for Destruction Derby (race mode). i search a little bit wiki, but i cant find any fuction about that. so is that possible? if its can you give me some fuction about that? thanks for now Link to comment
Castillo Posted March 4, 2012 Share Posted March 4, 2012 You have to check when a player dies if alive players left are 1 and then that's the winner. Link to comment
myyusuf Posted March 4, 2012 Author Share Posted March 4, 2012 You have to check when a player dies if alive players left are 1 and then that's the winner. i found some client script about that. local vehModel = nil local screen_x, screen_y = guiGetScreenSize() local font = "bankgothic" local scale = screen_x / 1000 local message = "" local messWidth = 1 local messHeight = 1 setElementData(getLocalPlayer(), "Kills", 0, true) setElementData(getLocalPlayer(), "Deaths", 0, true) addEventHandler("onClientRender", getRootElement(), function() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) if(vehicle == false)then return end if(getElementModel(vehicle) ~= vehModel)then vehModel = getElementModel(vehicle) local minX, minY, minZ, maxX, maxY, maxZ = getElementBoundingBox(vehicle) local pMinX, pMinY, pMinZ, pMaxX, pMaxY, pMaxZ = math.sqrt(minX^2), math.sqrt(minY^2), math.sqrt(minZ^2), math.sqrt(maxX^2), math.sqrt(maxY^2), math.sqrt(maxZ^2) minY = minY*1.2 maxY = maxY*1.2 --triggerServerEvent("onPlayerBoundingBoxChecked", getLocalPlayer(), math.sqrt(minY^2+maxY^2), -math.sqrt((pMinX-maxX)^2), -math.sqrt((pMinY-maxY)^2)) triggerServerEvent("onPlayerBoundingBoxChecked", getLocalPlayer(), math.sqrt(minY^2+maxY^2), 0, 0) end end) addEvent("showDeathMess", true) addEventHandler("showDeathMess", getRootElement(), function(theKiller) if(source ~= getLocalPlayer())then return end addEventHandler("onClientRender", getRootElement(), kill) message = "Killed by: "..theKiller messWidth = dxGetTextWidth(message, scale, font) messHeight = dxGetFontHeight(scale, font) setTimer(function() removeEventHandler("onClientRender", getRootElement(), kill) end, 5000, 1) end) function kill() dxDrawText(message, screen_x/2 - messWidth/2, screen_y/2 - messHeight/2, screen_x, screen_y, tocolor(255, 0, 0, 150), scale, font) end maybe i can use that function. function() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) if(vehicle == false)then return end if(getElementModel(vehicle) ~= vehModel)then vehModel = getElementModel(vehicle) Link to comment
Castillo Posted March 4, 2012 Share Posted March 4, 2012 addEvent("onPlayerRaceWasted",true) addEventHandler("onPlayerRaceWasted",root, function () if (#getAlivePlayers() <= 1) then outputChatBox(getPlayerName(source) .." has won this map!",root,0,255,0) end end ) Link to comment
myyusuf Posted March 5, 2012 Author Share Posted March 5, 2012 addEvent("onPlayerRaceWasted",true) addEventHandler("onPlayerRaceWasted",root, function () if (#getAlivePlayers() <= 1) then outputChatBox(getPlayerName(source) .." has won this map!",root,0,255,0) end end ) you dont understand me man. i will explain myself with a example. ex: a player pushes b player to sea, and b player died. after a player kill stats will +1 and b player death stats will +1. and on b players screen will write "Killed: a player". Kills and deaths will shown on scoreboard. im sorry for my fucking english. i hope you understand me this time. if you can make that i can pay you some on paypal. Link to comment
Castillo Posted March 5, 2012 Share Posted March 5, 2012 I don't even know if that would be possible, if it is, it may be hard to achieve, as you can't really know who killed him. Link to comment
myyusuf Posted March 6, 2012 Author Share Posted March 6, 2012 I don't even know if that would be possible, if it is, it may be hard to achieve, as you can't really know who killed him. it is possible. last day i was see at GMC DD server. maybe you can see the script how works. im ready to pay who can make this script! Link to comment
myyusuf Posted March 6, 2012 Author Share Posted March 6, 2012 a player pushes b player to sea, and b player died. after a player kill stats will +1 and b player death stats will +1. and on b players screen will write "Killed by: a player". Kills, deaths and wins stats will shown on scoreboard. there must have user.xml for saved user datas. here is the ex type of users.xml. "xxx" nick="nick" kills="155" deaths="15" wins="140" /> there must have to see stats cmd, reset stats and set stats command /stats /resetst /setst and sorry i cant explain this with my english. i hope you understand Link to comment
Ludo Posted March 6, 2012 Share Posted March 6, 2012 What do you mean? Do you want to know who knocked off another one to the sea? Link to comment
myyusuf Posted March 6, 2012 Author Share Posted March 6, 2012 What do you mean? Do you want to know who knocked off another one to the sea? yes. and who push another player to sea he will get +1 kill point. and died player will get +1 death point. and on dead players screen will write "you killed by: xxx" Link to comment
Ludo Posted March 6, 2012 Share Posted March 6, 2012 yes. and who push another player to sea he will get +1 kill point. and died player will get +1 death point. and on dead players screen will write "you killed by: xxx" Ok the problem isn't to add scores, but to know who killed someone, because I don' t know if it is possible to do. Anyway now I' m going to search some function for that, but I can' t say i will find anything. I' ll let you know. Link to comment
myyusuf Posted March 6, 2012 Author Share Posted March 6, 2012 yes. and who push another player to sea he will get +1 kill point. and died player will get +1 death point. and on dead players screen will write "you killed by: xxx" Ok the problem isn't to add scores, but to know who killed someone, because I don' t know if it is possible to do. Anyway now I' m going to search some function for that, but I can' t say i will find anything. I' ll let you know. if you can visit the GMC DD server, you will see the similiar script that i want. so it is possible. i hope you can do. Link to comment
sora+ Posted March 7, 2012 Share Posted March 7, 2012 maybe try getting the vehicles' last collision before being pushed to sea with another vehicle? onClientVehicleCollision other wise maybe you can get each vehicle by id, make a colsphere around it. Once the player pushes the other to sea mta will detect the colsphere and fetch you the id and name of the player.. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now