Albinix Posted October 7, 2010 Share Posted October 7, 2010 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
MiniGoveya Posted October 7, 2010 Share Posted October 7, 2010 I think no such any function for 'getAlivePlayers' Link to comment
Vercetti1010 Posted October 7, 2010 Share Posted October 7, 2010 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
dzek (varez) Posted October 7, 2010 Share Posted October 7, 2010 @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
Albinix Posted October 7, 2010 Author Share Posted October 7, 2010 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
dzek (varez) Posted October 7, 2010 Share Posted October 7, 2010 if info == "Destruction derby" then think and debug info is never defined.. 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