Admigo Posted February 6, 2012 Share Posted February 6, 2012 Dear Scripters, I want to make when u get the hunter u will get 1000 money. But when i take the hunter i dont get money. And i made a money collum for score board but it dont work. Code Hunter Money: function SToptimesManager:playerFinished( player, newTime, dateRecorded ) -- Check if top time recording is disabled for this player if getElementData ( player, "toptimes" ) == "off" then return end if not self.mapTimes then outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) return end dateRecorded = dateRecorded or getRealDateTimeNowString() local oldTime = self.mapTimes:getTimeForPlayer( player ) -- Can be false if no previous time local newPos = self.mapTimes:getPositionForTime( newTime, dateRecorded ) -- See if time is an improvement for this player if not oldTime or newTime < oldTime then local oldPos = self.mapTimes:getIndexForPlayer( player ) triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) -- See if its in the top display if newPos <= self.displayTopCount then outputChatBox( '#FF6600[TOPTIME]: #FFFFFF' .. getPlayerName(source) .. ' #FFFFFFgot toptime position #FF6600' .. newPos .. ' #FF6600[Time: ' .. SMaptimes:timeMsToTimeText(newTime) .. ']', root, 2, 255, 2, true) givePlayerMoney ( player, 1000 ) end if oldTime then outputDebug( '#FF6600[TOPTIME]: #FFFFFF' .. getPlayerName(source) .. ' #FFFFFFgot toptime position #FF6600' .. newPos .. ' #FF6600[Time: ' .. SMaptimes:timeMsToTimeText(newTime) .. ']', root, 2, 255, 2, true) givePlayerMoney ( player, 1000 ) end self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) -- updateTopText if database was changed if newPos <= self.displayTopCount then self:updateTopText() end end outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) end Code Money Collum Client: addEventHandler("onClientResourceStart",resourceRoot, function () setTimer(updateMoney, 1000, 0) end) function updateMoney() local newMoney = getPlayerMoney ( localPlayer ) if pMoney ~= newMoney then pMoney = newMoney setElementData ( localPlayer, "Money", newMoney ) end end Code Money Collum Server: addEventHandler("onResourceStart",resourceRoot, function() call(getResourceFromName("scoreboard"),"addScoreboardColumn","Money") end ) Pls,how can i fix this problems? Thanks Admigo Link to comment
GanJaRuleZ Posted February 6, 2012 Share Posted February 6, 2012 function someoneReachedHunter(number, sort, model) if sort == "vehiclechange" and model == 425 then outputChatBox ( getPlayerName(source).." #FF6464has gotten the hunter! Run!", getRootElement(), 255, 255, 255, true ) givePlayerMoney ( source , 1000 ) end end addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup",getRootElement(),someoneReachedHunter) Just added an line to scripter 'hunter_alert' From resources Link to comment
Admigo Posted February 6, 2012 Author Share Posted February 6, 2012 Thanks dude,works. Now i need to fix the money collum. When a new map start the collum is empty. Link to comment
GanJaRuleZ Posted February 6, 2012 Share Posted February 6, 2012 local oldMoney = getPlayerMoney() function renderMoney() newMoney = getPlayerMoney() if ( tonumber(newMoney) ~= tonumber(oldMoney) ) then triggerEvent("onClientMoneyChange",localPlayer,oldMoney,newMoney) oldMoney = newMoney end end addEventHandler("onClientRender",root,renderMoney) addEvent("onClientMoneyChange",true) addEventHandler("onClientMoneyChange",root, function (old, new) setElementData ( localPlayer, "Money", new ) end) Modified 1 line , made by solidsnake.. Link to comment
Admigo Posted February 7, 2012 Author Share Posted February 7, 2012 function someoneReachedHunter(number, sort, model) if sort == "vehiclechange" and model == 425 then outputChatBox ( getPlayerName(source).." #FF6464has gotten the hunter! Run!", getRootElement(), 255, 255, 255, true ) givePlayerMoney ( source , 1000 ) end end addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup",getRootElement(),someoneReachedHunter) Just added an line to scripter 'hunter_alert' From resources Works but only one problem,when u stay longer in the hunter pickup u get more money. And the scoreboard: local oldMoney = getPlayerMoney() function renderMoney() newMoney = getPlayerMoney() if ( tonumber(newMoney) ~= tonumber(oldMoney) ) then triggerEvent("onClientMoneyChange",localPlayer,oldMoney,newMoney) oldMoney = newMoney end end addEventHandler("onClientRender",root,renderMoney) addEvent("onClientMoneyChange",true) addEventHandler("onClientMoneyChange",root, function (old, new) setElementData ( localPlayer, "Money", new ) end) When you get the hunter u get money and you see money in the scoreboard but when there comes a new map the money collum is 0 but at admin you see that you have money. How can i fix this pls. Link to comment
GanJaRuleZ Posted February 7, 2012 Share Posted February 7, 2012 addEventHandler('onGamemodeMapStart', root, local money = getPlayerMoney ( localPlayer ) setElementData ( localPlayer, "Money", money ) end) Link to comment
Kenix Posted February 7, 2012 Share Posted February 7, 2012 onGamemodeMapStart is server side event. localPlayer is client side variable. https://wiki.multitheftauto.com/wiki/Pre ... ables_list Link to comment
Admigo Posted February 7, 2012 Author Share Posted February 7, 2012 addEventHandler('onGamemodeMapStart', root, local money = getPlayerMoney ( localPlayer ) setElementData ( localPlayer, "Money", money ) end) I put the code in script now i get spam errors in debuscript NameTags.lua 38:Bad Argument 1# to ipairs (table exptected,got nil) I deleted the code but now i get the error everytime and cant play race gm anymore. I didnt change something in nametag. How to fix it? Link to comment
Admigo Posted February 7, 2012 Author Share Posted February 7, 2012 do /refresh Still not working,i delete the codes i added from this thread but still same problem. i didnt change something in nametag. Link to comment
GanJaRuleZ Posted February 7, 2012 Share Posted February 7, 2012 try /restart nametag , if the error is still appearing , put your code in here.. Link to comment
Admigo Posted February 7, 2012 Author Share Posted February 7, 2012 Its not a resource,its the file in race.zip so the race gm. Link to comment
Admigo Posted February 7, 2012 Author Share Posted February 7, 2012 local oldMoney = getPlayerMoney() function renderMoney() newMoney = getPlayerMoney() if ( tonumber(newMoney) ~= tonumber(oldMoney) ) then triggerEvent("onClientMoneyChange",localPlayer,oldMoney,newMoney) oldMoney = newMoney end end addEventHandler("onClientRender",root,renderMoney) addEvent("onClientMoneyChange",true) addEventHandler("onClientMoneyChange",root, function (old, new) setElementData ( localPlayer, "Money", new ) end) Modified 1 line , made by solidsnake.. Can you send my this code with the new code pls? 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