Kutlu35 Posted August 1, 2017 Share Posted August 1, 2017 Hey dear forum users , i got pio's koth map and resource but it doesn't works. Client: -- resource root local resourceRoot = getResourceRootElement() local rootElement = getRootElement() -- variables local KOTHPoints = 0 local screenWidth, screenHeight = guiGetScreenSize() -- function: addKOTHPoint function addKOTHPoint(player) KOTHPoints = KOTHPoints+1 end addEvent("onPlayerScoreKOTHPoint", true) addEventHandler("onPlayerScoreKOTHPoint", resourceRoot, addKOTHPoint) -- displaying player points function displayKOTHPoints() dxDrawText(KOTHPoints, screenWidth*12/13+3, screenHeight*6/7-2, screenWidth*0.99+3, screenHeight, tocolor(0, 0, 0, 255), 4, "arial", "right") dxDrawText(KOTHPoints, screenWidth*12/13, screenHeight*6/7, screenWidth*0.99, screenHeight, tocolor(240, 240, 0, 255), 4, "arial", "right") dxDrawText("Points", screenWidth*12/13+3, screenHeight*6/7+38, screenWidth*0.99+3, screenHeight, tocolor(0, 0, 0, 255), 2.4, "arial", "right") dxDrawText("Points", screenWidth*12/13, screenHeight*6/7+40, screenWidth*0.99, screenHeight, tocolor(240, 240, 0, 255), 2.4, "arial", "right") end addEventHandler("onClientRender", rootElement, displayKOTHPoints) -- remove points display after game addEventHandler("onClientResourceStop", resourceRoot, function() removeEventHandler("onClientRender", rootElement, displayKOTHPoints) end) -- show results at the end function showResults(source, resultTable) local results = 15 if #resultTable < 15 then results = #resultTable end function displayResults() for i=1,results do local text = i.." "..getPlayerName(resultTable[i][1]).." ("..resultTable[i][2].." points)" dxDrawText(text, screenWidth/13+1, screenHeight/4-1+i*17, screenWidth, screenHeight, tocolor(0, 0, 0, 255)) dxDrawText(text, screenWidth/13, screenHeight/4+i*17, screenWidth, screenHeight, tocolor(255, 255, 255, 255)) end end addEventHandler("onClientRender", rootElement, displayResults) setTimer(function() removeEventHandler("onClientRender", rootElement, displayResults) end, 15000, 1) end addEvent("onKOTHEnd", true) addEventHandler("onKOTHEnd", resourceRoot, showResults) Server: local playersAmount = #getDeadPlayers() + #getAlivePlayers() -- settings local pointingTime = (5000/playersAmount)+200*(playersAmount/(playersAmount+21)) local hillPoints = math.floor(playersAmount*1.5) +2 -- resource root local resourceRoot = getResourceRootElement() local rootElement = getRootElement() -- hill element local hills = getElementsByType("hill") -- event: onHillDestroy addEvent("onHillDestroy") addEventHandler("onHillDestroy", resourceRoot, function() hillBlip = getElementData(source, "hillblip") destroyElement(hillBlip) destroyElement(source) end) -- points reset function resetKOTHPoints(player) setElementData(player, "checkpoint", 0) setElementData(player, "race rank", "") end function resetPlayersKOTHPoints() local players = getElementsByType("player") for k, player in ipairs(players) do resetKOTHPoints(player) end end addEventHandler("onResourceStart", resourceRoot, resetPlayersKOTHPoints) addEventHandler("onPlayerJoin", resourceRoot, resetKOTHPoints) -- points granting function startTakingPoints(theElement) if (getElementType(theElement) == "player") then pointingTimer = setTimer(function(source) if (source ~= nil) then if (isElementWithinMarker(theElement, source)) then playerKOTHPoints = getElementData(theElement, "checkpoint") markerPoints = getElementData(source, "checkpoint") setElementData(theElement, "checkpoint", playerKOTHPoints+1) setElementData(source, "checkpoint", markerPoints-1) triggerClientEvent(theElement, "onPlayerScoreKOTHPoint", resourceRoot, theElement) if (markerPoints <= 1) then triggerEvent("onHillDestroy", source) end else if (pointingTimer ~= nil) then killTimer(pointingTimer) end end else killTimer(pointingTimer) end end, pointingTime, hillPoints, source) function stopScoring() if (isTimer(pointingTimer)) then killTimer(pointingTimer) removeEventHandler("onHillDestroy", resourceRoot, stopScoring) end end addEventHandler("onHillDestroy", resourceRoot, stopScoring) end end -- function: createHill function createHill(posX, posY, posZ, size, points) theHill = createMarker(posX, posY, posZ+1, "corona", size, 240, 240, 0) hillBlip = createBlipAttachedTo(theHill, 56) setElementData(theHill, "checkpoint", points) setElementData(theHill, "hillblip", hillBlip) addEventHandler("onMarkerHit", theHill, startTakingPoints) end -- initializing KOTH mode function startKOTH() call(getResourceFromName("Scoreboard"), "scoreboardAddColumn", "checkpoint") function placeNewHill() newHill = hills[math.random(1, table.getn(hills))] local posX = getElementData(newHill, "posX") local posY = getElementData(newHill, "posY") local posZ = getElementData(newHill, "posZ") createHill(posX, posY, posZ, 5, hillPoints) end addEventHandler("onHillDestroy", resourceRoot, placeNewHill) placeNewHill() end addEventHandler("onResourceStart", resourceRoot, startKOTH) -- clearing after the game function removeAnything() --call(getResourceFromName("Scoreboard"), "scoreboardRemoveColumn", "checkpoint") end addEventHandler("onResourceStop", resourceRoot, removeAnything) -- creating a result table function checkForResults() local players = getElementsByType("player") local sorted = {} local i = 1 for k, player in ipairs(players) do local points = getElementData(player, "checkpoint") sorted[i] = {player, points} for j=i-1,1,-1 do if (sorted[i][2] > sorted[j][2]) then sorted[j+1] = sorted[j] sorted[j] = {player, points} else break end end i = i+1 end for i=table.getn(sorted),2,-1 do --setPlayerIsFinished(sorted[i], true) --call(getResourceFromName("Race"), "setPlayerIsFinished", theElement) triggerEvent("onPlayerFinishDD", sorted[i][1], i) killPed(sorted[i][1]) end triggerEvent("onPlayerWinDD", sorted[1][1]) triggerClientEvent("onKOTHEnd", resourceRoot, sorted[1][1], sorted) end addEvent("onPostFinish", true) addEventHandler("onPostFinish", rootElement, checkForResults) Error at client line 44: atttempt to perform aritmethic on global 'playerKOTHPoints' <a string value> can anyone help me ? Link to comment
Kutlu35 Posted August 1, 2017 Author Share Posted August 1, 2017 i need help guys , why nobody answers ? Hey it's working now 1 Link to comment
Oussema Posted August 2, 2017 Share Posted August 2, 2017 4 hours ago, Kutlu35 said: i need help guys , why nobody answers ? Hey it's working now you said : Error at client line 44: atttempt to perform aritmethic on global 'playerKOTHPoints' <a string value> but at line 44 : addEventHandler("onClientRender", rootElement, displayResults) don't give us worng line :v 1 Link to comment
Mr.Loki Posted August 2, 2017 Share Posted August 2, 2017 (edited) setElementData(theElement, "checkpoint", playerKOTHPoints+1 or 1) Try that. Edited August 2, 2017 by Mr.Loki 1 Link to comment
Kutlu35 Posted August 2, 2017 Author Share Posted August 2, 2017 12 hours ago, Oussema said: you said : Error at client line 44: atttempt to perform aritmethic on global 'playerKOTHPoints' <a string value> but at line 44 : addEventHandler("onClientRender", rootElement, displayResults) don't give us worng line :v Awh sorry and it bugged again 8 hours ago, Mr.Loki said: setElementData(theElement, "checkpoint", playerKOTHPoints+1 or 1) Try that. Thanks loki now im trying 8 hours ago, Mr.Loki said: setElementData(theElement, "checkpoint", playerKOTHPoints+1 or 1) Try that. Hmm , i do that but it's intresting , not working. That script sometimes working sometimes doesn't woking. Error: server:line44: attempt to perform arithmetic on global 'playerKOTHPoints' <a string value> Link to comment
Mr.Loki Posted August 2, 2017 Share Posted August 2, 2017 setElementData(theElement, "checkpoint", (tonumber(playerKOTHPoints) and playerKOTHPoints+1 or 1)) ok try this instead 1 Link to comment
Kutlu35 Posted August 2, 2017 Author Share Posted August 2, 2017 1 hour ago, Mr.Loki said: setElementData(theElement, "checkpoint", (tonumber(playerKOTHPoints) and playerKOTHPoints+1 or 1)) ok try this instead Hey thanks about it i'll try but i fix the problem. Script starts with 'destruction derby' race mode. I change race mode to 'freeroam' race mode and fixed. I'll try this for fix code. Thanks again. And vehicle turf wars looks soo cool 1 1 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