Jump to content

Qfury

Members
  • Posts

    5
  • Joined

  • Last visited

Qfury's Achievements

Vic

Vic (3/54)

0

Reputation

  1. hi i need help^^ i use this script to generate points for Players in a DM race. now i want to save the collectet points in a mysql database but i dont know how. can you help me please? Pointscript: addEvent("onPlayerWasted") function player_Wasted() for i,v in ipairs(getElementsByType('player')) do local rank = exports.race:getPlayerRank(player) if(rank == 2) then givePlayerMoney(v, 1500) outputChatBox('Rank 2:' .. getPlayerName(v).. '') end if(rank == 1) then givePlayerMoney(v, 1500) outputChatBox('Rank 1:' .. getPlayerName(v).. '') end end end addEventHandler("onPlayerWasted", getRootElement(), player_Wasted) function playerCount ( ) local dead = getPlayerCount() if (dead == 1) then outputChatBox('1st dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+1) end if (dead == 2) then outputChatBox('2nd dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+1) end if (dead == 3) then outputChatBox('3rd dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+2) end if (dead == 4) then outputChatBox('4th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+3) end if (dead == 5) then outputChatBox('5th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+4) end if (dead == 6) then outputChatBox('6th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+5) end if (dead == 7) then outputChatBox('7th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+6) end if (dead == -- s8) --> then outputChatBox('8th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+7) end if (dead == 9) then outputChatBox('9th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+8) end if (dead == 10) then outputChatBox('10th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+9) end if (dead == 11) then outputChatBox('11th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+10) end if (dead == 12) then outputChatBox('12th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+11) end if (dead == 13) then outputChatBox('13th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+12) end if (dead == 14) then outputChatBox('14th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+13) end if (dead == 15) then outputChatBox('15th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+14) end if (dead == 16) then outputChatBox('16th dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+15) end end addEventHandler("onPlayerWasted", getRootElement(), playerCount) addEventHandler("onPlayerQuit", getRootElement(), function() local playeraccount = getPlayerAccount(source) if playeraccount then local Points = getElementData(source, "Points") if Points then setAccountData(playeraccount, "Points", Points) end end end ) addEventHandler("onPlayerLogin", getRootElement(), function() local playeraccount = getPlayerAccount(source) if playeraccount then local Points = getAccountData(playeraccount, "Points") if Points then setElementData(source, "Points", Points) end end end )
  2. ok i think i got it. addEvent("onPlayerWasted") function player_Wasted() for i,v in ipairs(getElementsByType('player')) do local rank = exports.race:getPlayerRank(player) if(rank == 2) then givePlayerMoney(v, 1500) outputChatBox('Rank 2:' .. getPlayerName(v).. '') end if(rank == 1) then givePlayerMoney(v, 1500) outputChatBox('Rank 1:' .. getPlayerName(v).. '') end end end addEventHandler("onPlayerWasted", getRootElement(), player_Wasted) function playerCount ( ) outputChatBox ( "There are now " .. getPlayerCount() .. " players dead" ) local dead = getPlayerCount() if (dead == 1) then outputChatBox('1st dead') setElementData(source,"Points",tonumber(getElementData(source,"Points"))+1) end end addEventHandler("onPlayerWasted", getRootElement(), playerCount) now the Players get counted when they dying. So i can add many ifs up to 32 Ranks where the last one gets the most Points. But when you have some tips than please post it.
  3. i added this line above "if(rank == 2) then" local dead = getDeadPlayers() if (dead == 1) then outputChatBox('1st dead:' .. getPlayerName(v).. '') end i was hoping the server is posting that in chat but it doesn't. Why?
  4. its useless right? im using a new code: addEvent("onPlayerWasted") function player_Wasted() for i,v in ipairs(getElementsByType('player')) do local rank = exports.race:getPlayerRank(player) if(rank == 2) then givePlayerMoney(v, 1500) outputChatBox('Rank 2:' .. getPlayerName(v).. '') end if(rank == 1) then givePlayerMoney(v, 1500) outputChatBox('Rank 1:' .. getPlayerName(v).. '') end end end addEventHandler("onPlayerWasted", getRootElement(), player_Wasted) now i need to add getAlivePlayers and the server need to count how many players we have an need to know that the 1st guy who dies is the last rank and get no Points and the 2nd guy who dies gets 1 Point the 3rd guy who dies 2 Points and so on. Anyone that knows how i can get this?
  5. Hi, i need help with this script. I will that the 1st guy that dies get 0 Points and the 2nd 1 Point the 3rd 2 Points and so on I saw already many script snippets but they didn't help me. So thats what i already have: Client: localPlayer = getLocalPlayer() function addColumns() exports.scoreboard:scoreboardAddColumn("Points") exports.scoreboard:scoreboardAddColumn("Race Wins") exports.scoreboard:scoreboardAddColumn("Race Loses") setElementData(localPlayer,"Points",0) setElementData(localPlayer,"Race Loses",0) setElementData(localPlayer,"Race Wins",0) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), addColumns) Server: local rootElement = getRootElement() addEventHandler("onPlayerWasted",rootElement, function () setElementData(source,"Race Loses",tonumber(getElementData(source,"Race Loses"))+1) setElementData(source,"Points",tonumber(getElementData(source,"Points"))+1) local serial = getPlayerSerial(source) local oldData = executeSQLSelect( "RaceStats", "RaceLoses","serial = '" .. serial .. "'") newData = tonumber(oldData[1]["RaceWins"]) + 1 executeSQLUpdate ( "RaceStats", "RaceLoses = '"..newData.."'","serial = '" .. serial .. "'") end) As you can see all players get 1 Point when they lose. What do i need to add that the 1st loser gets 0 Points the 2nd 1 Point the 3rd 2 Points and so on?
×
×
  • Create New...