Lorenc
Posts : 1 Active Points : 3 Join date : 2010-10-29
| Subject: [TUT]How to make a register system in dialog (SAMP GUI) Sun Oct 31, 2010 8:53 am | |
| Register system in DialogBy LorencSo what is this?Its a tutorial about how to make a register system in dialog. I made this because i found one which was abit faulty and to be honest in my opinion it was crap. In this tutorial I will explain most of it. StartingOk in order to make this we will need 2 includes. Dini & Dudb. - Code:
-
#include <dini> #include <dudb> So just hit compile and you might get a warning like: - Code:
-
warning 203: symbol is never used: "ret_memcpy" To prevent that warning just insert this code to the top of your script: - Code:
-
#pragma unused ret_memcpy ^ what that does is that it tells the script that it will be unused for this moment ScriptingGreat we're on the 2nd step now! so we got our Dudb & Dini working, lets get ready for the real scripting . - Code:
-
enum pInfo { pAdminLevel, pCash, pScore, } new PlayerInfo[MAX_PLAYERS][pInfo]; ^ What in the hell is that? It's an enum that stores things into one variable You might get one warning but tho it will be gone throughout scripting. Next we will need to make gPlayerLogged, that means if the player is logged or not. - Code:
-
new gPlayerLogged[MAX_PLAYERS]; and the last define is the userfile, where the userfile will be. - Code:
-
#define SERVER_USER_FILE "myserver/%s.ini" ___ Lets move to the onplayer connect callback Add these codes to the call back. - Code:
-
gPlayerLogged[playerid] = 0; new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if (!dini_Exists(file)) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave"); } if(fexist(file)) { ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave"); } ^ what this does is that you connects you as a not logged in person and shows a dialog for if your logged or not logged. next we have to go to the OnPlayerDisconnect Callback and put: - Code:
-
new name[MAX_PLAYER_NAME], file[256]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(gPlayerLogged[playerid] == 1) { dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]); dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]); dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]); } gPlayerLogged[playerid] = 0; ^What that will do for us is save our new status in-game plus it logs you out. DialogsWe are up to making to dialogs configure now! so lets start off with the register dialog. Navigate to OnDialogResponse which is at the bottom of the script usally and add this code. - Code:
-
if (dialogid == 1) { new name[MAX_PLAYER_NAME], file[256], string[128]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(!response) return Kick(playerid); if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave"); dini_Create(file); dini_IntSet(file, "Password", udb_hash(inputtext)); dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0); dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500); dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0); format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext); SendClientMessage(playerid, COLOR_YELLOW, string); gPlayerLogged[playerid] = 1; } ^ That configures the dialog we've got for the register Now lets press enter at the end of the dialog 1 (register). Below it paste: - Code:
-
if (dialogid == 2) { new name[MAX_PLAYER_NAME], file[256], string[128]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name); if(!response) return Kick(playerid); if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave"); new tmp; tmp = dini_Int(file, "Password"); if(udb_hash(inputtext) != tmp) { SendClientMessage(playerid, COLOR_RED, "Wrong PW sir."); ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave"); } else { gPlayerLogged[playerid] = 1; PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel"); SetPlayerScore(playerid, PlayerInfo[playerid][pScore]); GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid)); SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!"); } } ^ That configures the dialog we've got for the login SummaryThere you go you've just got a dialog reg/log system. You can now claim it as yours and edit it. Well done. Please note if i made a lil error tell me, i was acctaully trying to get the codes outta my gm. I hope i didnt fail something. If i did, tell me ill fix it. CreditsLorenc - Mostly creating TUT & Script parts. -Rebel Son- - Got some codes off him. Dracoblue - DINI & Dudb SAMP for their new gui. Bugs bugs bugs, tell me if there is one, ill try my hardest to fix it. If i made mistakes in this tut tell me soz for awful english | |
|
Cold Moderator
Posts : 12 Active Points : 26 Join date : 2010-10-24
| Subject: Re: [TUT]How to make a register system in dialog (SAMP GUI) Mon Nov 01, 2010 8:38 pm | |
| Nice tut! I might use it :X P.S.: Please use - Code:
-
Code here FOr future Pawno Posts | |
|
Dragonlord
Posts : 1 Active Points : 1 Join date : 2011-08-27
| Subject: Re: [TUT]How to make a register system in dialog (SAMP GUI) Sat Aug 27, 2011 9:51 pm | |
| HEy, i got some errors, can u plz help me with them? - Quote :
- C:\Users\Daniel\Desktop\samp 0.3c\filterscripts\cmds.pwn(96) : error 017: undefined symbol "gPlayerLogged"
C:\Users\Daniel\Desktop\samp 0.3c\filterscripts\cmds.pwn(96) : warning 215: expression has no effect C:\Users\Daniel\Desktop\samp 0.3c\filterscripts\cmds.pwn(96) : error 001: expected token: ";", but found "]" C:\Users\Daniel\Desktop\samp 0.3c\filterscripts\cmds.pwn(96) : error 029: invalid expression, assumed zero C:\Users\Daniel\Desktop\samp 0.3c\filterscripts\cmds.pwn(96) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
4 Errors. | |
|
Sponsored content
| Subject: Re: [TUT]How to make a register system in dialog (SAMP GUI) | |
| |
|