gytisan Posted February 10, 2012 Share Posted February 10, 2012 (edited) call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Race Wins") function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) local wins = getAccountData( account,"Race Wins" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Wins", wins + 1 ) end local playername = getPlayerName( alivePlayers[1] ) outputChatBox ( "#FFA824The player " .. playername .. " won!", root, 255, 255, 255, true ) end end addEventHandler( "onPlayerWasted", root,DestructionWin) addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) local loses = getAccountData( account,"Race Loses" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Loses", loses + 1 ) end end ) function updateRatio (thePlayer) local account = getPlayerAccount( theplayer ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 if loses == 0 then setAccountData(account, "ratio", "-") else local kdr = round( wins / loses, 2) setAccountData(account, "ratio", kdr) end end end function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or N/A if loses and wins then outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. askdname .. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) elseif message == "!st" then triggerEvent( "stats", source ) cancelEvent( ) end end end addEventHandler( "onPlayerChat", root, checkCommand ) function getPlayerFromNamePart(Name) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end restriction = {} addCommandHandler("stats", function (thePlayer, cmd, whoToCheck) local playerName = getPlayerName(thePlayer) if restriction[playerName] then outputChatBox("#FFA824You have to wait 30 seconds", thePlayer, 255, 0, 0, true) else restriction[playerName] = true setTimer(restrictionEnd, 30000, 1, playerName) local player = getPlayerFromNamePart( whoToCheck ) if (player) then local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 ratio = (tonumber(wins)/tonumber(loses))*10 or N/A outputChatBox("#FFA824*[sTATS] Player's "..tostring(player).." stats : " , root, 255, 12, 15, true) if wins then outputChatBox("#FFA824*Wins: "..tostring(wins).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Wins: 0 !" , root, 255, 12, 15, true) end if loses then outputChatBox("#FFA824*Loses: "..tostring(loses).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Loses: 0 !", root, 255, 12, 15, true) end if ratio then outputChatBox("#FFA824*Ratio: "..tostring(ratio).."% !", root, 255, 12, 15, true) else outputChatBox("#FFA824*Ratio: - %", root, 255, 12, 15, true) end end else outputChatBox( "Player not found!" ) end end end) function restrictionEnd(playerName) restriction[playerName] = nil end See This Code ? Its for DM race win count The script adds Race Wins in Scoreboard but when player win race Dont count always 0 I need to make when player win ads 1 inscoreboard And Server or Client Side use it ? Edited February 10, 2012 by Guest Link to comment
Evil-Cod3r Posted February 10, 2012 Share Posted February 10, 2012 call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Race Wins") function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) local wins = getAccountData( account,"Race Wins" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Wins", wins + 1 ) end local playername = getPlayerName( alivePlayers[1] ) outputChatBox ( "#FFA824The player " .. playername .. " won!", root, 255, 255, 255, true ) end end addEventHandler( "onPlayerWasted", root,DestructionWin) addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) local loses = getAccountData( account,"Race Loses" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Loses", loses + 1 ) end end ) function updateRatio (thePlayer) local account = getPlayerAccount( theplayer ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 if loses == 0 then setAccountData(account, "ratio", "-") else local kdr = round( wins / loses, 2) setAccountData(account, "ratio", kdr) end end end function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or N/A if loses and wins then outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. askdname .. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) elseif message == "!st" then triggerEvent( "stats", source ) cancelEvent( ) end end end addEventHandler( "onPlayerChat", root, checkCommand ) function getPlayerFromNamePart(Name) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end restriction = {} addCommandHandler("stats", function (thePlayer, cmd, whoToCheck) local playerName = getPlayerName(thePlayer) if restriction[playerName] then outputChatBox("#FFA824You have to wait 30 seconds", thePlayer, 255, 0, 0, true) else restriction[playerName] = true setTimer(restrictionEnd, 30000, 1, playerName) local player = getPlayerFromNamePart( whoToCheck ) if (player) then local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 ratio = (tonumber(wins)/tonumber(loses))*10 or N/A outputChatBox("#FFA824*[sTATS] Player's "..tostring(player).." stats : " , root, 255, 12, 15, true) if wins then outputChatBox("#FFA824*Wins: "..tostring(wins).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Wins: 0 !" , root, 255, 12, 15, true) end if loses then outputChatBox("#FFA824*Loses: "..tostring(loses).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Loses: 0 !", root, 255, 12, 15, true) end if ratio then outputChatBox("#FFA824*Ratio: "..tostring(ratio).."% !", root, 255, 12, 15, true) else outputChatBox("#FFA824*Ratio: - %", root, 255, 12, 15, true) end end else outputChatBox( "Player not found!" ) end end end) function restrictionEnd(playerName) restriction[playerName] = nil end Link to comment
gytisan Posted February 10, 2012 Author Share Posted February 10, 2012 call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Race Wins") function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) local wins = getAccountData( account,"Race Wins" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Wins", wins + 1 ) end local playername = getPlayerName( alivePlayers[1] ) outputChatBox ( "#FFA824The player " .. playername .. " won!", root, 255, 255, 255, true ) end end addEventHandler( "onPlayerWasted", root,DestructionWin) addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) local loses = getAccountData( account,"Race Loses" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Loses", loses + 1 ) end end ) function updateRatio (thePlayer) local account = getPlayerAccount( theplayer ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 if loses == 0 then setAccountData(account, "ratio", "-") else local kdr = round( wins / loses, 2) setAccountData(account, "ratio", kdr) end end end function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or N/A if loses and wins then outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. askdname .. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) elseif message == "!st" then triggerEvent( "stats", source ) cancelEvent( ) end end end addEventHandler( "onPlayerChat", root, checkCommand ) function getPlayerFromNamePart(Name) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end restriction = {} addCommandHandler("stats", function (thePlayer, cmd, whoToCheck) local playerName = getPlayerName(thePlayer) if restriction[playerName] then outputChatBox("#FFA824You have to wait 30 seconds", thePlayer, 255, 0, 0, true) else restriction[playerName] = true setTimer(restrictionEnd, 30000, 1, playerName) local player = getPlayerFromNamePart( whoToCheck ) if (player) then local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 ratio = (tonumber(wins)/tonumber(loses))*10 or N/A outputChatBox("#FFA824*[sTATS] Player's "..tostring(player).." stats : " , root, 255, 12, 15, true) if wins then outputChatBox("#FFA824*Wins: "..tostring(wins).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Wins: 0 !" , root, 255, 12, 15, true) end if loses then outputChatBox("#FFA824*Loses: "..tostring(loses).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Loses: 0 !", root, 255, 12, 15, true) end if ratio then outputChatBox("#FFA824*Ratio: "..tostring(ratio).."% !", root, 255, 12, 15, true) else outputChatBox("#FFA824*Ratio: - %", root, 255, 12, 15, true) end end else outputChatBox( "Player not found!" ) end end end) function restrictionEnd(playerName) restriction[playerName] = nil end in meta.xml Server Side or Client ? Link to comment
MR.S3D Posted February 10, 2012 Share Posted February 10, 2012 (edited) call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Race Wins") function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) local wins = getAccountData( account,"Race Wins" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Wins", wins + 1 ) end local playername = getPlayerName( alivePlayers[1] ) outputChatBox ( "#FFA824The player " .. playername .. " won!", root, 255, 255, 255, true ) end end addEventHandler( "onPlayerWasted", root,DestructionWin) server side -- s:) --> addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) local loses = getAccountData( account,"Race Loses" ) or 0 if account then if isGuestAccount( account ) then return end setAccountData( account,"Race Loses", loses + 1 ) end end ) function updateRatio (thePlayer) local account = getPlayerAccount( theplayer ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 if loses == 0 then setAccountData(account, "ratio", "-") else local kdr = round( wins / loses, 2) setAccountData(account, "ratio", kdr) end end end function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or N/A if loses and wins then outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. askdname .. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) elseif message == "!st" then triggerEvent( "stats", source ) cancelEvent( ) end end end addEventHandler( "onPlayerChat", root, checkCommand ) function getPlayerFromNamePart(Name) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end restriction = {} addCommandHandler("stats", function (thePlayer, cmd, whoToCheck) local playerName = getPlayerName(thePlayer) if restriction[playerName] then outputChatBox("#FFA824You have to wait 30 seconds", thePlayer, 255, 0, 0, true) else restriction[playerName] = true setTimer(restrictionEnd, 30000, 1, playerName) local player = getPlayerFromNamePart( whoToCheck ) if (player) then local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 ratio = (tonumber(wins)/tonumber(loses))*10 or N/A outputChatBox("#FFA824*[sTATS] Player's "..tostring(player).." stats : " , root, 255, 12, 15, true) if wins then outputChatBox("#FFA824*Wins: "..tostring(wins).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Wins: 0 !" , root, 255, 12, 15, true) end if loses then outputChatBox("#FFA824*Loses: "..tostring(loses).."!", root, 255, 12, 15, true) else outputChatBox("#FFA824*Loses: 0 !", root, 255, 12, 15, true) end if ratio then outputChatBox("#FFA824*Ratio: "..tostring(ratio).."% !", root, 255, 12, 15, true) else outputChatBox("#FFA824*Ratio: - %", root, 255, 12, 15, true) end end else outputChatBox( "Player not found!" ) end end end) function restrictionEnd(playerName) restriction[playerName] = nil end in meta.xml Server Side or Client ? 'server side Edited February 10, 2012 by Guest 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