Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 14/12/17 in all areas

  1. Would be nice if you told people what you did to fix it. Now you're just wasting everyone's time reading this topic.
    2 points
  2. [Tutorial] PHP SDK Hi everybody! Today, it's the new year and i will make a tutorial for this community... It's my gift This tutorial is to teach to you how use the PHP SDK and what we can do with it. The tutorial is offered by MTAScripts.net. Enjoy Summary What is the PHP SDK What we can do with it How to install How to use (SERVER) How to use (WEB) Download a demo What is the PHP SDK To begin, PHP is a dynamic programming language web. Why we say dynamic ? Because we can interact with the user and the webserver. The PHP is the principal dynamic language used in the web with the HTML. We can call this language "SUPER PHP" because he can make everything... Examples: Facebook.com MTASA.com Twitter.com Every forums... And more Okey, we know what is the PHP, now the SDK ? SDK mean Software Development Kit, it's a library allow to developpers to make his applications. Multiple plateforms propose his SDK. Just search on Google Examples: Facebook SDK Have so much... Search on Google (Google have too his SDK) For continue this tutorial, you must download the PHP SDK from MTA. Download What we can do with it The PHP SDK from MTA offer much possibility. You can do everything with it if you have a great imagination Examples ? Login the player When the user join the server and he must login, if he have allready a login in the forum. We login the player with it And if he don't have, we create a new account in the server AND in the forum Stats of the player If the player play in the server and if he have an account in the server and the forum. We can show the stats of the player in the forum. Facebook This is more hard but ITS POSSIBLE ! If the player is logged in Facebook, the server send a request in the web and the web send a request to Facebook. If Facebook confirm, Facebook send informations to the webserver and the server will return this. So if you have an login panel, you can make a button "Login with Facebook". I don't will write my ideas, find yours So you can see, if you have great ideas... You can make some big things How to install We attack ! First, you must: A website A FTP account of the website Client FTP (Filezilla, ...) The library PHP SDK For this tutorial, i will use a fake website. Now we can start You must create a folder in the root of your website. We will can him "MTA" Result: http://www.yourwebsite.com/MTA Now, we will create a new folder in the folder MTA We call him "sdk". Result: http://www.yourwebsite.com/MTA/sdk Now your extract the mtaphpsdk_0.4.zip file into sdk folder. You will have much files in this folder. The principal file is mta_sdk.php. Now you can access to the sdk via the web. Result: http://www.yourwebsite.com/MTA/sdk/mta_sdk.php If you don't have this result, try again Now, you create a new PHP File. Every PHP files have the extention ".php" or ".php3" (for the new version) You go to the MTA folder (http://www.yourwebsite.com/MTA) and you create a PHP file with the name "test" Result: http://www.yourwebsite.com/MTA/test.php You open this file with your text editor (Notepad++, Eclypse, Sublime Text, ...) We will include the library to the file. Before we start to include, you will start the php file. For do it you write the balise PHP Start: <?php Close: ?> <?php -- Your code here ?> We have start the PHP file, now we want include "mta_sdk.php" to our file "test.php". For do it, you must use the function include() For informations, every functions on PHP must finish with ";" Now we include the file using include() <?php require "sdk/mta_sdk.php"; ?> The library is successfully inclued, now our library are installed If you want be sure, you can access to this file (http://www.yourwebsite.com/MTA/test.php) If you have an error, try again How to use (Server) Ah The LUA part For start, you must create an resource in your server (local or not) We will call him... "test". You know how create an resource, if you don't know.. You are in the S.H.I.T In your resource, you will have 3 files Meta.xml Client.lua Server.lua <meta> <info name="My Test Script" author="FatalTerror" description="My first resource with PHP SDK" version="1.0.0" type="script"></info> <script src="client.lua" type="client"></script> <script src="server.lua" type="server"></script> </meta> Your client and server files are empy for a moment. Before we start ! You must give admin right to the resource, we will use a function require admin rights. You can do it with the Admin Panel or in the ACL.xml More infos: Wiki Page To start, you open the server.lua with your text editor and you write it. addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() end) function result() end Very simple code, 1 event when the resource start and a function "result". For call an file in the web, we use the function callRemote(). So, we will use this function with basic parameters. bool callRemote ( string URL, callback callbackFunction, [ arguments... ] ) Explain: The url is the PHP file you want call. The callback function is the function will call the website when the website return parameters. The arguments are the infos you will send to the website. Write it into the event handler. addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() callRemote ("http://www.yourwebsite.com/MTA/test.php", result, "Hello") end) This will send the argument "Hello" to the test.php file. We will see in the next step how get this argument in PHP file. Imagine... We send 1 argument to the web and we want get 1 other argument (the name of ... my cat, YES My cat rockz ! ) The PHP file will return this argument and we will get it via the result function. Remember? This function alone... (Poor function...) function result(value) if value ~= "ERROR" then end end end If have an value, we continue Now we have the cat's name, we show it with a simple outputChatBox() function result(value) if value ~= "ERROR" then outputChatBox("Hello Mr."..value, getRootElement()) end end Great, we have finish this part. You can see, ITS SIMPLE OF SIMPLE How to use (Web) The web part start ! Get ready...Prepare your keyboard . GO ! To start, open your test.php file with your text editor. And normally, we had already written the code in the file. After the include (remember?) we will get the argument sended via the server. How ? Using the mta::getInput() ! This function get arguments in an array. $table = mta::getInput(); Yeah ! We have our table with informations You are alive ? Okey ! $table = mta::getInput(); $text = $table[0]; Hm.. We get the argument of the table using this method and we set the argument into $text. Small check if have an value... $table = mta::getInput(); $text = $table[0]; if(isset($text)){ } Great.. We give a name of the cat ? Let me search.. Padawan ? $table = mta::getInput(); $text = $table[0]; if(isset($text)){ $cat = "Padawan"; } Now we return $cat to the server using the function mta::doReturn() $table = mta::getInput(); $text = $table[0]; if(isset($text)){ $cat = "Padawan"; mta::doReturn($cat); } Perfect ! Now when you start the script, he will send 1 info to the website and the website will return a thing... and this thing is the name of my cat And when the server have the name of the cat, he say hello to him Try it Schema Example 1: Use PHP/MYSQL In this example, we will see what we can do with the PHP & the database MySQL. Here, isn't the MySQL of the server but of the website. Require things: MySQL database Read the tuto OK, let's start. In this tutorial, we will make list of who is online in your server and store it on database. And for finish, show it. First thing we will do, create a table in the MYSQL Database. For that, we will store 3 things. ID Player name Serial Why the serial ? I don't know but it's usefull to store it SQL Code: CREATE TABLE `DATABASE_NAME`.`players` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `player` TEXT NOT NULL , `serial` TEXT NOT NULL ) ENGINE = MYISAM ; Remplace DATABASE_NAME per the database name... I don't explain this code cuz it's to much simple. I think you will learn it fast. Create a new resource on your server. We call him "web". In this resource, we have 2 files. Meta.xml Server.lua On server.lua, we will put an event, when the map change (It's more usefull for race servers). A council ! Never put an callRemote() when the player join ! Why ? It makes lag. If you have a big dedicated server, you can do it. addEventHandler("onGamemodeMapStart", getRootElement(), function(theMap) end) Well, it's okey for this step. Now we will create a new function to get an table with the player name without his hexcode. addEventHandler("onGamemodeMapStart", getRootElement(), function(theMap) 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 Not very hard for the moment. We create an callRemote in the event. Like this: addEventHandler("onGamemodeMapStart", getRootElement(), function(theMap) local playerList = getPlayersName() if playerList then callRemote("http://wwww.website.com/MTA/players.php", returnFunction, playerList) end end) function returnFunction(value) if value ~= "ERROR" then 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 Put a small message to check if the player list is successfully save with outputDebugString(). Damn, let's start with the PHP. Create a new document PHP in your website like that: http://www.website.com/MTA/players.php In this document, you include the PHP SDK AND the MySQL Connexion ! What is that? You must put 2 lines of code to connect the page to the MySQL database. The line are: $base = mysql_connect ('127.0.0.1', 'USERNAME', 'PASSWORD'); mysql_select_db ('DATABASE_NAME', $base); You check if you have any errors, just access to your page. TO BE CONTINUED... (I go to school ) It's the end of this tutorial, i hope it will be useful Good luck and have fun © MTAScripts.net, All rights reserved
    1 point
  3. تمام مشكورين الجميع المشكله طلعت باسم الامر
    1 point
  4. onClientResourceStart > triggerServerEvent > get all the paintjobs from a table > triggerClientEvent
    1 point
  5. Or you can use onClientResourceStart client side, so you can skip on a triggerClientEvent.
    1 point
  6. جميل جداً, الأفضل تشفره لتفادي سرقة المود و إزالة الحقوق
    1 point
  7. فرحت فرح لما سويت مود مكون من سطرين بس addEventHandler("onPlayerSpawn", root, function() outputChatBox( "You Spawned", source, 255, 0, 0, true ) end)
    1 point
  8. Others had the same problem with the same resource: 1) https://forum.multitheftauto.com/topic/62052-problem-userpanel/ (don't worry, wasn't originally leaked..) 2) https://forum.multitheftauto.com/topic/52411-xiti-userpanel/ It's called Xiti userpanel, was initially released for free by it's author (Xiti/Matheusz) but then others started to modify it, to try separate it from the Race resource (and some of them to then try to sell it as their own..) but this doomed the resource. After that, bugged versions started to circulate, and you got a variant of them. The general state of the resource you got is so bad, you cannot know what exactly they ripped out to try turn a Race userpanel into a general/DM userpanel (as you're on about kills and more) so it's not easy to find the problem in the bloated codebase, even it's likely to be a structural problem because I think whichever amateur converted the userpanel didn't rewrite what needed to be rewritten. Also the best idea is to ask the original author, @xiti for support on the original version. I don't think anyone should/will help you with the modified/ruined version. @EMillion
    1 point
  9. مبرمج حياة واقعية؟ جديدة عاد
    1 point
  10. Ye leaked come visit us now and see if leaked or no ofc stolen from you or .......
    1 point
  11. leaked from your ass i think go check SAEG then say that stuff
    1 point
  12. ذي كانت فكرتي أنا وكونوليل قبل سنة ونص تقريباً لكن ما فضيت لها
    1 point
  13. Eu ensino isto de graça mais ninguém nunca tem realmente vontade de aprender, eu desisto se quiser aprenda pro conta própria meu tempo não é como lixo. e eu acho que será difícil de você achar alguém aqui pois a maioria dos desenvolvedores de conteúdo brasileiro ativos tem seus próprios projetos e estão ocupado com eles ao menos que o dinheiro fale mais alto para ele é claro.
    1 point
×
×
  • Create New...