Jump to content

[Need help (BUG)]


justn

Recommended Posts

Posted (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 by Guest
Posted

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?

Posted

Source is the player who is getting the ticket...

but the errors: ERROR:Police\server.lua:26:attempt to concatenate a boolean value

Posted

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.

Posted (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 by Guest
  • Moderators
Posted

@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

Posted (edited)

@IIYAMA Loool, I'll try xD

@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 by Guest

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