wesseb Posted March 14, 2010 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
karlis Posted March 14, 2010 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) [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
wesseb Posted March 14, 2010 Author Posted March 14, 2010 don't work ;/ i think onPlayerFinish is not good
karlis Posted March 14, 2010 Posted March 14, 2010 use addEvent("onPlayerFinish",true) too [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
karlis Posted March 14, 2010 Posted March 14, 2010 you still need use addEvent, watch race wiki [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
karlis Posted March 14, 2010 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. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
wesseb Posted March 14, 2010 Author 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)
karlis Posted March 14, 2010 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 [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
karlis Posted March 14, 2010 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 [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Gamesnert Posted March 14, 2010 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. Projects: Slothbot | Maximap
karlis Posted March 14, 2010 Posted March 14, 2010 i left 1bug there, try now^ [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
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