Jump to content

about PHP sdk


SkatCh

Recommended Posts

hi guys :) please i need some help , i have a simple question how can add players names inside my website using php sdk i know how to use callRemote , i add this and it's working fine i can see 'done' in my debugString but what i need to do to finish the php file.

addEventHandler("onResourceStart", getRootElement(), 
function(theMap) 
    local playerList = getPlayersName() 
    if playerList then 
        callRemote("My website", returnFunction, playerList) 
    end 
end) 
  
function returnFunction(value) 
    if value ~= "ERROR" then 
       outputDebugString("done") 
    end 
end 
  
function getPlayersName() 
    local playerslist = {} 
    for i,p in ipairs (getElementsByType("player")) do 
        local thep = string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", "") 
        table.insert(playerslist,tostring(thep)) 
    end 
    return playerslist 
end 

Link to comment
callRemote ( 'http://www.yoursite.com/example.php/' .. toJSON ( playerNamesTable ), function ( value ) 
     if ( value == 'ok' ) then -- A var from your website meaning that worked. 
         outputDebugString ( 'Player list sent successfully.' ) 
     end 
end) 

But... You'll need to do a php script to receive and read the data.

Link to comment
bro i'm asking about the php part i already told you that my script is working fine , juts my question is what i need to type inside the php file.
  
  
$table = json_decode(str_replace("/example.php/","",$_SERVER["PHP_SELF"])); 
-- then you can whatever you want =D. 
  

Link to comment

sorry i don't undrestand can you explane to me.

this is my script ;

- server side

addEventHandler("onResourceStart", getRootElement(), 
function(theMap) 
    local playerList = getPlayersName() 
    if playerList then 
        callRemote("My website", returnFunction, playerList) 
    end 
end) 
  
function returnFunction(value) 
    if value ~= "ERROR" then 
       outputDebugString("done") 
    end 
end 
  
function getPlayersName() 
    local playerslist = {} 
    for i,p in ipairs (getElementsByType("player")) do 
        local thep = string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", "") 
        table.insert(playerslist,tostring(thep)) 
    end 
    return playerslist 
end 

and what i need to add inside the PHP

Link to comment
sorry i don't undrestand can you explane to me.

this is my script ;

- server side

addEventHandler("onResourceStart", getRootElement(), 
function(theMap) 
    local playerList = getPlayersName() 
    if playerList then 
        callRemote("My website", returnFunction, playerList) 
    end 
end) 
  
function returnFunction(value) 
    if value ~= "ERROR" then 
       outputDebugString("done") 
    end 
end 
  
function getPlayersName() 
    local playerslist = {} 
    for i,p in ipairs (getElementsByType("player")) do 
        local thep = string.gsub(getPlayerName(p), "#%x%x%x%x%x%x", "") 
        table.insert(playerslist,tostring(thep)) 
    end 
    return playerslist 
end 

and what i need to add inside the PHP

Hm, what i posted is just a way to get the table inside the PHP( in that case $table ).

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