callback not working, mysql
#1

PHP код:
forward OnPlayerRegister(playeridpassword[]);
public 
OnPlayerRegister(playeridpassword[])
{
    new 
query[2048];
    if(
IsPlayerConnected(playerid))
    {
        if(
GetPVarInt(playerid"AccountExist") == 0)
        {
            
printf("inside OnPlayer");
            new 
hashpass[129], input[129];
            
format(hashpasssizeof(hashpass), "%s3ca827d65b48291545b"password);
            
mysql_escape_string(hashpassinput);
            
WP_Hash(hashpasssizeof(hashpass), input);
            new 
forum_name[64];
            
GetPVarString(playerid"ForumName"forum_namesizeof(forum_name));
            
mysql_format(handlesqlquerysizeof(query), "INSERT INTO accounts (Name, Origin, ForumName, Pass, Cash, Bank, Model, Age, Sex, PosX, PosY, PosZ, Health) VALUES ('%s', '%s', '%s', '%s', 300, 0, 26, %i, %i, 1642.7285, -2240.5591, 13.4945, 50.0)",
                
PlayerInfo[playerid][pUsername], PlayerInfo[playerid][pOrigin], forum_namehashpassGetPVarInt(playerid"Age"), GetPVarInt(playerid"Sex"));
            
mysql_pquery(handlesqlquery"OnPlayerRegistered""i"playerid);
        }
        else 
KickPlayer(playerid"Unable to register, account exists!");
    }
    return 
1;
}
forward OnPlayerRegistered(playerid);
public 
OnPlayerRegistered(playerid)
{
        
printf("inside Register");
    
//DeletePVar(playerid, "Registering");
    //DeletePVar(playerid, "RegistrationQuestion");
    
SetPVarInt(playerid"AccountExist"1);
    
CallRemoteFunction("OnPlayerLogin""ii"playerid1);
    return 
1;

OnPlayerRegistered is not being called, any idea why?
Reply
#2

Hey, Are you setting the PVar to 0 when they connect?
If you're not setting the pvar at all then it won't = 0.
So it will never make it inside ;
Код:
 
        if(GetPVarInt(playerid, "AccountExist") == 0)
Quick side note;
You shouldn't be checking if the account exists when they're trying to register, you should be checking if the account exists when they connect.

Simply putting a function inside OnPlayerConnect
To send an SQL call to look for the account name they've connected with;
If true > Go to login < If False > Go to Register.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)