Jump to content

Need help with cash/stats script


Bleidex

Recommended Posts

This script gives money to the winner and gives cash to players buy their rank, but it wont add cash. I had this script version vith givePlayerMoney and ect and it worked, when i changed to this one it wont work. need some help ;/

function givePrize_Quit() 
local activePlayers = getAlivePlayers() 
local playeraccount = getPlayerAccount(activePlayers[1]) 
local pRank = #activePlayers+1 
local playerMoney = getAccountData ( playeraccount, "pig.money" ) 
local cashToWin1 = 500 
local cashToWin2 = 1000 
local cashToWin3 = 1500 
if activePlayers then 
if(getPlayerCount() > 2) then 
if #activePlayers == 1 then 
if not(isGuestAccount(getPlayerAccount(activePlayers[1]))) then 
--addwins 
if(getPlayerCount() < 10) then 
setAccountData ( playeraccount, "pig.money", playerMoney + cashToWin1) 
setElementData ( activePlayers[1], "pig.money", playerMoney + cashToWin1) 
outputChatBox("You've got 500$!", activePlayers[1], 255, 255, 255) 
elseif(getPlayerCount() < 20) then 
setAccountData ( playeraccount, "pig.money", playerMoney + cashToWin2) 
setElementData ( activePlayers[1], "pig.money", playerMoney + cashToWin2) 
outputChatBox("You've got 1000$!", activePlayers[1], 255, 255, 255) 
else 
setAccountData ( playeraccount, "pig.money", playerMoney + cashToWin3) 
setElementData ( activePlayers[1], "pig.money", playerMoney + cashToWin3) 
outputChatBox("You've got 1500$!", activePlayers[1], 255, 255, 255) 
end 
end 
end 
if not(isGuestAccount(getPlayerAccount(source))) then 
--addlooses 
end 
end 
end 
end 
  
function givePrize_Wasted(totalAmmo, killer, killerWeapon, bodypart) 
local activePlayers = getAlivePlayers() 
local pRank = #activePlayers 
local playeraccount = getPlayerAccount(activePlayers[1]) 
local playerMoney = getAccountData ( playeraccount, "pig.money" ) 
local cashToWin1 = 500 
local cashToWin2 = 1000 
local cashToWin3 = 1500 
local playerGive1 = math.ceil(500/pRank) 
local playerGive2 = math.ceil(1000/pRank) 
local playerGive3 = math.ceil(1500/pRank) 
if not activePlayers then return end --If winner dead, then don't continue 
if(getPlayerCount() < 3) then 
outputChatBox("There are not enough players for stats! (Minimum: 3)", source, 255, 100, 0, false) 
return 
end 
if #activePlayers == 1 then 
if not(isGuestAccount(getPlayerAccount(activePlayers[1]))) then 
--addwins 
if(getPlayerCount() < 10) then 
setAccountData ( playeraccount, "pig.money", playerMoney + cashToWin1) 
setElementData ( activePlayers[1], "pig.money", playerMoney + cashToWin1) 
outputChatBox("You've got 500$!", activePlayers[1], 255, 255, 255) 
elseif(getPlayerCount() < 20) then 
setAccountData ( playeraccount, "pig.money", playerMoney + cashToWin2) 
setElementData ( activePlayers[1], "pig.money", playerMoney + cashToWin2) 
outputChatBox("You've got 1000$!", activePlayers[1], 255, 255, 255) 
else 
setAccountData ( playeraccount, "pig.money", playerMoney + cashToWin3) 
setElementData ( activePlayers[1], "pig.money", playerMoney + cashToWin3) 
outputChatBox("You've got 1500$!", activePlayers[1], 255, 255, 255) 
end 
end 
end 
if not(isGuestAccount(getPlayerAccount(source))) then 
--addlooses 
local playerMoney = getAccountData ( playeraccount, "pig.money" ) 
if(getPlayerCount() < 10) then 
setAccountData ( playeraccount, "pig.money", playerMoney + playerGive1) 
setElementData ( activePlayers[1], "pig.money", playerMoney + playerGive1) 
outputChatBox("You've got " ..playerGive1.. "$.", source, 255, 255, 255) 
elseif(getPlayerCount() < 20) then 
setAccountData ( playeraccount, "pig.money", playerMoney + playerGive2) 
setElementData ( activePlayers[1], "pig.money", playerMoney + playerGive2) 
outputChatBox("You've got " ..playerGive2.. "$.", source, 255, 255, 255) 
else 
setAccountData ( playeraccount, "pig.money", playerMoney + playerGive3) 
setElementData ( activePlayers[1], "pig.money", playerMoney + playerGive3) 
outputChatBox("You've got " ..playerGive3.. "$.", source, 255, 255, 255) 
end 
end 
end 
  
addEventHandler("onPlayerQuit", getRootElement(), givePrize_Quit) 
--addEvent("onPlayerRaceWasted") 
addEventHandler("onPlayerWasted", getRootElement(), givePrize_Wasted) 

/cash code:

function checkMoney1(thePlayer, command) 
 local playeraccount = getPlayerAccount(thePlayer) 
 local money = getAccountData(playeraccount,"pig.money")                                                                               
  outputChatBox("You have: "..tostring(money), root, getRootElement(), 255, 255, 255, true) 
end 
addCommandHandler("cash1", checkMoney1) 

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