cokacola Posted April 2, 2009 Share Posted April 2, 2009 okay got a new problem, i am trying to use this script, but it keeps telling me it can't check boolean againts a string, but i thought getPlayerMoney(thePlayer) returned a number --Cop ticket system - type /ticket [playername] [money] [reason] to give a player a ticket. It will take money from them automaticly, but if they do not have the money, it will jail them for 60 seconds function ticket ( badPlayer, money, reason ) local gpm = getPlayerMoney(badPlayer) if ( gpm < money) then setElementPosition ( badPlayer, 198.8221, 162.0566, 1003.0299 ) setElementInterior ( badPlayer, 3 ) takeAllWeapons ( badPlayer ) --remove all of the players weapons setTimer ( setElementPosition, 60000, 1, badPlayer, 2335.9614, 2454.5168, 14.9687 ) setTimer ( setElementInterior, 60000.0, 1, badPlayer, 0 ) outputChatBox ( "You've been finned " .. money .. " by a cop, you could not afford the fine and have been sent to jail for 1 minute.", badPlayer, 0, 100, 255 ) else takePlayerMoney(badPlayer, price) outputChatBox("You've been fined $150 - by a cop, for: " .. reason .. ".", badPlayer) end end addCommandHandler ( "ticket", ticket ) Link to comment
robhol Posted April 2, 2009 Share Posted April 2, 2009 I don't know of often I find myself saying this, but newsflash: we're not psychic, we need all the information you can give. Line number. Error message. Link to comment
DakiLLa Posted April 2, 2009 Share Posted April 2, 2009 may be you need to translate 'money' argument from string to number? money = tonumber( money ); and in your example your trying to concatenate number value with string.. Link to comment
cokacola Posted April 2, 2009 Author Share Posted April 2, 2009 hmm.. "attempt to compare number with nil" ehh.. is it not returning the player money / money to take? because i am entering the money parameter and the player has 0 money to test(i might try with money but usually it returns 0 if the player has no money, and then they should go to jail) this line: if ( gpm < money) then its line 4 in my original post's code Link to comment
robhol Posted April 2, 2009 Share Posted April 2, 2009 Either the badPlayer parameter or the money parameter is never passed - probably the money one, otherwise you'd also have other errors/warnings. Link to comment
cokacola Posted April 2, 2009 Author Share Posted April 2, 2009 is it not being passed codewise? or when its typed because i use this(example) "/ticket bizzycola 100 horrible" and it just returns an error Link to comment
DakiLLa Posted April 2, 2009 Share Posted April 2, 2009 man..you should to read carefully sintax of commandHandler on wiki...I think that you've passed wrong number of parametres if we take a look on a wiki, function funName( playerSource, commandName, [string arg1, string arg2, ...] ) so i think i know what you wanted to make.. here is your code with my corrects..i've not tested it, may be it have errors..check this.. function ticket( sourcePlayer, command, badPlName, money, reason ) money = tonumber( money ) --convert from string to number badPlayer = getPlayerFromNick( badPlName ) --get bad player if ( badPlayer ) then --if there is a bad player... local gpm = getPlayerMoney( badPlayer ) if ( gpm < money ) then setElementPosition ( badPlayer, 198.8221, 162.0566, 1003.0299 ) setElementInterior ( badPlayer, 3 ) takeAllWeapons ( badPlayer ) --remove all of the players weapons setTimer ( setElementPosition, 60000, 1, badPlayer, 2335.9614, 2454.5168, 14.9687 ) setTimer ( setElementInterior, 60000.0, 1, badPlayer, 0 ) outputChatBox ( "You've been finned " .. money .. " by a cop, you could not afford the fine and have been sent to jail for 1 minute.", badPlayer, 0, 100, 255 ) else takePlayerMoney(badPlayer, price) outputChatBox("You've been fined $150 - by a cop, for: " .. reason .. ".", badPlayer) end else outputChatBox( "I cant find a player with this nick...", sourcePlayer, 255, 0, 0 ) end end addCommandHandler ( "ticket", ticket ) Link to comment
cokacola Posted April 2, 2009 Author Share Posted April 2, 2009 your in the credits... yes it worked thankyou thank you thank-you thank.you thank you! ^ okay now, is it possible, to have the reason(last parameter) go more than 1 word? or d i just add dashes oh well, just gotta solve my mail script now...few posts down oh well, feel free to use the script, and, in the script he posted above, if the player has enough money change takePlayerMoney(badPlayer, price) to: takePlayerMoney(badPlayer, money) and it works, oh and 1 more thing, if you use it, give him credit(and maybe me for the idea, but he basicly scripted it, because my code done nothing ) Edit: to save a new topic... should this work? --car indacators - /lc for left indicator, /rc for right indicator. function carindonl ( sourcePlayer ) sourcePl = getPlayerFromNick ( sourcePlayer ) setVehicleLightState ( sourcePl, 0, 1 ) setVehicleLightState ( sourcePl, 1, 1 ) end function carindonr ( sourcePlayer ) sourcePl = getPlayerFromNick ( sourcePlayer ) setVehicleLightState ( sourcePl, 1, 0 ) setvehicleLightState ( sourcePl, 1, 1 ) end function carindl () setTimer ( carindonl, 1000, 10 ) end function carindr () setTimer ( carindonr, 1000, 10 ) end addCommandHandler("lc", carindl) addCommandHandler("rc", carindr) it doesn't, but it says something to do with the setvehicleLightState's value being "nil" oh and whats the easiest job to script? Link to comment
[DKR]silverfang Posted April 2, 2009 Share Posted April 2, 2009 To make the last parameter more than one word, you have to make the last argument '...' then use table.concat(..., " ") to break the table into a phrase (the '...' is a table) Link to comment
Lordy Posted April 2, 2009 Share Posted April 2, 2009 incorrect. You'd have to use table.concat({...}, " ") or table.concat(arg, " ") Link to comment
cokacola Posted April 3, 2009 Author Share Posted April 3, 2009 i am confused....small example maybe? Link to comment
[DKR]silverfang Posted April 3, 2009 Share Posted April 3, 2009 Yeah my mistake anyways try this. function parameterTest (player, command, ...) parameterTable = {...} parameterTableString = table.concat(parameterTable, " ") outputChatBox("You typed: " .. parameterTableString .. "!", player) end addCommandHandler("command", parameterTest) Link to comment
Lordy Posted April 3, 2009 Share Posted April 3, 2009 Why do you define another table, if arg is defined too (arg == {...} ) Link to comment
Thehookerkiller01 Posted April 4, 2009 Share Posted April 4, 2009 cokacola said: okay got a new problem, i am trying to use this script, but it keeps telling me it can't check boolean againts a string, but i thought getPlayerMoney(thePlayer) returned a number --Cop ticket system - type /ticket [playername] [money] [reason] to give a player a ticket. It will take money from them automaticly, but if they do not have the money, it will jail them for 60 seconds function ticket ( badPlayer, money, reason ) local gpm = getPlayerMoney(badPlayer) if ( gpm < money) then setElementPosition ( badPlayer, 198.8221, 162.0566, 1003.0299 ) setElementInterior ( badPlayer, 3 ) takeAllWeapons ( badPlayer ) --remove all of the players weapons setTimer ( setElementPosition, 60000, 1, badPlayer, 2335.9614, 2454.5168, 14.9687 ) setTimer ( setElementInterior, 60000.0, 1, badPlayer, 0 ) outputChatBox ( "You've been finned " .. money .. " by a cop, you could not afford the fine and have been sent to jail for 1 minute.", badPlayer, 0, 100, 255 ) else takePlayerMoney(badPlayer, price) outputChatBox("You've been fined $150 - by a cop, for: " .. reason .. ".", badPlayer) end end addCommandHandler ( "ticket", ticket ) Actually I think so that you just first have to get any1 out of his car. Because if you use this and any1 is in the car (the subject) he will be placed in interior 3 with a car. And with that you have bugs. Link to comment
Lordy Posted April 4, 2009 Share Posted April 4, 2009 Oh god, please crap on that guy. Please read the thread, he already has had help and he got it working. And your suggestion would not have fixed it. Link to comment
cokacola Posted April 4, 2009 Author Share Posted April 4, 2009 [DKR]silverfang said: Yeah my mistake anyways try this. function parameterTest (player, command, ...) parameterTable = {...} parameterTableString = table.concat(parameterTable, " ") outputChatBox("You typed: " .. parameterTableString .. "!", player) end addCommandHandler("command", parameterTest) yea it was fixed...BTW silverFang this did work thanks Link to comment
Thehookerkiller01 Posted April 4, 2009 Share Posted April 4, 2009 LordAzamth said: Oh god, please crap on that guy.Please read the thread, he already has had help and he got it working. And your suggestion would not have fixed it. He may try it ;l Get the person in a car named someguy. And type in the chat (with another account) /ticket Someguy 100000000 then he will be spawn with the vehicle in the interior. And you have a bug. Link to comment
Thehookerkiller01 Posted April 4, 2009 Share Posted April 4, 2009 [DKR]silverfang said: Yeah my mistake anyways try this. function parameterTest (player, command, ...) parameterTable = {...} parameterTableString = table.concat(parameterTable, " ") outputChatBox("You typed: " .. parameterTableString .. "!", player) end addCommandHandler("command", parameterTest) Where should you place this? Link to comment
Gamesnert Posted April 4, 2009 Share Posted April 4, 2009 Thehookerkiller01 said: Where should you place this? Paste it in Microsoft Office Word. Then you should print it out on A4 format. Huge 40+ Pt font. Next up you should position it in the top of the shredder. Drop it low enough, and you might see some action. If you don't have a shredder, a fire or a fryer would also do OK. Link to comment
Thehookerkiller01 Posted April 4, 2009 Share Posted April 4, 2009 Gamesnert said: Thehookerkiller01 said: Where should you place this? Paste it in Microsoft Office Word. Then you should print it out on A4 format. Huge 40+ Pt font. Next up you should position it in the top of the shredder. Drop it low enough, and you might see some action. If you don't have a shredder, a fire or a fryer would also do OK. LOL , I only mean, this: Quote --car indacators - /lc for left indicator, /rc for right indicator.function carindonl ( sourcePlayer ) sourcePl = getPlayerFromNick ( sourcePlayer ) setVehicleLightState ( sourcePl, 0, 1 ) setVehicleLightState ( sourcePl, 1, 1 ) end function carindonr ( sourcePlayer ) sourcePl = getPlayerFromNick ( sourcePlayer ) setVehicleLightState ( sourcePl, 1, 0 ) setvehicleLightState ( sourcePl, 1, 1 ) end function carindl () setTimer ( carindonl, 1000, 10 ) end function carindr () setTimer ( carindonr, 1000, 10 ) end addCommandHandler("lc", carindl) addCommandHandler("rc", carindr) and this: Quote function parameterTest (player, command, ...) parameterTable = {...} parameterTableString = table.concat(parameterTable, " ") outputChatBox("You typed: " .. parameterTableString .. "!", player) end addCommandHandler("command", parameterTest) Should I have to place it like: Quote --car indacators - /lc for left indicator, /rc for right indicator. function carindonl ( sourcePlayer ) sourcePl = getPlayerFromNick ( sourcePlayer ) setVehicleLightState ( sourcePl, 0, 1 ) setVehicleLightState ( sourcePl, 1, 1 ) end function carindonr ( sourcePlayer ) sourcePl = getPlayerFromNick ( sourcePlayer ) setVehicleLightState ( sourcePl, 1, 0 ) setvehicleLightState ( sourcePl, 1, 1 ) end function carindl () setTimer ( carindonl, 1000, 10 ) end function carindr () setTimer ( carindonr, 1000, 10 ) end addCommandHandler("lc", carindl) addCommandHandler("rc", carindr) function parameterTest (player, command, ...) parameterTable = {...} parameterTableString = table.concat(parameterTable, " ") outputChatBox("You typed: " .. parameterTableString .. "!", player) end addCommandHandler("command", parameterTest) That's my question. And use it ss or cs>? 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