Jump to content

[Need help (BUG)]


justn

Recommended Posts

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
Link to comment

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
Link to comment
  • Moderators

@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

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