Jump to content

[HELP] Functions for script


Reflex#

Recommended Posts

Your resource(code) on 1 server

local serverIP = "127.0.0.1:22005" -- Server ip [ Need HTTP Port (Not mta) ] 
  
function callBack (remote,code) 
    if not code then return end 
    outputDebugString( remote.." "..code ); 
end 
  
function aMap(player) 
    local accName = getAccountName ( getPlayerAccount ( player ) ); 
    if isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup( "Admin" ) ) then 
        local mapName = getResourceInfo ( exports.mapmanager:getRunningGamemodeMap(), "name" ); 
        if mapName then 
            callRemote ( serverIP, getResourceName ( getThisResource() ), "gotResult", callBack, 1, mapName ); 
        end 
    else 
        outputChatBox("* You need #ff0000Admin #ffffffRights!",player,255,255,255,true) 
    end 
end 
addCommandHandler("accepted",aMap) 
  
function dMap(player) 
    local accName = getAccountName ( getPlayerAccount ( player ) ); 
    if isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup( "Admin" ) ) then 
        local mapName = getResourceInfo ( exports.mapmanager:getRunningGamemodeMap(), "name" ); 
        if mapName then 
            callRemote ( serverIP, getResourceName ( getThisResource() ), "gotResult", callBack, 2, mapName ); 
        end 
    else 
        outputChatBox("* You need #ff0000Admin #ffffffRights!",player,255,255,255,true) 
    end 
end 
addCommandHandler("declined",dMap) 

Other server

function gotResult (mode,mapName) 
    if mode == 1 then 
        outputChatBox ( "[TESTING RESULTS]", getRootElement(), 255, 255, 255, true ); 
        outputChatBox ( "Map #ff0000'#ffffff" ..mapName.. "#ff0000'#ffffff was #00ff00accepted", getRootElement(), 255, 255, 255, true ); 
        outputChatBox ( "[TESTING RESULTS]", getRootElement(), 255, 255, 255, true ); 
    else 
        outputChatBox ( "[TESTING RESULTS]", getRootElement(), 255, 255, 255, true ); 
        outputChatBox ( "Map #ff0000'#ffffff" ..mapName.. "#ff0000'#ffffff was #ff0000declined", getRootElement(), 255, 255, 255, true ); 
        outputChatBox ( "[TESTING RESULTS]", getRootElement(), 255, 255, 255, true ); 
    end 
end 

meta.xml

<export function="gotResult" http="true" /> 

This resource is SERVER-SIDE and need Admin Rights for 'callRemote'

Edited by Guest
Link to comment
Your resource(code) on 1 server
local serverIP = "127.0.0.1:22005" -- Server ip [ Need HTTP Port (Not mta) ] 
  
function callBack (remote,code) 
    if not code then return end 
    outputDebugString( remote.." "..code ); 
end 
  
function aMap(player) 
    local accName = getAccountName ( getPlayerAccount ( player ) ); 
    if isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup( "Admin" ) ) then 
        local mapName = tostring ( exports.mapmanager:getRunningGamemodeMap( exports.mapmanager:getRunningGamemode() ) ); 
        if mapName then 
            callRemote ( serverIP, getResourceName ( getThisResource() ), "gotResult", callBack, 1, mapName ); 
        end 
    else 
        outputChatBox("* You need #ff0000Admin #ffffffRights!",player,255,255,255,true) 
    end 
end 
addCommandHandler("accepted",aMap) 
  
function dMap(player) 
    local accName = getAccountName ( getPlayerAccount ( player ) ); 
    if isObjectInACLGroup ( "user." .. tostring( accName ), aclGetGroup( "Admin" ) ) then 
        local mapName = tostring ( exports.mapmanager:getRunningGamemodeMap( exports.mapmanager:getRunningGamemode() ) ); 
        if mapName then 
            callRemote ( serverIP, getResourceName ( getThisResource() ), "gotResult", callBack, 2, mapName ); 
        end 
    else 
        outputChatBox("* You need #ff0000Admin #ffffffRights!",player,255,255,255,true) 
    end 
end 
addCommandHandler("declined",dMap) 

Other server

function gotResult (mode,mapName) 
    if mode == 1 then 
        outputChatBox ( "[TESTING RESULTS]", getRootElement(), 255, 255, 255, true ); 
        outputChatBox ( "Map #ff0000'#ffffff" ..mapName.. "#ff0000'#ffffff was #00ff00accepted", getRootElement(), 255, 255, 255, true ); 
        outputChatBox ( "[TESTING RESULTS]", getRootElement(), 255, 255, 255, true ); 
    else 
        outputChatBox ( "[TESTING RESULTS]", getRootElement(), 255, 255, 255, true ); 
        outputChatBox ( "Map #ff0000'#ffffff" ..mapName.. "#ff0000'#ffffff was #ff0000declined", getRootElement(), 255, 255, 255, true ); 
        outputChatBox ( "[TESTING RESULTS]", getRootElement(), 255, 255, 255, true ); 
    end 
end 

meta.xml

<export function="gotResult" http="true" /> 

This resource is SERVER-SIDE and need Admin Rights for 'callRemote'

Wow...you awesome TwiX :D

As always ;)

I wanted to make it by myself but you helped me more..I'll learn this script and I'll try to modify it

THX :)

Link to comment
  • 2 weeks later...

Sorry for bumping but your code gives me an ERROR 22! I have read CURL and it shows this :

CURLE_HTTP_RETURNED_ERROR (22)

This is returned if CURLOPT_FAILONERROR is set TRUE and the HTTP server returns an error code that is >= 400.

Sorry if I look like a nab but i actually never worked with callRemote.

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