Jump to content

Small problem with a command


Eshtiz

Recommended Posts

I'm making a command to show the 'Admin' who used it the 'report commands', but the thing is, it shows to everyone online and that's really not what I'm trying to accomplish, trying to make it visible to only him if he uses it.

Here's the script:

function reportHelp(thePlayer) 
    if (exports.global:isPlayerAdmin(thePlayer)) then 
    outputChatBox("~-~-~-~-~-~ Report Commands ~-~-~-~-~", showPlayer, 255, 194, 14) 
  
    outputChatBox("/reports       -     display reports", showPlayer, 255, 194, 14) 
    outputChatBox("/ri [id]       -     report info", showPlayer, 255, 194, 14) 
    outputChatBox("/tr [id]       -     transfer report", showPlayer, 255, 194, 14) 
    outputChatBox("/cr [id]       -     close report", showPlayer, 255, 194, 14) 
    outputChatBox("/ar [id]       -     accept report", showPlayer, 255, 194, 14) 
    outputChatBox("/dr [id]       -     drop report", showPlayer, 255, 194, 14) 
    outputChatBox("/fr [id]       -     false report", showPlayer, 255, 194, 14) 
  
    end 
end 
addCommandHandler("rh", reportHelp) 

Link to comment
I'm making a command to show the 'Admin' who used it the 'report commands', but the thing is, it shows to everyone online and that's really not what I'm trying to accomplish, trying to make it visible to only him if he uses it.

Here's the script:

function reportHelp(thePlayer) 
    if (exports.global:isPlayerAdmin(thePlayer)) then 
    outputChatBox("~-~-~-~-~-~ Report Commands ~-~-~-~-~", showPlayer, 255, 194, 14) 
  
    outputChatBox("/reports       -     display reports", showPlayer, 255, 194, 14) 
    outputChatBox("/ri [id]       -     report info", showPlayer, 255, 194, 14) 
    outputChatBox("/tr [id]       -     transfer report", showPlayer, 255, 194, 14) 
    outputChatBox("/cr [id]       -     close report", showPlayer, 255, 194, 14) 
    outputChatBox("/ar [id]       -     accept report", showPlayer, 255, 194, 14) 
    outputChatBox("/dr [id]       -     drop report", showPlayer, 255, 194, 14) 
    outputChatBox("/fr [id]       -     false report", showPlayer, 255, 194, 14) 
  
    end 
end 
addCommandHandler("rh", reportHelp) 

Where do you get "showPlayer" from?

The correct way is:

  
function reportHelp(thePlayer) 
    if (exports.global:isPlayerAdmin(thePlayer)) then 
    outputChatBox("~-~-~-~-~-~ Report Commands ~-~-~-~-~", thePlayer, 255, 194, 14) 
  
    outputChatBox("/reports       -     display reports", thePlayer, 255, 194, 14) 
    outputChatBox("/ri [id]       -     report info", thePlayer, 255, 194, 14) 
    outputChatBox("/tr [id]       -     transfer report", thePlayer, 255, 194, 14) 
    outputChatBox("/cr [id]       -     close report", thePlayer, 255, 194, 14) 
    outputChatBox("/ar [id]       -     accept report", thePlayer, 255, 194, 14) 
    outputChatBox("/dr [id]       -     drop report", thePlayer, 255, 194, 14) 
    outputChatBox("/fr [id]       -     false report", thePlayer, 255, 194, 14) 
  
    end 
end 
addCommandHandler("rh", reportHelp) 
  

Notice that I replaced showPlayer with thePlayer

Read here exactly how the outputChatBox function works: https://wiki.multitheftauto.com/wiki/OutputChatBox

Hope I could help you :-)

Link to comment

Eshtiz,showPlayer variable is nil in your script.

in function outputChatBox you need use 2 argument is element.But you use showPlayer then outputChatBox function not work , return false.

in /debugscript 3 would be shown the errors , but you not use.

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