Jump to content

cop tickets[help]


cokacola

Recommended Posts

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

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

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

your in the credits...

yes it worked :D

thankyou

thank you

thank-you

thank.you

thank you!

^:P

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 :P

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 :P)

Edit:

to save a new topic...

should this work? :P

--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? :P

Link to comment

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
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
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
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
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
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
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 xD, I only mean, this:

--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:

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:

--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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...