Dex Posted July 27, 2012 Share Posted July 27, 2012 I have a problem with pointsystem. what happens is that when a player enters the server, the player wins. And the player in the first place, not it wins the points and the money. *this script is not made by me, I just want to help me solve the problem - server.lua function checkWinAndIfWinGiveWinCash () local rank = getAliveCount() local allAlivePlayers = getAlivePlayers() local player = allAlivePlayers[1] local playeracc = getPlayerAccount(player) local playerCount = getPlayerCount() local pointsToWin = playerCount *37 local cashToWin = playerCount *187 local money = getPlayerMoney(player) local woncash = money + cashToWin if not isGuestAccount(playeracc) then if (rank == 1) then savePlayerData (player,"points",loadPlayerData(player,"points") + pointsToWin) setPlayerMoney(player, woncash) outputChatBox ("#ff0000* #ffffff" .. getPlayerName(player) .." #ffffffis wins #ff0000" .. tostring(pointsToWin) .." #ffffffpoints and #ff0000" .. tostring(cashToWin) .. "$",getRootElement(),255,0,0,true) end end if isGuestAccount(playeracc) then if (rank == 1) then outputChatBox ("#ffaa00* #ffffff"..getPlayerName(player)..clor.." #ff000should log in to earn money and points",getRootElement(),255,0,0,true) end end end addEventHandler ("onPlayerWasted",getRootElement(),checkWinAndIfWinGiveWinCash) addEventHandler ("onPlayerRaceWasted",getRootElement(), function() killPed (source) setElementHealth (source,0) if (isPedInVehicle(source)) then blowVehicle (getPedOccupiedVehicle(source)) end end) function findPlayerByName (playerPart) for i,v in ipairs (getElementsByType ("player")) do if (string.find(getPlayerName(v),playerPart)) then return v end end end function getDeadCount () deadAmount = 0 for i,v in ipairs (getDeadPlayers()) do deadAmount = deadAmount +1 end return deadAmount end function getSpawnedCount () spawnedAmount = 0 for i,v in ipairs (getAlivePlayers()) do if (isPedInVehicle (v)) then spawnedAmount = spawnedAmount +1 end end return spawnedAmount end function getAliveCount () aliveAmount = 0 for i,v in ipairs (getAlivePlayers()) do aliveAmount = aliveAmount +1 end return aliveAmount end Link to comment
Castillo Posted July 27, 2012 Share Posted July 27, 2012 Lemme try to understand: When a player joins the game, he'll win the points/money, which is wrong, and when all players die and one is alive, that one won't get anything? 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