![]() |
Script Server [ Login / Register ] - Printable Version +- Post4VPS Forum | Free VPS Provider (https://post4vps.com) +-- Forum: Geek World (https://post4vps.com/Forum-Geek-World) +--- Forum: Scripting & Programming (https://post4vps.com/Forum-Scripting-Programming) +--- Thread: Script Server [ Login / Register ] (/Thread-Script-Server-Login-Register) |
Script Server [ Login / Register ] - PemburuHantu - 08-06-2019 Introduce Hello! I am new to this forum. I made a SAMP server script. My friend and I have created our server, and it turns out that the server is in great demand, because I haven't received a report that the server has a bug, so I decided to use my time helping people, who want to learn server scripts Now in this tutorial I will create a [Login / Register] system, using Y_INI. * What is Y_INI? - [font=open_sansregular, Tahoma, Arial, sans-serif]Y_INI is a reader and writes data .INI or better known as '' FILE MANAGER SYSTEM '' Many SAMP users use Y_INI to create a LOGIN / REGISTER system[/font] * Developer of Y_INI [font=arial, sans-serif]Alex "Y_Less" Cole[/font] [font=open_sansregular, Tahoma, Arial, sans-serif]Tutorial[/font] 1. Add Y_INI include to the top of your script. PHP Code: #include <YSI/y_ini> 2. Lets define the dialogs. PHP Code: #define DIALOG_REGISTER 1 3. Lets define the Colors. You can found the color here https://htmlcolorcodes.com/ PHP Code: #define COL_WHITE "{FFFFFF} 4. Now define the 'Path' for .INI file. PHP Code: #define PATH "/Users/%s.ini" 5. Now create enum, for store our variables. PHP Code: enum pInfo 6. Now create the function for load the player's data. PHP Code: forward LoadUser_data(playerid,name[],value[]); 7. Now create stock for UserPath. The stock function 'UserPath' is merely going to 'grab' the 'PATH' of the User's file. PHP Code: stock UserPath(playerid) 8. Add this code bellow your previous stock function. ( UserPath ) * The stock above is a simple 'hasher', and will be used to hash passwords, Credits to Dracoblue. PHP Code: stock udb_hash(buf[]) { 9. Now move to 'OnPlayerConnect' callback to check whether the player is register or not. PHP Code: public OnPlayerConnect(playerid) 10. Now move to 'OnDialogResponse' for make dialog in register / login. PHP Code: public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) [!] Instead of using the 'if' statement to define my dialogs, I've used cases as they seem to take less space and are supposedly 'faster'. The (!response) is the function if the first Button hasn't been clicked, it will then kick the player. The if(!strlen(inputtext)) explains if nothing has been entered into the dialog (input), you would then be prompted to another dialog which shows you 'Incorrect Password'. If all goes well, the function INI_Open is then 'executed' which loads and opens the Userfile. Once open, the function 'INI_WriteInt' is then called and starts writing the data into the userfile. The udb_hash would generate a hash code from the player's inputtext (what you've typed). And after all this is completed, it is then closed by 'INI_Close' function. Once finished, you will then be prompted to the 'Login' dialog. In 'DIALOG_LOGIN', if the response is false (you have clicked 'QUIT), you would then be kicked. If given the correct information (password provided), the INI_Parsefile function would then scan and load your player's data. 11. Don't forget, you would need a way to save those variables. The OnPlayerDisconnect callback simply re-opens the files, write what-ever values which has been stored and then closes it. PHP Code: public OnPlayerDisconnect(playerid, reason) 12. Finally, add this to OnPlayerDeath to add value(s) to kills and deaths. PHP Code: public OnPlayerDeath(playerid, killerid, reason) [font=open_sansregular, Tahoma, Arial, sans-serif]Y_INI https://github.com/Southclaws/YSI-4.0/blob/master/YSI_Storage/y_ini.inc[/font] [font=open_sansregular, Tahoma, Arial, sans-serif][font=open_sansregular, Tahoma, Arial, sans-serif][font=open_sansregular, Tahoma, Arial, sans-serif]Credits[/font][/font][/font] [font=open_sansregular, Tahoma, Arial, sans-serif][font=open_sansregular, Tahoma, Arial, sans-serif][font=open_sansregular, Tahoma, Arial, sans-serif]Y-Less for 'Y_INI'[/font][/font][/font] RE: Script Server [ Login / Register ] - hamed - 08-06-2019 man . samp scripts is c++? or other lang ? can u help me in create a rpg server in samp? i'm mta scriptr and i'm lua scriptr . if you want help about lua script tell me anytime ![]() RE: Script Server [ Login / Register ] - PemburuHantu - 08-06-2019 (08-06-2019, 11:58 AM)hamed Wrote: man . samp scripts is c++? or other lang ? can u help me in create a rpg server in samp? i'm mta scriptr and i'm lua scriptr . if you want help about lua script tell me anytime Hi hamed. To learn the basics of server scripts, you can learn at [font=arial, sans-serif][url=https://forum.sa-mp.com/][/url]https://forum.sa-mp.com/ [/font]and also if you have problems with your script, you can ask for help there, we are ready to help. |