[UCG]Mike Posted August 3, 2014 Posted August 3, 2014 what is the problem here ??? exports.scoreboard:addScoreboardColumn('Score') addEventHandler("onPlayerWasted", root, function(attacker,attackerweapon) if (getElementData(attacker, "Score") == false) or (getElementData(attacker, "Score") == nil) then setElementData(attacker, "Score", 1) setElementData(source, "Score", -1) else setElementData( attacker, "Score", getElementData(attacker,"Score")+1) setElementData( source, "Score", getElementData(source,"Score")-1) end )
Addlibs Posted August 3, 2014 Posted August 3, 2014 exports.scoreboard:addScoreboardColumn('Score') addEventHandler("onPlayerWasted", root, function(attacker,attackerweapon) local sScore = getElementData(source, "Score") or 0 local aScore = getElementData(attacker, "Score") or 0 setElementData(source, "Score", sScore-1) setElementData(attacker, "Score", aScore+1) end)
[UCG]Mike Posted August 3, 2014 Author Posted August 3, 2014 exports.scoreboard:addScoreboardColumn('Score') addEventHandler("onPlayerWasted", root, function(attacker,attackerweapon) local sScore = getElementData(source, "Score") or 0 local aScore = getElementData(attacker, "Score") or 0 setElementData(source, "Score", sScore-1) setElementData(attacker, "Score", aScore+1) end) ty but see this errors any fix here ?
Et-win Posted August 3, 2014 Posted August 3, 2014 Why making 2 topics? Your script already has been fixed by me on your other one. viewtopic.php?f=108&t=78639 Learn to be patient.
Addlibs Posted August 3, 2014 Posted August 3, 2014 addEventHandler("onPlayerWasted", root, function(ammo,attacker,attackerweapon)
[UCG]Mike Posted August 3, 2014 Author Posted August 3, 2014 addEventHandler("onPlayerWasted", root, function(ammo,attacker,attackerweapon) errors dont fixed
Max+ Posted August 3, 2014 Posted August 3, 2014 --ServerSide exports.scoreboard:addScoreboardColumn('Score') addEventHandler ( 'onPlayerWasted', root, function ( attacker ) if ( attacker ) and ( attacker ~= source ) then local sScore = getElementData(source, 'Score') or 0 local aScore = getElementData(attacker, 'Score') or 0 setElementData(source, 'Score', sScore -1) setElementData(attacker, 'Score', aScore +1) end end )
[UCG]Mike Posted August 3, 2014 Author Posted August 3, 2014 --ServerSide exports.scoreboard:addScoreboardColumn('Score') addEventHandler ( 'onPlayerWasted', root, function ( attacker ) if ( attacker ) and ( attacker ~= source ) then local sScore = getElementData(source, 'Score') or 0 local aScore = getElementData(attacker, 'Score') or 0 setElementData(source, 'Score', sScore -1) setElementData(attacker, 'Score', aScore +1) end end ) WARNING: Score\server.lua:8: Bad argument @ 'setElementData' [Expected element at argument 1, got number '1']
Addlibs Posted August 3, 2014 Posted August 3, 2014 --ServerSide exports.scoreboard:addScoreboardColumn('Score') addEventHandler ( 'onPlayerWasted', root, function ( attacker ) if ( attacker ) and ( attacker ~= source ) then local sScore = getElementData(source, 'Score') or 0 local aScore = getElementData(attacker, 'Score') or 0 setElementData(source, 'Score', sScore -1) setElementData(attacker, 'Score', aScore +1) end end ) Wrong - first parameter of onPlayerWasted is the totalAmmo (int) - Thats why line 8 says it gets an integer '1' instead of the attacker. Line 3: Change function ( attacker ) to function ( ammo, attacker )
Max+ Posted August 3, 2014 Posted August 3, 2014 there is not point of adding ammo to the script Change it to function ( _, attacker )
Et-win Posted August 3, 2014 Posted August 3, 2014 I just wanted to ask, whenever you put ammo on 'ammo', 'ajfhjdfhjjhkgf' or '_', it's all the same?
Addlibs Posted August 3, 2014 Posted August 3, 2014 (edited) Just defines the variable you'd use, if you put 'HelloWorld', You'd have to use outputChatBox(HelloWorld) to get it to output whatever was in the place of the parameter... eg: --Version 1: addEventHandler("onPlayerWasted", root, function(ammo) outptuChatBox("Ammo: "..ammo, root, 255, 255, 255, false) end) --Version 2: addEventHandler("onPlayerWasted", root, function(HelloWorld) outptuChatBox("Ammo: "..HelloWorld, root, 255, 255, 255, false) end) --They work exactly the same Edited August 3, 2014 by Guest
Et-win Posted August 3, 2014 Posted August 3, 2014 I know, but he says "there is not point of adding ammo to the script". So, why does changing 'ammo' to '_' in the function matter? I would think it doesn't matter a thing, because '_' is a variable now too?
Addlibs Posted August 3, 2014 Posted August 3, 2014 Yeah, that's what I think - maybe it's just for the purpose of "ignoring" it, cause if you don't see what is the actual variable about, you won't use it (?)
[UCG]Mike Posted August 3, 2014 Author Posted August 3, 2014 exports.scoreboard:addScoreboardColumn('Score') addEventHandler ( 'onPlayerWasted', root, function ( attacker ) if ( attacker ) and ( attacker ~= source ) then local sScore = getElementData(source, 'Score') or 0 local aScore = getElementData(attacker, 'Score') or 0 setElementData(source, 'Score', sScore -1) setElementData(attacker, 'Score', aScore +1) end end ) function myscore ( thePlayer ) outputChatBox("Your score is"..getElementData..(source, 'Score'), thePlayer, 0, 255, 0) end addCommandHandler("myscore", myscore) any fix plzz
Et-win Posted August 3, 2014 Posted August 3, 2014 tostring() getElementData will return a number, use tostring on it.
[UCG]Mike Posted August 3, 2014 Author Posted August 3, 2014 tostring() getElementData will return a number, use tostring on it. im not a scripter if you can fix it
Et-win Posted August 3, 2014 Posted August 3, 2014 So... Then learn... tostring(getElementData(yourstuff))
[UCG]Mike Posted August 4, 2014 Author Posted August 4, 2014 exports.scoreboard:addScoreboardColumn('Score') addEventHandler ( 'onPlayerWasted', root, function ( attacker ) if ( attacker ) and ( attacker ~= source ) then local sScore = getElementData(source, 'Score') or 0 local aScore = getElementData(attacker, 'Score') or 0 setElementData(source, 'Score', sScore -1) setElementData(attacker, 'Score', aScore +1) end end ) function myscore ( thePlayer ) outputChatBox("Your score is" tostring(getElementData('Score')), thePlayer, 0, 255, 0) end addCommandHandler("myscore", myscore) Right ??
TAPL Posted August 4, 2014 Posted August 4, 2014 exports.scoreboard:addScoreboardColumn("Score") addEventHandler("onPlayerWasted", root, function(_, attacker) if (attacker and getElementType(attacker) == "player") and (attacker ~= source) then local sScore = getElementData(source, "Score") or 0 local aScore = getElementData(attacker, "Score") or 0 setElementData(source, "Score", sScore-1) setElementData(attacker, "Score", aScore+1) end end) function myscore(player) local MyScore = getElementData(player, "Score") or 0 outputChatBox("Your score is "..tostring(MyScore), player, 0, 255, 0) end addCommandHandler("myscore", myscore)
[UCG]Mike Posted August 4, 2014 Author Posted August 4, 2014 exports.scoreboard:addScoreboardColumn("Score") addEventHandler("onPlayerWasted", root, function(_, attacker) if (attacker and getElementType(attacker) == "player") and (attacker ~= source) then local sScore = getElementData(source, "Score") or 0 local aScore = getElementData(attacker, "Score") or 0 setElementData(source, "Score", sScore-1) setElementData(attacker, "Score", aScore+1) end end) function myscore(player) local MyScore = getElementData(player, "Score") or 0 outputChatBox("Your score is "..tostring(MyScore), player, 0, 255, 0) end addCommandHandler("myscore", myscore) ty bro its fixed now
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