Jump to content

simple redirectPlayer problem


Recommended Posts

Posted
    function forceRedirectPlayer(commandName,who) 
    redirectPlayer( who, "192.168.1.64", 22003 ) 
    else 
    outputDebugString("Unknown error.") 
    end 
    addCommandHandler("freconnect",forceRedirectPlayer) 

Posted

i've tried editing it now just for a bit and it gives me a non sense error!

function forceRedirectPlayer(who,commandName,thePlayer) 
        if hasObjectPermissionTo ( player, "function.banPlayer", true ) then 
        redirectPlayer( who, "192.168.1.64", 22003 ) 
        else 
        cancelEvent() and outputChatBox("You cannot use that command.",thePlayer,255,0,0) 
    end 
end 
addCommandHandler("freconnect",forceRedirectPlayer) 

[18:21:32] SCRIPT ERROR: test\freconnect_s.lua:5: unexpected symbol near

'and'

[18:21:32] ERROR: Loading script failed: test\freconnect_s.lua:5: unexpe

cted symbol near 'and'

please help

Posted (edited)

You don't need that "and" on line 5

try this:

function forceRedirectPlayer(player,_, who) 
    if not who then return end 
    if hasObjectPermissionTo ( player, "function.banPlayer", true ) then 
        who = getPlayerFromName(who) 
        if who then 
            redirectPlayer( who, "192.168.1.64", 22003 ) 
        end 
    else 
        cancelEvent() 
        outputChatBox("You cannot use that command.",player,255,0,0) 
    end 
end 
addCommandHandler("freconnect",forceRedirectPlayer) 

Edited by Guest
Posted
You don't need that "and" on line 5

try this:

function forceRedirectPlayer(who,commandName) 
    if hasObjectPermissionTo ( player, "function.banPlayer", true ) then 
        redirectPlayer( who, "192.168.1.64", 22003 ) 
    else 
        cancelEvent() 
        outputChatBox("You cannot use that command.",player,255,0,0) 
    end 
end 
addCommandHandler("freconnect",forceRedirectPlayer) 

lol, it doesn't let me force reconnect myself while loggined in as admin

[18:37:13] WARNING: test\freconnect_s.lua:2: Bad argument @ 'hasObjectPermissionTo'
Posted
Sorry, I misread the script...

Try the code I've posted again.

Doesn't work at all

[18:54:05] ERROR: Loading script failed:test\freconnect_s.lua:13: unexpected symbol near ')'

-- line 13

addCommandHandler("freconnect",forceRedirectPlayer) 

Posted

Why are you using cancelEvent in a command handler? cancelEvent is only for event. Try deleting that.

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