Jump to content

what is the problem here


[UCG]Mike

Recommended Posts

Posted

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 
) 

Posted
  
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) 
  

Posted
  
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

9hjKOxv.png

any fix here ?

Posted

--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 
) 
Posted
--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']

Posted
--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 ) 

Posted (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 by Guest
Posted

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?

Posted

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 (?)

Posted
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

Posted
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 :D??

Posted
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) 

Posted
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...