Jump to content

Redirect Player


R.y.c.k

Recommended Posts

Hello. I want to ask if someone has already done with this feature !dd ,I do not know how I put it in the form

I would like to trigger a command name !dd , !dm

This is normal command /dd how to put into !dd ? I would like to learn something new because with this feature, I met first time :(

function prepniNaServer (player, command) 
outputChatBox("In 5 seconds you'll be redirected to our DD server!", player)  
  
local nick = getPlayerName(player)  
  
setTimer(redirectPlayer, 5000, 1, player, "00.000.00.0000", 0000)  
  
outputChatBox("Player " .. nick .. " be linked to our DD server!", getRootElement(), 250, 0, 0)  
  
end 
  
addCommandHandler("dd",prepniNaServer)  

Link to comment
addEventHandler ( "onPlayerCommand", root, 
         function ( command ) 
               if command = "!dd" then 
                     -- do the stuff 
               end 
         end 
) 

Link to comment

wtf... R.y.c.k , does that really work?

onPlayerCommand should not be able to detect stuff like that..

Instead, you should be using onPlayerChat and check the first word for '!' character or something. But it's really weird that you say onPlayerCommand works :S

For all I know, that should only work if the command is "/!dd" not "!dd"

Link to comment

debugscript reported problem " Loading script Failed: dd\dd.lua:15: 'then' expected near '=' "

function prepniNaServer (player, command) 
outputChatBox("In 5 seconds you'll be redirected to our DD server!", player)  
  
local nick = getPlayerName(player)  
  
setTimer(redirectPlayer, 5000, 1, player, "00.000.000.000", 22004)  
  
outputChatBox("Player " .. nick .. " be linked to our DD server!", getRootElement(), 250, 0, 0) --Posleme zpravu vsem hracum o tom ze se hrac odpojil. 
  
end 
  
addCommandHandler("dd",prepniNaServer)  
  
addEventHandler ( "onPlayerCommand", root, 
         function ( prepniNaServer )  --- function ( command ) or ( prepniNaServer ) ?  
               if command = "!dd" then 
                     -- do the stuff 
               end 
         end 
) 

Link to comment
Guest Guest4401

If you wish to convert every command of "/" to "!" then

addEventHandler('onPlayerChat',root, 
    function(msg,msgtype) 
        if msgtype == 0 then 
            if msg:find("!",1,true) == 1 then 
                if msg:find(" ") then 
                    executeCommandHandler(msg:sub(2,msg:find(" ")-1),source,msg:sub(msg:find(" ")+1)) 
                else 
                    executeCommandHandler(msg:sub(2),source) 
                end 
            end 
        end 
    end 
) 

If only for !dd then:

addEventHandler('onPlayerChat',root, 
    function(msg,msgtype) 
        if msgtype == 0 then 
            if msg == "!dd" then 
                executeCommandHandler("dd",source) 
            end 
        end 
    end 
) 

And don't forget to add the command:

addCommandHandler("dd", 
    function(player) 
        setTimer(redirectPlayer,5000,1,player,"00.000.000.000",0000) 
        outputChatBox("In 5 seconds you'll be redirected to our DD server!", player) 
        outputChatBox("Player " ..getPlayerName(player).. " be linked to our DD server!", getRootElement(), 250, 0, 0) 
    end 
) 

Link to comment
the port should be 'tonumber(22003)'

Nope, it is a number value, no need to put tonumber there, this has been said MANY times.

It won't work without tonumber() ..

what the point of convert it to integer since the port is already integer lol

you need it only if you are put the port using command because command will always return string and you need to convert it to integer number.

Link to comment

Nope, it is a number value, no need to put tonumber there, this has been said MANY times.

It won't work without tonumber() ..

what the point of convert it to integer since the port is already integer lol

you need it only if you are put the port using command because command will always return string and you need to convert it to integer number.

isn't he trying to do a command :) ?

Link to comment
[

what the point of convert it to integer since the port is already integer lol

you need it only if you are put the port using command because command will always return string and you need to convert it to integer number.

isn't he trying to do a command :) ?

Nope, he put it manually

setTimer(redirectPlayer, 5000, 1, player, "00.000.000.000", 22004)

i was talking about command arg :wink:

for example: this won't work without tonumber

addCommandHandler("dd", 
    function(player,cmd,port) 
        setTimer(redirectPlayer,5000,1,player,"00.000.000.000",port) 
        outputChatBox("In 5 seconds you'll be redirected to our DD server!", player) 
        outputChatBox("Player " ..getPlayerName(player).. " be linked to our DD server!", getRootElement(), 250, 0, 0) 
    end 
) 

so it's need to be

addCommandHandler("dd", 
    function(player,cmd,port) 
        setTimer(redirectPlayer,5000,1,player,"00.000.000.000",tonumber(port)) 
        outputChatBox("In 5 seconds you'll be redirected to our DD server!", player) 
        outputChatBox("Player " ..getPlayerName(player).. " be linked to our DD server!", getRootElement(), 250, 0, 0) 
    end 
) 

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