#Paper Posted April 30, 2011 Posted April 30, 2011 In the debugscript there isn't any error... And the stat doesn't set in the scoreboard... function addStat(thePlayer, theStat, theValue) local getActualPoints = getElementData(thePlayer, "Points") local getActualCash = getElementData(thePlayer, "Cash") if theStat == cash then setElementData(thePlayer, "Cash", getActualCash + theValue) elseif theStat == points then setElementData(thePlayer, "Points", getActualPoints + theValue) end end function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local cash = players * 7 addStat(thePlayer, points, points) addStat(thePlayer, cash, cash) end My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Kenix Posted April 30, 2011 Posted April 30, 2011 In the debugscript there isn't any error...And the stat doesn't set in the scoreboard... function addStat(thePlayer, theStat, theValue) local getActualPoints = getElementData(thePlayer, "Points") local getActualCash = getElementData(thePlayer, "Cash") if theStat == cash then setElementData(thePlayer, "Cash", getActualCash + theValue) elseif theStat == points then setElementData(thePlayer, "Points", getActualPoints + theValue) end end function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local cash = players * 7 addStat(thePlayer, points, points) addStat(thePlayer, cash, cash) end may be this? function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local cash = players * 7 addStat(source, points, points) addStat(source, cash, cash) end http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
#Paper Posted April 30, 2011 Author Posted April 30, 2011 In the debugscript there isn't any error...And the stat doesn't set in the scoreboard... function addStat(thePlayer, theStat, theValue) local getActualPoints = getElementData(thePlayer, "Points") local getActualCash = getElementData(thePlayer, "Cash") if theStat == cash then setElementData(thePlayer, "Cash", getActualCash + theValue) elseif theStat == points then setElementData(thePlayer, "Points", getActualPoints + theValue) end end function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local cash = players * 7 addStat(thePlayer, points, points) addStat(thePlayer, cash, cash) end may be this? function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local cash = players * 7 addStat(source, points, points) addStat(source, cash, cash) end no... the "player" variable is the right... My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Dre-+- Posted April 30, 2011 Posted April 30, 2011 I hope now work) function addStat(thePlayer, theStat, theValue) local getActualPoints = getElementData(thePlayer, "Points") local getActualCash = getElementData(thePlayer, "Cash") if theStat == "Cash" then setElementData(thePlayer, "Cash", getActualCash + theValue) elseif theStat == "Points" then setElementData(thePlayer, "Points", getActualPoints + theValue) end end function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local pointsstat = "Points" local cash = players * 7 local cashstat = "Cash" addStat(thePlayer, pointsstat, points) addStat(thePlayer, cashstat, cash) end or easier: function addStat(thePlayer, theStat, theValue) setElementData(thePlayer, theStat, getElementData(thePlayer,theStat) + theValue) end function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local pointsstat = "Points" local cash = players * 7 local cashstat = "Cash" addStat(thePlayer, pointsstat, points) addStat(thePlayer, cashstat, cash) end Sorry for my bad english(
Castillo Posted April 30, 2011 Posted April 30, 2011 Doesn't make any sense, you are passing 'thePlayer' as player argument, but in your function you are using 'player'. function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local pointsstat = "Points" local cash = players * 7 local cashstat = "Cash" addStat(player, pointsstat, points) addStat(player, cashstat, cash) end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
#Paper Posted April 30, 2011 Author Posted April 30, 2011 Doesn't make any sense, you are passing 'thePlayer' as player argument, but in your function you are using 'player'. function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local pointsstat = "Points" local cash = players * 7 local cashstat = "Cash" addStat(player, pointsstat, points) addStat(player, cashstat, cash) end there aren't any error... but the scoreboard still be to 0... doesn't change My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Castillo Posted April 30, 2011 Posted April 30, 2011 I guess you are using both functions, right? addStat and onPlayerWins. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
#Paper Posted April 30, 2011 Author Posted April 30, 2011 yes... i trigger the onPlayerWins() func by the race gm... and then i trigger the addStat func My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Moderators Citizen Posted May 1, 2011 Moderators Posted May 1, 2011 function addStat(thePlayer, theStat, theValue) local getActualPoints = getElementData(thePlayer, "Points") local getActualCash = getElementData(thePlayer, "Cash") outputChatBox( "addStat: "..getActualPoints..", "..getActualCash) -- test if theStat == "cash" then setElementData(thePlayer, "Cash", getActualCash + theValue) elseif theStat == "points" then setElementData(thePlayer, "Points", getActualPoints + theValue) end outputChatBox( "Current datas: "..getElementData(thePlayer, "Points")..", "..getElementData(thePlayer, "Cash") )-- test end function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local cash = players * 7 outputChatBox( "onPlayerWins: "..players..", "..points..", "..cash )-- test addStat(player, "points", points) addStat(player, "cash", cash) end The rEvolution is coming ...
#Paper Posted May 1, 2011 Author Posted May 1, 2011 function addStat(thePlayer, theStat, theValue) local getActualPoints = getElementData(thePlayer, "Points") local getActualCash = getElementData(thePlayer, "Cash") outputChatBox( "addStat: "..getActualPoints..", "..getActualCash) -- test if theStat == "cash" then setElementData(thePlayer, "Cash", getActualCash + theValue) elseif theStat == "points" then setElementData(thePlayer, "Points", getActualPoints + theValue) end outputChatBox( "Current datas: "..getElementData(thePlayer, "Points")..", "..getElementData(thePlayer, "Cash") )-- test end function onPlayerWins(player) local players = getPlayerCount() local points = players * 1.3 local cash = players * 7 outputChatBox( "onPlayerWins: "..players..", "..points..", "..cash )-- test addStat(player, "points", points) addStat(player, "cash", cash) end Thanks bro! But can you explain why mine version doesn't works? My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Moderators Citizen Posted May 2, 2011 Moderators Posted May 2, 2011 Sure, So here, if theStat == cash then the script want to check if theStat is equal to cash ( not the name cash but the value of this variable ), the variable cash is not defined so cash = nil so the script make that: if theStat == nil then Also, you made: addStat(player, points, points) here, you send 2 times the value of the variable points and theStat receive the 1st variable points ( so a number and not the name cash ) (I'm sorry if you don't understand but I can't explain better why your script can't work , but I can explain why my script works ) The rEvolution is coming ...
#Paper Posted May 2, 2011 Author Posted May 2, 2011 Ohhh, i understand, ty City My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Moderators Citizen Posted May 5, 2011 Moderators Posted May 5, 2011 No problem The rEvolution is coming ...
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