SkatCh Posted January 2, 2015 Posted January 2, 2015 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
RenanPG Posted January 3, 2015 Posted January 3, 2015 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.
SkatCh Posted January 3, 2015 Author Posted January 3, 2015 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.
RenanPG Posted January 3, 2015 Posted January 3, 2015 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.
SkatCh Posted January 3, 2015 Author Posted January 3, 2015 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
RenanPG Posted January 3, 2015 Posted January 3, 2015 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 ).
MTA Team botder Posted January 3, 2015 MTA Team Posted January 3, 2015 The URL has a character limit (I think it was 2048 characters). You should use the php stream php://input
SkatCh Posted January 3, 2015 Author Posted January 3, 2015 bro can explane more what i need to write inside the PHP file
MTA Team botder Posted January 3, 2015 MTA Team Posted January 3, 2015 include( "mta_sdk.php" ); $input = mta::getInput(); Taken from https://wiki.multitheftauto.com/wiki/CallRemote#Example
SkatCh Posted January 3, 2015 Author Posted January 3, 2015 didn't work please any one from MTA sa team help me.
Addlibs Posted January 3, 2015 Posted January 3, 2015 You don't really need to use the PHP SDK to display players who are online. All you'd need to do is dbConnect and dbExec to truncate (clear) the table and insert all online players every now and then. The website can then use PDO or Mysqli to access the database and retrieve the online players, and write them to the HTML code.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now