justn Posted March 25, 2014 Share Posted March 25, 2014 (edited) So yeah, i have made this , and the problem is, when the cop aims at the player and presses N , nothing happens, can you help please? function onPlayerTargetA ( theCop ) if isPlayerInTeam( theCop, "Police" ) then if not isPlayerInTeam(source, "Police" ) then if ( getPlayerWantedLevel ( source ) == 1 ) then if ( getElementType ( theCop ) == "player" ) then bindKey ( theCop, "N", "down", function() exports["TopBarChat"]:sendClientMessage("You have given "..getPlayerName(source).." a ticket , Wait for him to pay it",theCop,255, 0, 0, true) exports["TopBarChat"]:sendClientMessage("You have gotten a ticket ! Press 'H' to pay it!",source,255, 0, 0, true) bindKey ( source, "H", "down", payTheTicket ) end) end end end end end addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargetA ) function payTheTicket (theCop) if isPlayerInTeam( theCop, "Police" ) then if not isPlayerInTeam(source, "Police" ) then if ( getPlayerWantedLevel ( source ) == 1 ) then if ( getElementType ( theCop ) == "player" ) then givePlayerMoney(theCop,200) takePlayerMoney(source,200) exports["TopBarChat"]:sendClientMessage("The ticket has been paid by "..getPlayerName(source),theCop,255, 0, 0, true) exports["TopBarChat"]:sendClientMessage("You have paid the ticket to "..getPlayerName(theCop),source,255, 0, 0, true) end end end end end Edited March 26, 2014 by Guest Link to comment
WhoAmI Posted March 25, 2014 Share Posted March 25, 2014 Well, as I can see, source should be theCop and theCop should be source in onPlayerTargetA function. I'm not sure. Anyway fo you get any errors? Link to comment
justn Posted March 25, 2014 Author Share Posted March 25, 2014 Source is the player who is getting the ticket... but the errors: ERROR:Police\server.lua:26:attempt to concatenate a boolean value Link to comment
WhoAmI Posted March 25, 2014 Share Posted March 25, 2014 As far as I can see, you want to make this code when police aims at player, but this function is executing when the player is aiming at the cop and when he has 1 star of wanted level. Link to comment
justn Posted March 25, 2014 Author Share Posted March 25, 2014 can you fix for me please? Link to comment
WhoAmI Posted March 25, 2014 Share Posted March 25, 2014 I'll do it tomorrow morning if someone wouldn't be faster. Link to comment
WhoAmI Posted March 26, 2014 Share Posted March 26, 2014 (edited) Not sure if it works, but function onPlayerTargetA ( player ) if ( isPlayerInTeam ( source, "Police" ) ) then if ( isElement ( player ) and getElementType ( player ) == "player" ) then if ( not isPlayerInTeam ( player, "Police" ) ) then bindKey ( source, "N", "down", function() exports [ "TopBarChat" ] : sendClientMessage ( "You have given " .. getPlayerName ( player ) .. " a ticket , Wait for him to pay it", source, 255, 0, 0, true ) exports [ "TopBarChat" ] : sendClientMessage ( "You have gotten a ticket ! Press 'H' to pay it!", player, 255, 0, 0, true ) bindKey ( player, "H", "down", payTheTicket, source, player ) end ) end end end end addEventHandler ( "onPlayerTarget", root, onPlayerTargetA ) function payTheTicket ( _, _, _, theCop, thePlayer ) givePlayerMoney ( theCop, 200 ) takePlayerMoney ( thePlayer, 200 ) exports [ "TopBarChat" ] : sendClientMessage ( "The ticket has been paid by " .. getPlayerName ( thePlayer ), theCop, 255, 0, 0, true ) exports [ "TopBarChat" ] : sendClientMessage ( "You have paid the ticket to " .. getPlayerName ( theCop ), thePlayer, 255, 0, 0, true ) unbindKey ( thePlayer, "H", "down", paytTheTicket ) end Edited March 26, 2014 by Guest Link to comment
Moderators IIYAMA Posted March 26, 2014 Moderators Share Posted March 26, 2014 @WhoAmI No, it doesn't work since you skipped they key arguments of the bindKey at the function payTheTicket. I you don't know what I mean, click on the link to his other topic about the same script. @#Twerky Would you pls not post everything double? You won't get better results, but mad moderators if that is what you want... https://forum.multitheftauto.com/viewtopic.php?f=91&t=73202 Link to comment
justn Posted March 26, 2014 Author Share Posted March 26, 2014 (edited) @IIYAMA Loool, I'll try @WhoAmI Bug, the police doesn't get the money and for 'sendClientMessage' nothing appears for the cop, only for the criminal, everything works fine. Edited March 26, 2014 by Guest 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