wesseb Posted March 14, 2010 Share Posted March 14, 2010 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
karlis Posted March 14, 2010 Share Posted March 14, 2010 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
wesseb Posted March 14, 2010 Author Share Posted March 14, 2010 don't work ;/ i think onPlayerFinish is not good Link to comment
karlis Posted March 14, 2010 Share Posted March 14, 2010 use addEvent("onPlayerFinish",true) too Link to comment
wesseb Posted March 14, 2010 Author Share Posted March 14, 2010 in raceMod is event onPlayerFinish Link to comment
karlis Posted March 14, 2010 Share Posted March 14, 2010 you still need use addEvent, watch race wiki Link to comment
karlis Posted March 14, 2010 Share Posted March 14, 2010 ==Events for version 0.8.3== '''Note:''' You may have to add the events in your script using addEvent() if you want to use them. Link to comment
wesseb Posted March 14, 2010 Author Share Posted March 14, 2010 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
karlis Posted March 14, 2010 Share Posted March 14, 2010 _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
wesseb Posted March 14, 2010 Author Share Posted March 14, 2010 don't work i don't know why... Link to comment
karlis Posted March 14, 2010 Share Posted March 14, 2010 (edited) 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 March 14, 2010 by Guest Link to comment
wesseb Posted March 14, 2010 Author Share Posted March 14, 2010 don't work again... and no errors Link to comment
Gamesnert Posted March 14, 2010 Share Posted March 14, 2010 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
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