Script Help!
#1

How can i make this code like this? IF the field is 0, then continue, else the login is blocked.

Код:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid) {

	new rows, fields, string[128];

	cache_get_row_count(rows);
	cache_get_field_count(fields);

	if (rows) {
		if (cache_get_value_name_int(0, "Locked", Account[playerid][Locked])) {
		    ShowPlayerDialog(playerid, DIALOG_LOCKED, DIALOG_STYLE_MSGBOX, ""COLOR_ORANGE"System", ""COLOR_WHITE"This account is locked due to too many failed attempts upon login.\nPlease contact a administrator to unlock this account.\n\nClick '"COLOR_LIGHTRED"Accept"COLOR_WHITE"' to close.", ""COLOR_ORANGE"Accept", "");
		    return true;
		}
		else if (cache_get_value_name_int(0, "isLogged", Account[playerid][isLogged])) {
			ShowPlayerDialog(playerid, DIALOG_ISLOGGED, DIALOG_STYLE_MSGBOX, ""COLOR_ORANGE"System", ""COLOR_WHITE"This account is currently online.", ""COLOR_ORANGE"Close", "");
			return true;
		}
		else {
			cache_get_value_name(0, "Password", Account[playerid][Password], 129);
			cache_get_value_name_int(0, "ID", Account[playerid][ID]);
			format(string, sizeof(string), ""COLOR_WHITE"This account is registered. Please input your password below\n\nUsername: "COLOR_YELLOW"%s\n\n"COLOR_WHITE"Password:", GetName(playerid));
			return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COLOR_ORANGE"Login", string, ""COLOR_ORANGE"Login", ""COLOR_WHITE"Quit");
		}
	}
	else {
	    format(string, sizeof(string), ""COLOR_WHITE"This account is NOT registered. Please input your password below\n\nUsername: "COLOR_YELLOW"%s\n\n"COLOR_WHITE"Password:", GetName(playerid));
		return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COLOR_ORANGE"Register", string, ""COLOR_ORANGE"Register", ""COLOR_WHITE"Quit");
	}
}
Reply
#2

More or less so

PHP код:
public OnPlayerConnect(playerid)
{
    new 
name[MAX_PLAYER_NAME], query[53];
    
GetPlayerName(playeridnamesizeof(name));
    if(
IsPlayerConnected(playerid))
    {
        
mysql_format(g_SQLQuerysizeof(Query), "SELECT * FROM `users` WHERE `Username` ='%e' LIMIT 1"name);
        
mysql_tquery(g_SQLQuery"Check_Account""d"playerid);
    }
    return 
1;
}
forward Check_Account(playerid)
{
    if(
cache_num_rows() > 0)
    {
        
cache_get_value_name_int(0"Ban"Account[playerid][Ban]);
        
cache_get_value_name(0"Password"Account[playerid][Password], 129);
        
cache_get_value_name_int(0"ID"Account[playerid][ID]);
        
Check_Bans(playerid);
    }
    else
    {
        
format(stringsizeof(string), ""COLOR_WHITE"This account is NOT registered. Please input your password below\n\nUsername: "COLOR_YELLOW"%s\n\n"COLOR_WHITE"Password:"GetName(playerid));
        return 
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD""COLOR_ORANGE"Register"string""COLOR_ORANGE"Register"""COLOR_WHITE"Quit");
    }
    return 
1;
}
forward Check_Bans(playerid)
{
    if(
Account[playerid][Banned] == 1)
    {
         
ShowPlayerDialog(playeridDIALOG_LOCKEDDIALOG_STYLE_MSGBOX""COLOR_ORANGE"System"""COLOR_WHITE"This account is locked due to too many failed attempts upon login.\nPlease contact a administrator to unlock this account.\n\nClick '"COLOR_LIGHTRED"Accept"COLOR_WHITE"' to close."""COLOR_ORANGE"Accept""");
    }
    else
    {
        
format(stringsizeof(string), ""COLOR_WHITE"This account is registered. Please input your password below\n\nUsername: "COLOR_YELLOW"%s\n\n"COLOR_WHITE"Password:"GetName(playerid));
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD""COLOR_ORANGE"Login"string""COLOR_ORANGE"Login"""COLOR_WHITE"Quit");    
    }
    return 
1;

Complete this script and use
Reply
#3

Hi! I got problems in "isPlayerConnected" command, my pawn doesn't recognized this command.
Reply
#4

Quote:
Originally Posted by eikzdej
Посмотреть сообщение
Hi! I got problems in "isPlayerConnected" command, my pawn doesn't recognized this command.
How do you exactly mean?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)