Jump to content

what is the problem here


[UCG]Mike

Recommended Posts

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 
) 

Link to comment
  
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) 
  

Link to comment
  
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 ?

Link to comment

--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 
) 
Link to comment
--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']

Link to comment
--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 ) 

Link to comment

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
Link to comment
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

Link to comment
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??

Link to comment
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) 

Link to comment
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

Link to comment

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...