myyusuf Posted March 11, 2012 Share Posted March 11, 2012 function nitro(source, command) local points = getElementData(source,"points") if points >= 10 then if (isPedInVehicle(source)) then addVehicleUpgrade(getPedOccupiedVehicle(source), 1010) setTimer(outputChatBox,50,1,"#c0c0c0* #abcdef"..getPlayerName (source).." #c0c0c0bought nitro for #abcdef10#c0c0c0 points!",root, 255, 255, 255, true ) savePlayerData( nitro, "points", playerPoints - 10 ) else outputChatBox ("#c0c0c0* You must sit in a car to buy nitro it!",source, 255, 255, 255, true ) cancelEvent() end else outputChatBox ("#c0c0c0* You can't buy nitro, you need #abcdef10#c0c0c0 points first!",source, 255, 255, 255, true ) cancelEvent() end end addCommandHandler("nitro", nos) addCommandHandler("nos", nos) server.lua:17 bad argument @ 'addCommandHandler' [Expected function at argument 2, got nil] server.lua:18 bad argument @ 'addCommandHandler' [Expected function at argument 2, got nil] i have got this error. what is wrong? Link to comment
GanJaRuleZ Posted March 11, 2012 Share Posted March 11, 2012 (edited) ??? You named the function 'nitro' and you called the function 'nos' Next time use wiki.. function nos(source, command) local points = getElementData(source,"points") if points >= 10 then if (isPedInVehicle(source)) then addVehicleUpgrade(getPedOccupiedVehicle(source), 1010) setTimer(outputChatBox,50,1,"#c0c0c0* #abcdef"..getPlayerName (source).." #c0c0c0bought nitro for #abcdef10#c0c0c0 points!",root, 255, 255, 255, true ) savePlayerData( nitro, "points", playerPoints - 10 ) else outputChatBox ("#c0c0c0* You must sit in a car to buy nitro it!",source, 255, 255, 255, true ) cancelEvent() end else outputChatBox ("#c0c0c0* You can't buy nitro, you need #abcdef10#c0c0c0 points first!",source, 255, 255, 255, true ) cancelEvent() end end addCommandHandler("nitro",nos) addCommandHandler("nos",nos) Edited March 11, 2012 by Guest Link to comment
drk Posted March 11, 2012 Share Posted March 11, 2012 function nitro(source, command) local points = getElementData(source,"points") if points >= 10 then if (isPedInVehicle(source)) then addVehicleUpgrade(getPedOccupiedVehicle(source), 1010) setTimer(outputChatBox,50,1,"#c0c0c0* #abcdef"..getPlayerName (source).." #c0c0c0bought nitro for #abcdef10#c0c0c0 points!",root, 255, 255, 255, true ) savePlayerData( nitro, "points", playerPoints - 10 ) else outputChatBox ("#c0c0c0* You must sit in a car to buy nitro it!",source, 255, 255, 255, true ) cancelEvent() end else outputChatBox ("#c0c0c0* You can't buy nitro, you need #abcdef10#c0c0c0 points first!",source, 255, 255, 255, true ) cancelEvent() end end addCommandHandler("nitro", nitro) addCommandHandler("nos", nitro) You are calling a nil function nos. Link to comment
myyusuf Posted March 11, 2012 Author Share Posted March 11, 2012 oh my bad but i have got this problem now. function nitro(source, command) local points = getElementData(source,"points") if points >= 10 then if (isPedInVehicle(source)) then addVehicleUpgrade(getPedOccupiedVehicle(source), 1010) setTimer(outputChatBox,50,1,"#c0c0c0* #abcdef"..getPlayerName (source).." #c0c0c0bought nitro for #abcdef10#c0c0c0 points!",root, 255, 255, 255, true ) local cashToNos = 10 savePlayerData(nitro, "points", points - cashToNos ) else outputChatBox ("#c0c0c0* You must sit in a car to buy nitro it!",source, 255, 255, 255, true ) cancelEvent() end else outputChatBox ("#c0c0c0* You can't buy nitro, you need #abcdef10#c0c0c0 points first!",source, 255, 255, 255, true ) cancelEvent() end end addCommandHandler("nitro", nitro) addCommandHandler("nos", nitro) code works great but it doenst effect to "points". whats wrong? Link to comment
drk Posted March 11, 2012 Share Posted March 11, 2012 nitro = nil You are trying to savePlayerData of element "nitro". Link to comment
myyusuf Posted March 11, 2012 Author Share Posted March 11, 2012 nitro = nilYou are trying to savePlayerData of element "nitro". i dont understand. i am new at lua coding. can you explain me? edit: ıh i got it. thank you so much for helping Link to comment
drk Posted March 11, 2012 Share Posted March 11, 2012 Change to: savePlayerData ( source, "points", points - cashToNos ) Link to comment
myyusuf Posted March 11, 2012 Author Share Posted March 11, 2012 Change to: savePlayerData ( source, "points", points - cashToNos ) thanks again. i got it how works. 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