myyusuf Posted March 11, 2012 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?
GanJaRuleZ Posted March 11, 2012 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 My Projects! No one.
drk Posted March 11, 2012 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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
myyusuf Posted March 11, 2012 Author 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?
drk Posted March 11, 2012 Posted March 11, 2012 nitro = nil You are trying to savePlayerData of element "nitro". EPT Team Server Development: 0% Learning C++ | C++ is amazing
myyusuf Posted March 11, 2012 Author 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
drk Posted March 11, 2012 Posted March 11, 2012 Change to: savePlayerData ( source, "points", points - cashToNos ) EPT Team Server Development: 0% Learning C++ | C++ is amazing
myyusuf Posted March 11, 2012 Author Posted March 11, 2012 Change to: savePlayerData ( source, "points", points - cashToNos ) thanks again. i got it how works.
drk Posted March 11, 2012 Posted March 11, 2012 You're welcome. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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