Jump to content

[HELP] redirectPlayer


=KoG=Rouche

Recommended Posts

Posted (edited)

Hi all i'm =KoG=Rouche owner of Team =KoG= (http://www.teamkog.eu).

I'm learning LUA scripting and i need your help for a script.

I'm trying to create a panel which can redirect player if they want.

Here is the screenshot of the panel :

9esm.png

Problem

- redirectPlayer don't work and return a nil value in test "returnVar", must be True or False.

Debugging Report :

zs58.png

Clientside

  
-- Event when the ressource start 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), 
    function()  
         
        function createWindow() 
             
            -- Press key F1 to open Server Changer Panel 
            bindKey("F1","down",function() 
                        if(windowServChanger ~= nil) then 
                        guiSetVisible(windowServChanger,true) 
                            guiWindowSetMovable(windowServChanger,false) 
                            guiWindowSetSizable(windowServChanger,false) 
                            guiSetAlpha(windowServChanger,1.0) 
                        else 
                            outputChatBox("There is a bug with the Panel !") 
                        end 
                        -- Mouse Cursor ON 
                        showCursor(true) 
                    end 
            )    
                 
            function clientChangeServ(button,state) 
                if button == "left" and state == "up" then 
                outputChatBox("Test Avant Trigger") 
                triggerServerEvent("onRedirect",localPlayer) 
                outputChatBox("Test Après Trigger") 
                end 
            end 
  
            function clientCancel(button,state) 
                if button == "left" and state == "up" then 
                    guiSetVisible(windowServChanger,false) 
                    showCursor(false) 
                end 
            end 
         
            windowServChanger = guiCreateWindow(0.43,0.40,0.14,0.10,"| =KoG= Server Changer v1.0 |",true) 
            btnOldServ = guiCreateButton(0.25,0.30,0.50,0.40,"Old Maps Server",true,windowServChanger) 
            btnCancel = guiCreateButton(0.85,0.70,0.10,0.25,"X",true,windowServChanger) 
            guiSetVisible(windowServChanger,false) 
            outputChatBox("Window OK") 
            -- Add Event on Button Click 
            addEventHandler("onClientGUIClick",btnOldServ,clientChangeServ,false) 
            addEventHandler("onClientGUIClick",btnCancel,clientCancel,false)  
            outputChatBox("After addEventHandler") 
        end 
       
        -- GUI Creation    
        createWindow() 
  
    end 
) 
  

Serverside

  
function redirectHim() 
    outputChatBox("Before Redirect OK"..tostring(source))     
    local returnVar = redirectPlayer(source,"5.39.92.100",22010) -- It's for test 
    outputChatBox("After Redirect OK"..tostring(source)) 
    outputChatBox(tostring(returnVar)) -- Must be false / true    
    outputChatBox(getPlayerName(source)) -- Nickname 
    end  
  
addEvent("onRedirect",true) 
addEventHandler("onRedirect",root,redirectHim) 
  

meta

  

Edited by Guest

430x73_67B2EB_F75151_000000_000000.png

430x73_67B2EB_F75151_000000_000000.png

Posted

You're sure that the IP and port are the correct ones?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Hold on, did you give permission in the ACL to the resource? as far as I know, it needs it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, try adding it there.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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