Jump to content

Little Problem


wesseb

Recommended Posts

Hi! I'm have problem. I'm make script for MTA Racemod and look this.

I must have script to give player money for win DD or DM

_root = getRootElement()
addEventHandler("onPlayerFinish",_root,
function (rank,time)
if not (isGuestAccount (getPlayerAccount (source))) then
local playerAccount = getPlayerAccount(source)
local playerMoney = getAccountData(playerAccount,"VIPM-Money")
if (playerMoney) and (playerAccount) then
local alivePlayer = getAlivePlayers()
if (alivePlayer == 1) then
outputChatBox("#aa00ff<Script>:#ffffff " .. getPlayerName(source) .. " won 1000$ for 1st!!",_root,255,255,255,true)
setAccountData (playerAccount, "VIPM-Money", playerMoney +1000)
end
end
end
end)

thanks for help and sorry for my bad english

Link to comment

problem is that at beginig noone got that account data, heres it fixed

_root = getRootElement()
addEventHandler("onPlayerFinish",_root,
function (rank,time)
if not (isGuestAccount (getPlayerAccount (source))) then
local playerAccount = getPlayerAccount(source)
local playerMoney = getAccountData(playerAccount,"VIPM-Money")
if (playerAccount) then
local alivePlayer = getAlivePlayers()
if (alivePlayer == 1) then
outputChatBox("#aa00ff<Script>:#ffffff " .. getPlayerName(source) .. " won 1000$ for 1st!!",_root,255,255,255,true)
setAccountData (playerAccount, "VIPM-Money", playerMoney +1000)
end
end
end
end)

Link to comment

please look this code

addEventHandler("onElementDataChange",_root,
function (theName,theOldValue)
if (theName == "race.finish") then --and (getElementType (source) == "player") then
--    if not (isGuestAccount (getPlayerAccount (source))) then
local playerAccount = getPlayerAccount(source)
local playerMoney = getAccountData(playerAccount,"VIPM-Money")
if (playerMoney) and (playerAccount) then
if (getElementData (source,"race rank") == 1) then
local playerCount = getPlayerCount ()
local winningMoney = playerCount *50
local allMoney = playerMoney + winningMoney
outputChatBox("#aa00ff<Script>:#ffffff " .. getPlayerName(source) .. " won " .. tostring (winningMoney) .. "$ for 1st!!",_root,255,255,255,true)
setAccountData (playerAccount, "VIPM-Money", allMoney)
end
end
--    else
--      ouptutChatBox ("#aa00ff<Script>:#ffffff " .. getPlayerName(source) .. " won NOTHING because he is not logged in.")
--    end
end
end)

Link to comment
_root = getRootElement()
addEvent("onPlayerFinish",true)
addEventHandler("onPlayerFinish",_root,
function (rank,time)
if not (isGuestAccount (getPlayerAccount (source))) then
local playerAccount = getPlayerAccount(source)
local playerMoney = getAccountData(playerAccount,"VIPM-Money")
if (playerAccount) then
local alivePlayer = getAlivePlayers()
if (alivePlayer == 1) then
outputChatBox("#aa00ff<Script>:#ffffff " .. getPlayerName(source) .. " won 1000$ for 1st!!",_root,255,255,255,true)
setAccountData (playerAccount, "VIPM-Money", playerMoney +1000)
end
end
end
end)

is easyer and fine too

Link to comment

no errors?

try this:

_root = getRootElement()
addEvent("onPlayerFinish",true)
addEventHandler("onPlayerFinish",_root,
function (rank,time)
if not (isGuestAccount (getPlayerAccount (source))) then
local playerAccount = getPlayerAccount(source)
local playerMoney = getAccountData(playerAccount,"VIPM-Money")
if (playerAccount) then
local alivePlayer = getAlivePlayers()
if (alivePlayer == 1) then
outputChatBox("#aa00ff<Script>:#ffffff " .. getPlayerName(source) .. " won 1000$ for 1st!!",_root,255,255,255,true)
if playerMoney then money=playerMoney+1000 else money=1000 end
setAccountData (playerAccount, "VIPM-Money", money )
end
end
end
end)

Edited by Guest
Link to comment

Make sure you're logged in.

Furthermore, you can keep on guessing like this, but finding it will take longer than trying to win the jackpot in the lottery. I suggest you to debug your script. It will make us help you.

Also, don't just say things like "don't work", because we can't do anything with that. We're not psychic, and we shouldn't have to run your code at our own servers either. Just telling us in what way it doesn't work, any of the conditions or whatever helps a lot.

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