Jump to content

points problem


Albinix

Recommended Posts

If a player i want him to win some points :)

but this don't work :/

debug line 2 "attempt to call global 'getAlivePlayers' (a nil value)"

function winpoints () 
  local rank = getAliveplayers() 
  if rank == "1" then 
    local allAlivePlayers = getAlivePlayers( ) 
    local player = allAlivePlayers[1] 
    local playerCount = getPlayerCount() 
    local pointsToWin = playerCount *5 
    setElementData(player, "Points", getElementData(player, "points") + pointsToWin) 
    outputChatBox (getPlayerName(player) .." #FF0000is the final survivor!! He wins " .. tostring(pointsToWin) .." points!",getRootElement(),0,255,0,true)       
  end 
end 
addEventHandler ("onPlayerWasted",getRootElement(),winpoints) 
addEventHandler ("onPlayerQuit",getRootElement(),winpoints) 

Link to comment

Looking from what you have posted, it looks to be okay. I would check for typos in the function name you are trying to call. Honestly I can't really nail the problem because it appears that this is only a portion of the script you are working on. You might want to use tonumber on the part where you set the element data though, looks like you are trying to do math on a string.

Link to comment

@Vercetti1010: If you don't know how to help - don't try, because you are confusing people.. Error is clearly visible with that error message.

as MiniGoveya said - there is no such function as getAlivePlayers() -- race gamemode have one, and if you want to use it - you have to copy it (with all other related parts of code) - or just add your code into race resource.

Link to comment

Now it's no error but nothing happends when 1 player win

function winpoints(mapInfo,mapOptions,gameOptions) 
local alivePlayers = getAlivePlayers() 
if info == "Destruction derby" then  
   if #alivePlayers == 1 then  
    local allAlivePlayers = getAlivePlayers() 
    local player = allAlivePlayers[1] 
    local playerCount = getPlayerCount() 
    local pointsToWin = playerCount *5 
    setElementData(player, "Points", getElementData(player, "points") + pointsToWin) 
    outputChatBox (getPlayerName(player) .." #FF0000is the final survivor!! He wins " .. tostring(pointsToWin) .." points!",getRootElement(),0,255,0,true)       
  end 
end 
end 
addEventHandler ("onPlayerWasted",getRootElement(),winpoints) 
addEventHandler ("onPlayerQuit",getRootElement(),winpoints) 
  
addEventHandler( 'onPlayerLogin', root, 
  function() 
  local getp = getAccountData ( getPlayerAccount ( source ), "xss.points" ) 
  setElementData(source, "Points", getp) 
  end 
) 
  
addEventHandler( 'onPlayerQuit', root, 
  function() 
  local setp = getElementData(source, "Points") 
  setAccountData ( getPlayerAccount ( source ), "xss.points", setp ) 
  end 
) 
  
addEventHandler("onResourceStart", 
getResourceRootElement(getThisResource()), 
function() 
    exports.scoreboard:addScoreboardColumn("Points") 
end) 

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