register/login sex/age - HELP
#1

I have been working on a script. I keep getting stuck at this point. I would really appreciate some help. I know how to make the register/login. I also want it to ask the age and sex before they spawn. I can't seem to get it. Can someone please help me. I am stuck. Thanks in advanced.
Reply
#2

PHP код:
#define Register 1
#define Email 2
#define Sex 3
#define Age 4
#define Orgin 5
#define Mood 6
#define Login 7
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
  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(playeridipsizeof(ip));
      
format(strsizeof str,"[%d:%d:%d][%d:%d:%d]"daymonthyearhourminutesecond);
      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(string512COLOR_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, -1string);
      
GivePlayerMoney(playerid,WelcomeGift);
      
format(string512COLOR_YELLOW"<<Player Info>>"COLOR_WHITE" You Have Been Awarded A Welcome Gift Of"COLOR_GREEN" $2000"COLOR_WHITE" !!");
      
SendClientMessage(playerid,-1string);
    }
    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)!= -&& 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(playeridLoginDIALOG_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(playeridLoginDIALOG_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(playeridLoginDIALOG_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(playeridPlayerInfo[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(stringsizeof(string),COLOR_YELLOW"<<Player>>"COLOR_ORANGE" %s"COLOR_WHITE" Has Joined The Server !!"GetName(playerid));
        
SendClientMessageToAll(-1string);
      }
      return 
1;
    }
}
return 
1;

feel free edit make sure brackets are correctly inline
Reply
#3

thanks, I have got this working. I just tried adding a faction which is going great. Except for the /r chat.

pawn Код:
CMD:r(playerid, params[])
{
    new string[128];
    if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/r)adio [radio chat]");

    new rank[64];
    switch (PlayerInfo[playerid][pMember]) // employer/rank/division data is pulled from here
    {
    case 1:
        {
            switch(PlayerInfo[playerid][pRank])
            {
            case 1: rank = "Officer";
            case 2: rank = "Detective";
            case 3: rank = "Sergeant";
            case 4: rank = "Lieutenant";
            case 5: rank = "Captain";
            case 6: rank = "Chief";
            default: rank = "Cadet";
            }
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Adrick
Посмотреть сообщение
thanks, I have got this working. I just tried adding a faction which is going great. Except for the /r chat.

pawn Код:
CMD:r(playerid, params[])
{
    new string[128];
    if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/r)adio [radio chat]");

    new rank[64];
    switch (PlayerInfo[playerid][pMember]) // employer/rank/division data is pulled from here
    {
    case 1:
        {
            switch(PlayerInfo[playerid][pRank])
            {
            case 1: rank = "Officer";
            case 2: rank = "Detective";
            case 3: rank = "Sergeant";
            case 4: rank = "Lieutenant";
            case 5: rank = "Captain";
            case 6: rank = "Chief";
            default: rank = "Cadet";
            }
        }
    }
    return 1;
}
PHP код:
CMD:r(playeridparams[])
{
  new 
text[128];
  if(
sscanf(params"s[128]",text)) return SendClientMessage(playerid,-1,COLOR_RED"<<Usage>>"COLOR_WHITE" /achat [Text]");
new 
rank[64];
    switch(
PlayerInfo[playerid][pMember])) // 0 for cops if more than 1 member try creating 1 for terriorists 
    
{
                 case 
0:
                {
        switch(
PlayerInfo[playerid][pRank])
        {
         case 
1: {rank "Officer";}
         case 
2: {rank "Detective";}
         case 
3: {rank "Sergeant";}
         case 
4: {rank "Lieutenant";}
         case 
5: {rank "Captain";}
         case 
6: {rank "Chief";}
         default: {
rank "Cadet";}
        }
      }
                case 
1:{}///---etc for other ranks
             
}
             return 
1;

try this not tested as I have to nip out try to create switch cases for different ranks !
Reply
#5

it rank o.O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)