age&gender selection [help]
#1

Hi , could someone share age&gender selection after registration ?

also it would be great if was saving and loading with y_ini.

Thanks
Reply
#2

« Would help if you handed out some code to aid in making this command, but you know, Scripting Help isn't really for making you a command...
But if someone was going to be kind, then they'd need some basis to go on, rather than nothing and guess everything. » - Sew_Suni
Reply
#3

Quote:
Originally Posted by Dayrion
View Post
« Would help if you handed out some code to aid in making this command, but you know, Scripting Help isn't really for making you a command...
But if someone was going to be kind, then they'd need some basis to go on, rather than nothing and guess everything. » - Sew_Suni
it's not a command , basically it's a dialog where u need to choose either you a male of female . And the age u just simply type it in . Pretty much that's it .
Reply
#4

Look at there:https://sampforum.blast.hk/showthread.php?tid=386257
Reply
#5

Quote:
Originally Posted by EclipseWho
View Post
i see but how do i implement it with y_ini ?
Reply
#6

PHP Code:
#include <a_samp>
#include <YSI\y_ini>
#include <zcmd>
#define spd ShowPlayerDialog
#define max_players 40
enum {
    
d_log,
    
d_reg,
    
d_age,
    
d_gender,
};
enum uEnum{
    
PW,
    
Age,
    
Gender,
};
new 
uInfo[max_players][uEnum];
new 
bool:LoggedIn[max_players];
UserName(pid){
    new 
str[24];
    
GetPlayerName(pid,str,sizeof(str));
    return 
str;
}
UserPath(pid){
    new 
str[60];
    
format(str,sizeof(str),"users/%s.ini",UserName(pid));
    return 
str;
}
udb_hash(buf[]) {
    new 
length=strlen(buf);
    new 
s1 1;
    new 
s2 0;
    new 
n;
    for (
n=0n<lengthn++){
       
s1 = (s1 buf[n]) % 65521;
       
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;
}
main(){}
public 
OnGameModeInit(){
    for(new 
i20i++)AddPlayerClass(10+i1958.37831343.157215.3746269.14250,0,0,0,0,0);
    return 
1;
}
public 
OnPlayerConnect(playerid){
    
LoggedIn[playerid]=false;
    if(
fexistUserPath(playerid) )){
        
INI_ParseFileUserPath(playerid),"load_user_%s",.bExtra true, .extra playerid );
        
spd(playerid,d_log,DIALOG_STYLE_PASSWORD,"Login","{ffffff}You own account, to login just enter your password.","Login","Kick");
    }else{
        
spd(playerid,d_gender,DIALOG_STYLE_MSGBOX,"Register","{ffffff}Choose your gender.","Male","Female");
    }
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid){
    if(
LoggedIn[playerid]==false){
        
SendClientMessage(playerid,-1,"You must be logged in!");
        return 
0;
    }
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerRequestSpawn(playerid){
    if(
LoggedIn[playerid]==false){
        
SendClientMessage(playerid,-1,"You must be logged in!");
        return 
0;
    }
    return 
1;
}
forward load_user_info(pid,name[],value[]);
public 
load_user_info(pid,name[],value[]){
    
INI_Int("pw",uInfo[pid][PW]);
    
INI_Int("age",uInfo[pid][Age]);
    
INI_Int("gender",uInfo[pid][Gender]);
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[]){
    switch(
dialogid){
        case 
d_log:{
            if(!
response)return Kick(playerid);
            if(
uInfo[playerid][PW]!=udb_hash(inputtext))return spd(playerid,d_log,DIALOG_STYLE_PASSWORD,"Login","{FF0000}You entered wrong password!\n{FFFFFF}You own account, to login just enter your password.","Login","Kick");
            
LoggedIn[playerid]=true;
            
SendClientMessage(playerid,-1,"You successfully logged in!");
        }
        case 
d_gender:{
            
uInfo[playerid][Gender]=response;
            
spd(playerid,d_age,DIALOG_STYLE_INPUT,"Register","{ffffff}Enter your character age.","Okey","Kick");
        }
        case 
d_age:{
            if(!
response)return Kick(playerid);
            if(
strval(inputtext)<18||strval(inputtext)>99)return spd(playerid,d_age,DIALOG_STYLE_INPUT,"Register","{ff0000}Age must be between 18 to 99!\n{ffffff}Enter your character age.","Okey","Kick");
            
uInfo[playerid][Age]=strval(inputtext);
            
spd(playerid,d_reg,DIALOG_STYLE_PASSWORD,"Register","{ffffff}Enter your future password.","Register","Kick");
        }
        case 
d_reg:{
            if(!
response)return Kick(playerid);
            if(
strlen(inputtext)<3||strlen(inputtext)>20)return spd(playerid,d_reg,DIALOG_STYLE_MSGBOX,"Register","{ff00000}Pw must contain 3 to 20 characters!\n{ffffff}Enter your future password.","Register","Kick");
            new 
INI:file INI_Open(UserPath(playerid));
            
INI_SetTag(file,"info");
            
INI_WriteInt(file,"pw",udb_hash(inputtext));
            
INI_WriteInt(file,"gender",uInfo[playerid][Gender]);
            
INI_WriteInt(file,"age",uInfo[playerid][Age]);
            
INI_Close(file);
            
LoggedIn[playerid]=true;
            
SendClientMessage(playerid,-1,"You successfully registered your account!");
        }
    }
    return 
1;
}
CMD:stats(pid){    
    new 
str[30];
    
format(str,sizeof(str),"Gender: %s | Age: %d",(uInfo[pid][Gender])?("Male"):("Female"),uInfo[pid][Age]);
    
SendClientMessage(pid,-1,str);
    return 
1;

Reply
#7

Quote:
Originally Posted by Dayrion
View Post
« Would help if you handed out some code to aid in making this command, but you know, Scripting Help isn't really for making you a command...
But if someone was going to be kind, then they'd need some basis to go on, rather than nothing and guess everything. » - Sew_Suni
Do you read what you write? his damn name is Sew_Sumi for god's sake .. this is bugging me for months that you copy paste without reading your own shi'
Reply
#8

Quote:
Originally Posted by PrO.GameR
View Post
Do you read what you write? his damn name is Sew_Sumi for god's sake .. this is bugging me for months that you copy paste without reading your own shi'
I've never notified I was wrong. So yes, I read 'Sumi' instead of 'Suni'. You don't need to be fucking rude like that..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)