In this dialog you create new password, and i click "Daftar" to create new account |
in this dialog you choose your character sex, and i click "OK" to next |
In this dialog you can choose your character age |
#define Register 1 #define Email 2 #define Sex 3 #define Age 4 #define Orgin 5 #define Mood 6 #define Login 7 public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == Register) { if(!response) return Kick(playerid); if(response) { new string[512],ip[16],str[250],hour,minute,second,day,month,year; gettime(hour,minute,second); getdate(year,month,day); GetPlayerIp(playerid, ip, sizeof(ip)); format(str, sizeof str,"[%d:%d:%d][%d:%d:%d]", day, month, year, hour, minute, second); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); //--[Basic Info] INI_WriteString(File,"UserName",GetName(playerid)); INI_WriteString(File,"IP",ip); INI_WriteString(File,"Email","Unset"); INI_WriteString(File,"Registration Date",str); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteString(File,"LastLogin","Unset"); INI_WriteInt(File,"Age",0); INI_WriteString(File,"Orgin","Unset"); INI_WriteInt(File,"SexShown",0); INI_WriteInt(File,"Sex",6); INI_WriteInt(File,"ChangeSexOnly",0); INI_WriteInt(File,"LogOnAttempt",0); INI_WriteInt(File,"Seconds",PlayerInfo[playerid][pSec]); INI_WriteInt(File,"Minutes",PlayerInfo[playerid][pMin]); INI_WriteInt(File,"Hours",PlayerInfo[playerid][pHours]); INI_WriteInt(File,"Days",PlayerInfo[playerid][pDay]); INI_WriteInt(File,"Years",PlayerInfo[playerid][pYears]); INI_WriteString(File,"Mood"," "); INI_WriteInt(File,"MoodSpawn",0); //--[Player Commands] INI_WriteInt(File,"ChangeView",PlayerInfo[playerid][pChangeView]); INI_WriteInt(File,"ChangeView2",PlayerInfo[playerid][pChangeView2]); INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]); INI_WriteInt(File,"Duty",PlayerInfo[playerid][pDuty]); INI_WriteInt(File,"Frozen",PlayerInfo[playerid][pFrozen]); INI_WriteInt(File,"Mute",PlayerInfo[playerid][pMute]); INI_WriteInt(File,"Spectating",PlayerInfo[playerid][pSpectating]); INI_WriteInt(File,"Warning",PlayerInfo[playerid][pWarning]); //--[Player Shopping Items] INI_WriteInt(File,"CD-Player",PlayerInfo[playerid][pCDMP3Player]); INI_WriteInt(File,"FishingToolBox",PlayerInfo[playerid][pFishTool]); INI_WriteInt(File,"Watch",PlayerInfo[playerid][pWatch]); INI_WriteInt(File,"Beers",PlayerInfo[playerid][pBeers]); INI_WriteInt(File,"Cigs",PlayerInfo[playerid][pCigarettes]); INI_WriteInt(File,"Lighter",PlayerInfo[playerid][pLighter]); INI_WriteInt(File,"Helmet",PlayerInfo[playerid][pHelmet]); //--[Player Varables] INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"VIP",0); INI_WriteInt(File,"Money", WelcomeGift); INI_WriteInt(File,"BankAccount",0); INI_WriteInt(File,"Score",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"WantedLevel",0); INI_WriteInt(File,"STD's",0); INI_WriteInt(File,"Smoked",0); INI_WriteInt(File,"Cancer",0); INI_WriteInt(File,"Health",0); INI_WriteInt(File,"Armour",0); //--[Pos] INI_WriteFloat(File,"X",1960.9506); INI_WriteFloat(File,"Y",1343.3920); INI_WriteFloat(File,"Z",15.3746); INI_WriteFloat(File,"Angle",89.1425); INI_WriteInt(File,"Interior",0); INI_WriteInt(File,"VirtualWorld",0); INI_Close(File); ShowPlayerDialog(playerid,Email,DIALOG_STYLE_INPUT,"Email Dialog","Please Register Your Email To Ensure Password Recovery","OK","Cancel"); format(string, 512, COLOR_YELLOW"<<Info>>"COLOR_WHITE" Name:"COLOR_ORANGE" %s"COLOR_WHITE" Password:"COLOR_ORANGE" %s"COLOR_WHITE" Has Been"COLOR_RED" Successfully"COLOR_WHITE" Created !!", GetName(playerid), inputtext); SendClientMessage(playerid, -1, string); GivePlayerMoney(playerid,WelcomeGift); format(string, 512, COLOR_YELLOW"<<Player Info>>"COLOR_WHITE" You Have Been Awarded A Welcome Gift Of"COLOR_GREEN" $2000"COLOR_WHITE" !!"); SendClientMessage(playerid,-1, string); } return 1; } if(dialogid == Email) { if(!response) return ShowPlayerDialog(playerid,Email,DIALOG_STYLE_INPUT,"Email Dialog","Please Register Your Email To Ensure Password Recovery!\n"COLOR_RED"Please Enter Email To Continue!","OK","Cancel"); if(response) { if(strfind(inputtext,"@",true)!= -1 && strfind(inputtext,".",true)!= -1) { format(PlayerInfo[playerid][pEmail], 255, "%s", inputtext); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteString(File,"Email",(inputtext)); INI_Close(File); GameTextForPlayer(playerid, "~w~Email ~g~Valid",1000,6); ShowPlayerDialog(playerid,Sex,DIALOG_STYLE_LIST,"Please Select Your Gender To Continue","Male\nFemale","Ok","Cancel"); return 1; } else { ShowPlayerDialog(playerid,Email,DIALOG_STYLE_INPUT,"Email Dialog","Please Register Your Email To Ensure Password Recovery!\n"COLOR_RED"Invalid Email!","OK","Cancel"); GameTextForPlayer(playerid, "~w~Email ~r~Invalid",1000,6); } } } if(dialogid == Sex) { if(!response) return ShowPlayerDialog(playerid,Sex,DIALOG_STYLE_LIST,"Please Select Your Gender To Continue","Male\nFemale","Ok","Cancel"); if(response) { switch(listitem) { case 0: { if(PlayerInfo[playerid][pChangeSexOnly] == 0) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteInt(File,"Sex",1); INI_Close(File); PlayerInfo[playerid][pSex] = 1; ShowPlayerDialog(playerid,Age,DIALOG_STYLE_INPUT,"---------Age--------","Please Enter Your Age To Continue","Ok","Cancel"); } else { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteInt(File,"Sex",1); INI_Close(File); PlayerInfo[playerid][pSex] = 1; PlayerInfo[playerid][pChangeSexOnly] = 0; } return 1; } case 1: { if(PlayerInfo[playerid][pChangeSexOnly] == 0) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteInt(File,"Sex",0); INI_Close(File); PlayerInfo[playerid][pSex] = 0; ShowPlayerDialog(playerid,Age,DIALOG_STYLE_INPUT,"------Age------","Please Enter Your Age To Continue","Ok","Cancel"); } else { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteInt(File,"Sex",0); INI_Close(File); PlayerInfo[playerid][pSex] = 0; PlayerInfo[playerid][pChangeSexOnly] = 0; } } } } } if(dialogid == Age) { if(!response) return ShowPlayerDialog(playerid,Age,DIALOG_STYLE_INPUT,"--------Age--------","Please Enter Your Age To Continue","Ok","Cancel"); if(response) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteString(File,"Age",(inputtext)); INI_Close(File); ShowPlayerDialog(playerid,Orgin,DIALOG_STYLE_LIST,"--------Location--------","UK\nUSA","Ok","Cancel"); } } if(dialogid == Orgin) { if(!response) return ShowPlayerDialog(playerid,Orgin,DIALOG_STYLE_LIST,"--------Location--------","UK\nUSA","Ok","Cancel"); if(response) { switch(listitem) { case 0: { format(PlayerInfo[playerid][pOrgin], 255, "%s", "UK"); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteString(File,"Orgin","UK"); INI_Close(File); } case 1: { format(PlayerInfo[playerid][pOrgin], 255, "%s", "USA"); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteString(File,"Orgin","USA"); INI_Close(File); } } } } if(dialogid == Login) { if(!response) return Kick(playerid); if(response) { if(udb_hash(inputtext) != PlayerInfo[playerid][pPass]) { if(PlayerInfo[playerid][pLogOnAttempt] == 3) { Kick(playerid); PlayerInfo[playerid][pLogOnAttempt] = 0; } if(PlayerInfo[playerid][pLogOnAttempt] == 2) { ShowPlayerDialog(playerid, Login, DIALOG_STYLE_PASSWORD,"Login System","Welcome Back. This Account Is Registered !!\nInsert Your Password To Login Into Your Account.\n"COLOR_RED"Incorrect Password!\n"COLOR_RED"1 Attempts Left!\n"COLOR_RED"Try Caps Lock!","Login","Quit"); PlayerInfo[playerid][pLogOnAttempt] = 3; } if(PlayerInfo[playerid][pLogOnAttempt] == 1) { ShowPlayerDialog(playerid, Login, DIALOG_STYLE_PASSWORD,"Login System","Welcome Back. This Account Is Registered !!\nInsert Your Password To Login Into Your Account.\n"COLOR_RED"Incorrect Password!\n"COLOR_RED"2 Attempts Left!\n"COLOR_RED"Try Caps Lock!","Login","Quit"); PlayerInfo[playerid][pLogOnAttempt] = 2; } if(PlayerInfo[playerid][pLogOnAttempt] == 0) { ShowPlayerDialog(playerid, Login, DIALOG_STYLE_PASSWORD,"Login System","Welcome Back. This Account Is Registered !!\nInsert Your Password To Login Into Your Account.\n"COLOR_RED"Incorrect Password!\n"COLOR_RED"3 Attempts Left!\n"COLOR_RED"Try Caps Lock!","Login","Quit"); PlayerInfo[playerid][pLogOnAttempt] = 1; } } else { INI_ParseFile(UserPath(playerid),"LoadUserAccounts", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]); SetPlayerPos(playerid,PlayerInfo[playerid][X],PlayerInfo[playerid][Y],PlayerInfo[playerid][Z]); SetPlayerFacingAngle(playerid,PlayerInfo[playerid][Angle]); SetPlayerInterior(playerid,PlayerInfo[playerid][Interior]); SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][VirtualWorld]); SendClientMessage(playerid,-1,""COLOR_ORANGE"Welcome Back!"COLOR_WHITE" You Have Been"COLOR_RED" Successfully"COLOR_WHITE" Logged In !!"); new string[128]; format(string, sizeof(string),COLOR_YELLOW"<<Player>>"COLOR_ORANGE" %s"COLOR_WHITE" Has Joined The Server !!", GetName(playerid)); SendClientMessageToAll(-1, string); } return 1; } } return 1; }
Try This,
Код:
#define Register 1 #define Email 2 #define Sex 3 #define Age 4 #define Orgin 5 #define Mood 6 #define Login 7 public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == Register) { if(!response) return Kick(playerid); if(response) { new string[512],ip[16],str[250],hour,minute,second,day,month,year; gettime(hour,minute,second); getdate(year,month,day); GetPlayerIp(playerid, ip, sizeof(ip)); format(str, sizeof str,"[%d:%d:%d][%d:%d:%d]", day, month, year, hour, minute, second); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); //--[Basic Info] INI_WriteString(File,"UserName",GetName(playerid)); INI_WriteString(File,"IP",ip); INI_WriteString(File,"Email","Unset"); INI_WriteString(File,"Registration Date",str); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteString(File,"LastLogin","Unset"); INI_WriteInt(File,"Age",0); INI_WriteString(File,"Orgin","Unset"); INI_WriteInt(File,"SexShown",0); INI_WriteInt(File,"Sex",6); INI_WriteInt(File,"ChangeSexOnly",0); INI_WriteInt(File,"LogOnAttempt",0); INI_WriteInt(File,"Seconds",PlayerInfo[playerid][pSec]); INI_WriteInt(File,"Minutes",PlayerInfo[playerid][pMin]); INI_WriteInt(File,"Hours",PlayerInfo[playerid][pHours]); INI_WriteInt(File,"Days",PlayerInfo[playerid][pDay]); INI_WriteInt(File,"Years",PlayerInfo[playerid][pYears]); INI_WriteString(File,"Mood"," "); INI_WriteInt(File,"MoodSpawn",0); //--[Player Commands] INI_WriteInt(File,"ChangeView",PlayerInfo[playerid][pChangeView]); INI_WriteInt(File,"ChangeView2",PlayerInfo[playerid][pChangeView2]); INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]); INI_WriteInt(File,"Duty",PlayerInfo[playerid][pDuty]); INI_WriteInt(File,"Frozen",PlayerInfo[playerid][pFrozen]); INI_WriteInt(File,"Mute",PlayerInfo[playerid][pMute]); INI_WriteInt(File,"Spectating",PlayerInfo[playerid][pSpectating]); INI_WriteInt(File,"Warning",PlayerInfo[playerid][pWarning]); //--[Player Shopping Items] INI_WriteInt(File,"CD-Player",PlayerInfo[playerid][pCDMP3Player]); INI_WriteInt(File,"FishingToolBox",PlayerInfo[playerid][pFishTool]); INI_WriteInt(File,"Watch",PlayerInfo[playerid][pWatch]); INI_WriteInt(File,"Beers",PlayerInfo[playerid][pBeers]); INI_WriteInt(File,"Cigs",PlayerInfo[playerid][pCigarettes]); INI_WriteInt(File,"Lighter",PlayerInfo[playerid][pLighter]); INI_WriteInt(File,"Helmet",PlayerInfo[playerid][pHelmet]); //--[Player Varables] INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"VIP",0); INI_WriteInt(File,"Money", WelcomeGift); INI_WriteInt(File,"BankAccount",0); INI_WriteInt(File,"Score",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"WantedLevel",0); INI_WriteInt(File,"STD's",0); INI_WriteInt(File,"Smoked",0); INI_WriteInt(File,"Cancer",0); INI_WriteInt(File,"Health",0); INI_WriteInt(File,"Armour",0); //--[Pos] INI_WriteFloat(File,"X",1960.9506); INI_WriteFloat(File,"Y",1343.3920); INI_WriteFloat(File,"Z",15.3746); INI_WriteFloat(File,"Angle",89.1425); INI_WriteInt(File,"Interior",0); INI_WriteInt(File,"VirtualWorld",0); INI_Close(File); ShowPlayerDialog(playerid,Email,DIALOG_STYLE_INPUT,"Email Dialog","Please Register Your Email To Ensure Password Recovery","OK","Cancel"); format(string, 512, COLOR_YELLOW"<<Info>>"COLOR_WHITE" Name:"COLOR_ORANGE" %s"COLOR_WHITE" Password:"COLOR_ORANGE" %s"COLOR_WHITE" Has Been"COLOR_RED" Successfully"COLOR_WHITE" Created !!", GetName(playerid), inputtext); SendClientMessage(playerid, -1, string); GivePlayerMoney(playerid,WelcomeGift); format(string, 512, COLOR_YELLOW"<<Player Info>>"COLOR_WHITE" You Have Been Awarded A Welcome Gift Of"COLOR_GREEN" $2000"COLOR_WHITE" !!"); SendClientMessage(playerid,-1, string); } return 1; } if(dialogid == Email) { if(!response) return ShowPlayerDialog(playerid,Email,DIALOG_STYLE_INPUT,"Email Dialog","Please Register Your Email To Ensure Password Recovery!\n"COLOR_RED"Please Enter Email To Continue!","OK","Cancel"); if(response) { if(strfind(inputtext,"@",true)!= -1 && strfind(inputtext,".",true)!= -1) { format(PlayerInfo[playerid][pEmail], 255, "%s", inputtext); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteString(File,"Email",(inputtext)); INI_Close(File); GameTextForPlayer(playerid, "~w~Email ~g~Valid",1000,6); ShowPlayerDialog(playerid,Sex,DIALOG_STYLE_LIST,"Please Select Your Gender To Continue","Male\nFemale","Ok","Cancel"); return 1; } else { ShowPlayerDialog(playerid,Email,DIALOG_STYLE_INPUT,"Email Dialog","Please Register Your Email To Ensure Password Recovery!\n"COLOR_RED"Invalid Email!","OK","Cancel"); GameTextForPlayer(playerid, "~w~Email ~r~Invalid",1000,6); } } } if(dialogid == Sex) { if(!response) return ShowPlayerDialog(playerid,Sex,DIALOG_STYLE_LIST,"Please Select Your Gender To Continue","Male\nFemale","Ok","Cancel"); if(response) { switch(listitem) { case 0: { if(PlayerInfo[playerid][pChangeSexOnly] == 0) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteInt(File,"Sex",1); INI_Close(File); PlayerInfo[playerid][pSex] = 1; ShowPlayerDialog(playerid,Age,DIALOG_STYLE_INPUT,"---------Age--------","Please Enter Your Age To Continue","Ok","Cancel"); } else { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteInt(File,"Sex",1); INI_Close(File); PlayerInfo[playerid][pSex] = 1; PlayerInfo[playerid][pChangeSexOnly] = 0; } return 1; } case 1: { if(PlayerInfo[playerid][pChangeSexOnly] == 0) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteInt(File,"Sex",0); INI_Close(File); PlayerInfo[playerid][pSex] = 0; ShowPlayerDialog(playerid,Age,DIALOG_STYLE_INPUT,"------Age------","Please Enter Your Age To Continue","Ok","Cancel"); } else { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteInt(File,"Sex",0); INI_Close(File); PlayerInfo[playerid][pSex] = 0; PlayerInfo[playerid][pChangeSexOnly] = 0; } } } } } if(dialogid == Age) { if(!response) return ShowPlayerDialog(playerid,Age,DIALOG_STYLE_INPUT,"--------Age--------","Please Enter Your Age To Continue","Ok","Cancel"); if(response) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteString(File,"Age",(inputtext)); INI_Close(File); ShowPlayerDialog(playerid,Orgin,DIALOG_STYLE_LIST,"--------Location--------","UK\nUSA","Ok","Cancel"); } } if(dialogid == Orgin) { if(!response) return ShowPlayerDialog(playerid,Orgin,DIALOG_STYLE_LIST,"--------Location--------","UK\nUSA","Ok","Cancel"); if(response) { switch(listitem) { case 0: { format(PlayerInfo[playerid][pOrgin], 255, "%s", "UK"); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteString(File,"Orgin","UK"); INI_Close(File); } case 1: { format(PlayerInfo[playerid][pOrgin], 255, "%s", "USA"); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player-Data"); INI_WriteString(File,"Orgin","USA"); INI_Close(File); } } } } if(dialogid == Login) { if(!response) return Kick(playerid); if(response) { if(udb_hash(inputtext) != PlayerInfo[playerid][pPass]) { if(PlayerInfo[playerid][pLogOnAttempt] == 3) { Kick(playerid); PlayerInfo[playerid][pLogOnAttempt] = 0; } if(PlayerInfo[playerid][pLogOnAttempt] == 2) { ShowPlayerDialog(playerid, Login, DIALOG_STYLE_PASSWORD,"Login System","Welcome Back. This Account Is Registered !!\nInsert Your Password To Login Into Your Account.\n"COLOR_RED"Incorrect Password!\n"COLOR_RED"1 Attempts Left!\n"COLOR_RED"Try Caps Lock!","Login","Quit"); PlayerInfo[playerid][pLogOnAttempt] = 3; } if(PlayerInfo[playerid][pLogOnAttempt] == 1) { ShowPlayerDialog(playerid, Login, DIALOG_STYLE_PASSWORD,"Login System","Welcome Back. This Account Is Registered !!\nInsert Your Password To Login Into Your Account.\n"COLOR_RED"Incorrect Password!\n"COLOR_RED"2 Attempts Left!\n"COLOR_RED"Try Caps Lock!","Login","Quit"); PlayerInfo[playerid][pLogOnAttempt] = 2; } if(PlayerInfo[playerid][pLogOnAttempt] == 0) { ShowPlayerDialog(playerid, Login, DIALOG_STYLE_PASSWORD,"Login System","Welcome Back. This Account Is Registered !!\nInsert Your Password To Login Into Your Account.\n"COLOR_RED"Incorrect Password!\n"COLOR_RED"3 Attempts Left!\n"COLOR_RED"Try Caps Lock!","Login","Quit"); PlayerInfo[playerid][pLogOnAttempt] = 1; } } else { INI_ParseFile(UserPath(playerid),"LoadUserAccounts", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]); SetPlayerPos(playerid,PlayerInfo[playerid][X],PlayerInfo[playerid][Y],PlayerInfo[playerid][Z]); SetPlayerFacingAngle(playerid,PlayerInfo[playerid][Angle]); SetPlayerInterior(playerid,PlayerInfo[playerid][Interior]); SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][VirtualWorld]); SendClientMessage(playerid,-1,""COLOR_ORANGE"Welcome Back!"COLOR_WHITE" You Have Been"COLOR_RED" Successfully"COLOR_WHITE" Logged In !!"); new string[128]; format(string, sizeof(string),COLOR_YELLOW"<<Player>>"COLOR_ORANGE" %s"COLOR_WHITE" Has Joined The Server !!", GetName(playerid)); SendClientMessageToAll(-1, string); } return 1; } } return 1; } |
#include <a_samp>
#include <a_mysql>
#include <zcmd>
#include <foreach>
#include "../include/gl_spawns.inc"
#include "../include/gl_common.inc"
#include <float>
#include <core>
#include <sscanf2>
#include <streamer>
#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_DATABASE "myserver"
#define MYSQL_PASSWORD ""
#define SPAWN_X 1685.6680
#define SPAWN_Y -2332.9236
#define SPAWN_Z 13.5469
#define SPAWN_A 2.3834
#define COLOR_WHITE 0xFFFFFFFF
#define GAMETEXT_COLOR 1
enum
{
LoginDialog,
RegisterDialog,
AgeDialog,
GenderDialog,
EmailDialog
};
new
mysql;
native WP_Hash(buffer[], len, const str[]);
enum PlayerData
{
ID,
Name[MAX_PLAYER_NAME],
Password[129],
IP[16],
Admin,
VIP,
Money,
Float:posX,
Float:posY,
Float:posZ,
Float:posA
};
new Player[MAX_PLAYERS][PlayerData];
public OnGameModeInit()
{
AddPlayerClass(0,1685.6680,-2332.9236,13.5469,2.3834,0,0,0,0,0,0);
mysql_log(LOG_ALL);
mysql = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);
if(mysql_errno() != 0)
{
printf("[MySQL] The connection has failed.");
}
else
{
printf("[MySQL] The connection was successful.");
}
return 1;
}
public OnPlayerConnect(playerid)
{
SetPlayerColor(playerid, COLOR_WHITE);
SendClientMessage(playerid,COLOR_WHITE,"{FFFFFF}Welcome to {0000CD}Indonesia Real Life Roleplay");
SendClientMessage(playerid,COLOR_WHITE,"{FFFFFF}Visit {00FF00}www.new.IRL-RP.com {FFFFFF}to register new character!");
new
query[128],
playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
return true;
}
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new
rows,
fields,
name[MAX_PLAYER_NAME];
cache_get_data(rows, fields, mysql);
GetPlayerName(playerid,name,sizeof(name));
if(rows)
{
new string1[400],string[400],ip[50];
GetPlayerIp(playerid, ip, sizeof(ip));
cache_get_field_content(0, "Password", Player[playerid][Password], mysql, 129);
Player[playerid][ID] = cache_get_field_content_int(0, "ID");
format(string, 128, "{FF0000}Indonesia Real Life Roleplay\n\n");
strcat(string1,string);
format(string, 128, "{FFFFFF}Nama : {FF0000}%s\n{FFFFFF}IP : {FF0000}%s", name, ip);
strcat(string1,string);
format(string, 128, "\n\n{FFFFFF}Silahkan masukkan password anda untuk melakukan Log In pada server.\n");
strcat(string1,string);
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT,"{FF0000}Indonesia Real Life Roleplay - {FF0000}Login",string1,"Log-in","Quit");
}
else
{
new string1[400],string[400],ip[50];
GetPlayerIp(playerid, ip, sizeof(ip));
format(string, 128, "{FF0000}Indonesia Real Life Roleplay\n\n");
strcat(string1,string);
format(string, 128, "{FFFFFF}Nama : {FF0000}%s\n{FFFFFF}IP : {FF0000}%s", name, ip);
strcat(string1,string);
format(string, 128, "\n\n{FFFFFF}Silahkan masukkan password anda untuk melakukan registrasi pada server ini.\n");
strcat(string1,string);
ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_LIST,"{FF0000}Indonesia Real Life Roleplay - {FF0000}Register",string1,"Register","Quit");
}
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
new
query[128],
Float:pos[4];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `Money` = %d, `PosX` = %f, `PosY` = %f, `PosZ` = %f, `PosA` = %f WHERE `ID` = %d",
GetPlayerMoney(playerid), pos[0], pos[1], pos[2], pos[3], Player[playerid][ID]);
mysql_tquery(mysql, query, "", "");
TextDrawHideForPlayer(playerid, Time), TextDrawHideForPlayer(playerid, Date), TextDrawHideForPlayer(playerid, IRLRP);
return true;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case LoginDialog:
{
if(!response) Kick(playerid);
new
hashpass[129],
query[100],
name[MAX_PLAYER_NAME],
playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerName(playerid,name,sizeof(name));
WP_Hash(hashpass, sizeof(hashpass), inputtext);
if(!strcmp(hashpass, Player[playerid][Password]))
{
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
}
else
{
new string1[400],string[400],ip[50];
GetPlayerIp(playerid, ip, sizeof(ip));
SendClientMessage(playerid, -1, "You have specified an incorrect password!");
format(string, 128, "{FF0000}Indonesia Real Life Roleplay\n\n");
strcat(string1,string);
format(string, 128, "{FFFFFF}Nama : {FF0000}%s\n{FFFFFF}IP : {FF0000}%s", name, ip);
strcat(string1,string);
format(string, 128, "\n\n{FFFFFF}Silahkan masukkan password anda untuk melakukan Log In pada server.\n");
strcat(string1,string);
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT,"{FF0000}Indonesia Real Life Roleplay - {FF0000}Login",string1,"Log-in","Quit");
}
}
case RegisterDialog:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 5)
{
SendClientMessage(playerid, -1, "Your password must at least contain more than 4 characters.");
new string1[400],string[400],ip[50],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
GetPlayerIp(playerid, ip, sizeof(ip));
format(string, 128, "{FF0000}Indonesia Real Life Roleplay\n\n");
strcat(string1,string);
format(string, 128, "{FFFFFF}Nama : {FF0000}%s\n{FFFFFF}IP : {FF0000}%s", name, ip);
strcat(string1,string);
format(string, 128, "\n\n{FFFFFF}Silahkan masukkan password anda untuk melakukan registrasi pada server ini.\n");
strcat(string1,string);
return ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT,"{FF0000}Indonesia Real Life Roleplay - {FF0000}Register",string1,"Register","Quit");
}
new
query[512],
playername[MAX_PLAYER_NAME],
playerip[16];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerIp(playerid, playerip, sizeof(playerip));
WP_Hash(Player[playerid][Password], 129, inputtext);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f)", playername, Player[playerid][Password], playerip, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
}
}
return false;
}
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
new name[MAX_PLAYER_NAME];
new string[500];
GetPlayerName(playerid,name,sizeof(name));
Player[playerid][Admin] = cache_get_field_content_int(0, "Admin");
Player[playerid][VIP] = cache_get_field_content_int(0, "VIP");
Player[playerid][Money] = cache_get_field_content_int(0, "Money");
Player[playerid][posX] = cache_get_field_content_float(0, "PosX");
Player[playerid][posY] = cache_get_field_content_float(0, "PosY");
Player[playerid][posZ] = cache_get_field_content_float(0, "PosZ");
Player[playerid][posA] = cache_get_field_content_float(0, "PosA");
GivePlayerMoney(playerid, Player[playerid][Money]);
SetSpawnInfo(playerid, 0, 61, Player[playerid][posX], Player[playerid][posY], Player[playerid][posZ], Player[playerid][posA], 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
format(string, sizeof(string), "{0000CD}[SERVER] {FFFFFF}Welcome Back {00FF00}%s, {FFFFFF}you are now logged in.", name);
SendClientMessage(playerid, -1, string);
return true;
}
forward OnAccountRegister(playerid);
public OnAccountRegister(playerid)
{
new name[MAX_PLAYER_NAME];
new string[500];
GetPlayerName(playerid,name,sizeof(name));
Player[playerid][ID] = cache_insert_id();
printf("[Registration] New account registered. Database ID: [%d]", Player[playerid][ID]);
SetSpawnInfo(playerid, 0, 61, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
format(string, sizeof(string), "{0000CD}[SERVER] {FFFFFF}Welcome New Player {00FF00}%s, {FFFFFF}you are registered now.", name);
SendClientMessage(playerid, -1, string);
return true;
}
ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT,"{FF0000}Indonesia Real Life Roleplay - {FF0000}Register",string1,"Register","Quit");
ShowPlayerDialog(playerid, AgeDialog, DIALOG_STYLE_INPUT,"{FF0000}ENTER YOUR AGE {FF0000}Register",string1,"Enter","Quit");
ShowPlayerDialog(playerid, GenderDialog, DIALOG_STYLE_INPUT,"Enter your gender{FF0000}Register",string1,"Enter","Quit");
I opened it wanted to copy and paste but I just want to know how to make it, I can help solve it?
|