Xwad Posted August 29, 2015 Share Posted August 29, 2015 My script is not working pls help! DEBUGSCRIPT 3: WARNING: moneyS.lua: Bad argumentum @ "givePkayerMoney' [Expected element at argumentum 1,got nil] function rewardTimer() setTimer ( rewardOnRun, 10000, 1 ) givePlayerMoney ( source, 3000 ) end addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) function rewardOnRun() givePlayerMoney ( source, 3000 ) setTimer ( rewardTimer, 10000, 1 ) end Link to comment
AfuSensi Posted August 29, 2015 Share Posted August 29, 2015 Try this: function rewardTimer(player) local player = source or player setTimer ( rewardOnRun, 10000, 1,player ) givePlayerMoney ( player, 3000 ) end addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) function rewardOnRun(player) givePlayerMoney ( player, 3000 ) setTimer ( rewardTimer, 10000, 1,player ) end You did not give any argument to the rewardOnRun() function. This would make it work, although i am not sure what you are trying to do with the code. 1 Link to comment
Xwad Posted August 29, 2015 Author Share Posted August 29, 2015 Its working thanks! The script is for my new terminator gamemode. I will release it soon. You will see what im doing with the code:D Link to comment
Xwad Posted August 29, 2015 Author Share Posted August 29, 2015 one more question. I want to kill the timer if the player die but its not working:/ function rewardTimer(player) local player = source or player local Timer = setTimer ( rewardOnRun, 100, 1,player ) givePlayerMoney ( player, 1 ) end addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) function rewardOnRun(player) givePlayerMoney ( player, 1 ) setTimer ( rewardTimer, 100, 1,player ) end function stopTimer() if isTimer ( Timer ) then killTimer ( Timer ) end end addEventHandler ( "onPlayerWasted", getRootElement(), stopTimer ) Link to comment
Walid Posted August 29, 2015 Share Posted August 29, 2015 Remove local here local Timer = setTimer ( rewardOnRun, 100, 1,player ) Link to comment
Xwad Posted August 29, 2015 Author Share Posted August 29, 2015 This is also working thx! But i have a last last last question i want to make that the timer will only start if the player has skin 201. I made it but its not working:/ What shuld be the problem? function rewardTimer(player) if getElementModel(source) == 201 then local player = source or player Timer = setTimer ( rewardOnRun, 100, 1,player ) givePlayerMoney ( player, 1 ) else cancelEvent() end end addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) Link to comment
Walid Posted August 29, 2015 Share Posted August 29, 2015 This is also working thx! But i have a last last last question i want to make that the timer will only start if the player has skin 201. I made it but its not working:/ What shuld be the problem? Code 1: function rewardTimer() local skinId = getElementModel(source) if not skinId == 201 then return end Timer = setTimer ( rewardOnRun, 100, 1,source ) givePlayerMoney (source, 1000 ) end addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) or function rewardTimer (_,_,_,_,_,skin) if not tonumber(skin) == 201 then return end Timer = setTimer ( rewardOnRun, 100, 1,source ) givePlayerMoney (source, 1000 ) end addEventHandler ( "onPlayerSpawn", getRootElement(),rewardTimer) Link to comment
Xwad Posted August 29, 2015 Author Share Posted August 29, 2015 if i use this code then the timer is not working:/ so i edited the script like this: but then the timer was starting on all skins again:/ function rewardTimer(player) local skinId = getElementModel(source) if not skinId == 201 then return end local player = source or player Timer = setTimer ( rewardOnRun, 100, 1,player ) givePlayerMoney ( player, 1 ) end addEventHandler ( "onPlayerSpawn", getRootElement(), rewardTimer ) function rewardOnRun(player) givePlayerMoney ( player, 1 ) setTimer ( rewardTimer, 100, 1,player ) end function stopTimer() if isTimer ( Timer ) then killTimer ( Timer ) end end addEventHandler ( "onPlayerWasted", getRootElement(), stopTimer ) Link to comment
Xwad Posted October 10, 2015 Author Share Posted October 10, 2015 one more quesiton. Why is it not giving me the money? The script starts that function with a timer function captureAreaA1(commandName, player) local player = source or player UA1 = createRadarArea ( -2731.27, -2592, 250, 380, 255, 255, 31, alpha ) givePlayerMoney ( player, 1000 ) if isElement(markerG1) then destroyElement ( GA1 ) end end Link to comment
ALw7sH Posted October 10, 2015 Share Posted October 10, 2015 one more quesiton. Why is it not giving me the money? The script starts that function with a timer function captureAreaA1(commandName, player) local player = source or player UA1 = createRadarArea ( -2731.27, -2592, 250, 380, 255, 255, 31, alpha ) givePlayerMoney ( player, 1000 ) if isElement(markerG1) then destroyElement ( GA1 ) end end if it's client side wiki: Note: Using this function client side (not recommended) will not change a players money server side. Link to comment
TAPL Posted October 10, 2015 Share Posted October 10, 2015 Why you have commandName here? function captureAreaA1(commandName, player) Link to comment
Xwad Posted October 10, 2015 Author Share Posted October 10, 2015 Becaouse i also need commands for that function. And for that i need that argumentum. So why is the givePlayerMoney nkt working? 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