codeluaeveryday Posted January 4, 2012 Share Posted January 4, 2012 Hey all, I wrote this within an hour... I realized that the scoreboard columns aren't creating... I haven't ever called a function before... Other than admin panel flags... function addTotalKill(totalAmmo, killer, killerWeapon, bodypart, stealth) local account = getPlayerAccount (killer) if (account) and (killer) then setAccountData(account,"totalkillsdeaths.kills",getAccountData(account,"totalkillsdeaths.kills")+1) setElementData(killer, "Total Kills", getAccountData(account,"totalkillsdeaths.kills")) end end addEventHandler ("onPlayerWasted", getRootElement(), addTotalKill) function addTotalDeath(totalAmmo, killer, killerWeapon, bodypart, stealth) local account = getPlayerAccount (source) if (account) then setAccountData(account,"totalkillsdeaths.Deaths",getAccountData(account,"totalkillsdeaths.Deaths")+1) setElementData(source, "Total Deaths", getAccountData(account,"totalkillsdeaths.Deaths")) end end addEventHandler ("onPlayerWasted", getRootElement(), addTotalKill) function checkAccountKillsDeaths(thePreviousAccount, theCurrentAccount, autoLogin) if (getAccountData(theCurrentAccount,"totalkillsdeaths.kills") == nil) and (getAccountData(theCurrentAccount,"totalkillsdeaths.deaths") == nil) then setAccountData(theCurrentAccount,"totalkillsdeaths.kills",0) setAccountData(theCurrentAccount,"totalkillsdeaths.deaths",0) end end addEventHandler("onPlayerLogin",getRootElement(),checkAccountKillsDeaths) function addScoreboardItems() call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Total Kills",getRootElement(),100,"Total Kills",3) call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Total Deaths",getRootElement(),100,"Total Kills",3) end addEventHandler("onResourceStart",getRootElement(),addScoreboardItems) Thanks in advance, Chris Link to comment
CapY Posted January 4, 2012 Share Posted January 4, 2012 Wrong. scoreboardAddColumn This is actually correct. addScoreboardColumn Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 https://wiki.multitheftauto.com/wiki/Res ... coreboard?! Ok Capy, i guess tis page is wrong too... Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 Capy i tried your thing... function addScoreboardItems() call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Kills",getRootElement(),1, 0.5) call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Deaths",getRootElement(),1, 0.5) end addEventHandler("onResourceStart",getRootElement(),addScoreboardItems) It still not creating columns Link to comment
Kenix Posted January 4, 2012 Share Posted January 4, 2012 (edited) /debugscript 3 not say errors? maybe resource scoreboard not running Check return value call function And you don't need use getRootElement() in event "onResourceStart" you need use resourceRoot Otherwise every start resource add columns to scoreboard Edited January 4, 2012 by Guest Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 /debugscript 3 not say errors?maybe resource scoreboard not running Check return value call function And you don't need use getRootElement() you need use resourceRoot Otherwise every start resource add columns to scoreboard Debug shows nothing, um resource/s are defiantly running and What about return lol? Thanks for the info on resourceRoot. So What do u mean Check return value call function I have never needed to call before in scripts ive made Link to comment
Kenix Posted January 4, 2012 Share Posted January 4, 2012 (edited) function addScoreboardItems( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Kills",root,1, 0.5 ) ) ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Deaths",root,1, 0.5 ) ) ) end addEventHandler( "onResourceStart",resourceRoot,addScoreboardItems ) EDIT:I update upper post please read. EDIT2:In future if you need debug for example client side script read clientscript.log in folder:MTA_FOLDER\MTA\clientscript.log this is rly useful. Edited January 4, 2012 by Guest Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 function addScoreboardItems( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Kills",root,1, 0.5 ) ) ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Deaths",root,1, 0.5 ) ) ) end addEventHandler( "onResourceStart",resourceRoot,addScoreboardItems ) EDIT:I update upper post please read. Oh god nothing at all no debug Is something wrong :S, um, btw my dxscoreboard is named Scoreboard ... Idk whats wrong Link to comment
FatalTerror Posted January 4, 2012 Share Posted January 4, 2012 (edited) Hi, function addTotalKill(totalAmmo, killer, killerWeapon, bodypart, stealth) local account = getPlayerAccount (killer) if (account) and (killer) then setAccountData(account,"totalkillsdeaths.kills",getAccountData(account,"totalkillsdeaths.kills")+1) setElementData(killer, "Total Kills", getAccountData(account,"totalkillsdeaths.kills")) end end addEventHandler ("onPlayerWasted", getRootElement(), addTotalKill) function addTotalDeath(totalAmmo, killer, killerWeapon, bodypart, stealth) local account = getPlayerAccount (source) if (account) then setAccountData(account,"totalkillsdeaths.Deaths",getAccountData(account,"totalkillsdeaths.Deaths")+1) setElementData(source, "Total Deaths", getAccountData(account,"totalkillsdeaths.Deaths")) end end addEventHandler ("onPlayerWasted", getRootElement(), addTotalKill) function checkAccountKillsDeaths(thePreviousAccount, theCurrentAccount, autoLogin) if (getAccountData(theCurrentAccount,"totalkillsdeaths.kills") == nil) and (getAccountData(theCurrentAccount,"totalkillsdeaths.deaths") == nil) then setAccountData(theCurrentAccount,"totalkillsdeaths.kills",0) setAccountData(theCurrentAccount,"totalkillsdeaths.deaths",0) end end addEventHandler("onPlayerLogin",getRootElement(),checkAccountKillsDeaths) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Kills",getRootElement(),1) call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Total Deaths",getRootElement(),2) end) Edited January 4, 2012 by Guest Link to comment
Kenix Posted January 4, 2012 Share Posted January 4, 2012 Named Scoreboard? Remember case sensitive. function addScoreboardItems( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "Total Kills",root,1, 0.5 ) ) ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "Total Deaths",root,1, 0.5 ) ) ) end addEventHandler( "onResourceStart",resourceRoot,addScoreboardItems ) Read my upper post i update. Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 Fatal terror misunderstands... Im not doing a piss easy kill script, cause basemode already has kills and deaths, its just im logging each kill for total kills, and it will show all kills got by that account in scoreboard... Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 , Kenix, still nothing idk, and fatals doesnt work... omgz Whats up with it lol, mta bug? is this the same as deleteResource() bug (i should report that LOL!) So idk... Link to comment
Kenix Posted January 4, 2012 Share Posted January 4, 2012 Maybe problem in meta.xml show please. Link to comment
CapY Posted January 4, 2012 Share Posted January 4, 2012 Chris, Is "addScoreboardColumn" even exported function in scoreboard resource ? Link to comment
Kenix Posted January 4, 2012 Share Posted January 4, 2012 Yes is exported. If he not modified resource. Link to comment
CapY Posted January 4, 2012 Share Posted January 4, 2012 If he not modified resource Because of that i asked. Chris, Is your scoreboard resource even named 'scoreboard' ? Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 (edited) omg, im the biggest retard! I just checked the meta Well now i know it creates the columns. The only thing not working is the kill data. Do you see any issues with it? Ive changed it a bit more: function addTotalKill(totalAmmo, killer, killerWeapon, bodypart, stealth) local account = getPlayerAccount (killer) if (account) and (killer) then setAccountData(account,"totalkillsdeaths.kills",getAccountData(account,"totalkillsdeaths.kills")+1) setElementData(killer, "T/K", getAccountData(account,"totalkillsdeaths.kills")) end end addEventHandler ("onPlayerWasted", getRootElement(), addTotalKill) function addTotalDeath(totalAmmo, killer, killerWeapon, bodypart, stealth) local account = getPlayerAccount (source) if (account) then setAccountData(account,"totalkillsdeaths.Deaths",getAccountData(account,"totalkillsdeaths.deaths")+1) setElementData(source, "T/K", getAccountData(account,"totalkillsdeaths.deaths")+1) end end addEventHandler ("onPlayerWasted", getRootElement(), addTotalDeath) function checkAccountKillsDeaths(thePreviousAccount, theCurrentAccount, autoLogin) if (getAccountData(theCurrentAccount,"totalkillsdeaths.kills") == nil) and (getAccountData(theCurrentAccount,"totalkillsdeaths.deaths") == nil) then setAccountData(theCurrentAccount,"totalkillsdeaths.kills",0) setAccountData(theCurrentAccount,"totalkillsdeaths.deaths",0) end end addEventHandler("onPlayerLogin",getRootElement(),checkAccountKillsDeaths) function addScoreboardItems( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/K",root,2, 0.035 ) ) ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/D",root,3, 0.035 ) ) ) end addEventHandler( "onResourceStart",resourceRoot,addScoreboardItems ) this doesnt work function checkAccountKillsDeaths(thePreviousAccount, theCurrentAccount, autoLogin) if (getAccountData(theCurrentAccount,"totalkillsdeaths.kills") == nil) and (getAccountData(theCurrentAccount,"totalkillsdeaths.deaths") == nil) then setAccountData(theCurrentAccount,"totalkillsdeaths.kills",0) setAccountData(theCurrentAccount,"totalkillsdeaths.deaths",0) end end addEventHandler("onPlayerLogin",getRootElement(),checkAccountKillsDeaths) Ok AFK... Edited January 4, 2012 by Guest Link to comment
Kenix Posted January 4, 2012 Share Posted January 4, 2012 (edited) try: addEventHandler ( "onPlayerWasted", root, function( totalAmmo, killer, killerWeapon, bodypart, stealth ) local account = getPlayerAccount ( killer ) if account and isElement( killer ) then setAccountData( account,"totalkillsdeaths.kills",getAccountData( account,"totalkillsdeaths.kills" )+1 ) setAccountData( account,"totalkillsdeaths.Deaths",getAccountData(account,"totalkillsdeaths.Deaths")+1) setElementData( killer, "T/K", tonumber( getAccountData( account,"totalkillsdeaths.kills" ) or 0 ) ) setElementData( killer, "T/D", tonumber( getAccountData( account,"totalkillsdeaths.Deaths" ) or 0 ) ) end end ) addEventHandler( "onPlayerLogin",root, function( thePreviousAccount, theCurrentAccount, autoLogin ) if not getAccountData( theCurrentAccount,"totalkillsdeaths.kills" ) and not getAccountData( theCurrentAccount,"totalkillsdeaths.deaths" ) then setAccountData( theCurrentAccount,"totalkillsdeaths.kills",0) setAccountData( theCurrentAccount,"totalkillsdeaths.deaths",0) end end ) addEventHandler( "onResourceStart",resourceRoot, function( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/K",root,2, 0.035 ) ) ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/D",root,3, 0.035 ) ) ) end ) EDIT:code updated EDIT2:if not getAccountData return false not nil Edited January 4, 2012 by Guest Link to comment
CapY Posted January 4, 2012 Share Posted January 4, 2012 Chris, Put 'account' instead of 'theCurrentAccount' Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 No ones is working and kenix I think u miss understand...! addEventHandler ( "onPlayerWasted", root, function( totalAmmo, killer, killerWeapon, bodypart, stealth ) local account = getPlayerAccount ( killer ) if account and isElement( killer ) then setAccountData( account,"totalkillsdeaths.kills",getAccountData( account,"totalkillsdeaths.kills" )+1 ) setAccountData( account,"totalkillsdeaths.Deaths",getAccountData(account,"totalkillsdeaths.Deaths")+1) setElementData( killer, "T/K", tonumber( getAccountData( account,"totalkillsdeaths.kills" ) or 0 ) ) setElementData( killer, "T/D", tonumber( getAccountData( account,"totalkillsdeaths.Deaths" ) or 0 ) ) end end ) Its meant to log kills and deaths separately, This adds 1 death and 1 kill. and it doesnt work Link to comment
Kenix Posted January 4, 2012 Share Posted January 4, 2012 (edited) My bad I'm very tired addEventHandler ( "onPlayerWasted", root, function( totalAmmo, killer, killerWeapon, bodypart, stealth ) local account = getPlayerAccount ( killer ) local accountSource = getPlayerAccount ( source ) if killer and killer ~= source then setAccountData( account,"totalkillsdeaths.kills",getAccountData( account,"totalkillsdeaths.kills" )+1 ) setElementData( killer, "T/K", tonumber( getAccountData( account,"totalkillsdeaths.kills" ) ) ) else setAccountData( accountSource,"totalkillsdeaths.Deaths",getAccountData(accountSource,"totalkillsdeaths.Deaths")+1) setElementData( source, "T/D", tonumber( getAccountData( accountSource,"totalkillsdeaths.Deaths" ) ) ) end end ) addEventHandler( "onPlayerLogin",root, function( thePreviousAccount, theCurrentAccount, autoLogin ) if not getAccountData( theCurrentAccount,"totalkillsdeaths.kills" ) and not getAccountData( theCurrentAccount,"totalkillsdeaths.deaths" ) then setAccountData( theCurrentAccount,"totalkillsdeaths.kills",0) setAccountData( theCurrentAccount,"totalkillsdeaths.deaths",0) setElementData( source,"T/D",0 ) setElementData( source,"T/K",0 ) else setElementData( source,"T/D",getAccountData( theCurrentAccount,"totalkillsdeaths.kills" ) ) setElementData( source,"T/K",getAccountData( theCurrentAccount,"totalkillsdeaths.deaths" ) ) end end ) addEventHandler( "onResourceStart",resourceRoot, function( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/K",root,2, 0.035 ) ) ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/D",root,3, 0.035 ) ) ) end ) Edited January 4, 2012 by Guest Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 Almost kenix I keep relogging to get my total kills to 0... But Its not, so i think addEventHandler( "onPlayerLogin",root, function( thePreviousAccount, theCurrentAccount, autoLogin ) if not getAccountData( theCurrentAccount,"totalkillsdeaths.kills" ) and not getAccountData( theCurrentAccount,"totalkillsdeaths.deaths" ) then setAccountData( theCurrentAccount,"totalkillsdeaths.kills",0) setAccountData( theCurrentAccount,"totalkillsdeaths.deaths",0) end end ) function is preventing everything else... Its a theory. Cause nothing is appearing in scoreboard in those columns. Link to comment
Kenix Posted January 4, 2012 Share Posted January 4, 2012 It should work ( tested ) addEventHandler ( "onPlayerWasted", root, function( totalAmmo, killer, killerWeapon, bodypart, stealth ) if killer then local account = getPlayerAccount ( killer ) if killer ~= source then setAccountData( account,"totalkillsdeaths.Kills",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) +1 ) setElementData( killer, "T/K", tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) ) ) end else local accountSource = getPlayerAccount ( source ) setAccountData( accountSource,"totalkillsdeaths.Deaths",tonumber( getAccountData(accountSource,"totalkillsdeaths.Deaths") or 0 ) +1 ) setElementData( source, "T/D", tonumber( getAccountData( accountSource,"totalkillsdeaths.Deaths" ) ) ) end end ) addEventHandler( "onPlayerLogin",root, function( thePreviousAccount, theCurrentAccount, autoLogin ) local account = getPlayerAccount ( source ) if not getAccountData( account,"totalkillsdeaths.Kills" ) and not getAccountData( account,"totalkillsdeaths.Deaths" ) then setAccountData( account,"totalkillsdeaths.Kills",0 ) setAccountData( account,"totalkillsdeaths.Deaths",0 ) end setElementData( source,"T/D",tonumber( getAccountData( account,"totalkillsdeaths.Deaths" ) or 0 ) ) setElementData( source,"T/K",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) ) end ) addEventHandler( "onResourceStart",resourceRoot, function( ) outputDebugString( "add Total Kills to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/K",root,2, 0.035 ) ) ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/D",root,3, 0.035 ) ) ) end ) Link to comment
codeluaeveryday Posted January 4, 2012 Author Share Posted January 4, 2012 THANK YOU KENIX, Thanks alot. Your name will be in Credits, like: Credits: Kenix - For fixing my SUPER buggy script, it meant alot to me. 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