SA-MP Forums Archive
Script Help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Script Help! (/showthread.php?tid=627210)



Script Help! - eikzdej - 25.01.2017

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");
	}
}



Respuesta: Script Help! - Eloy - 25.01.2017

More or less so

PHP код:
public OnPlayerConnect(playerid)
{
    new 
name[MAX_PLAYER_NAME], query[53];
    
GetPlayerName(playerid, name, sizeof(name));
    if(
IsPlayerConnected(playerid))
    {
        
mysql_format(g_SQL, Query, sizeof(Query), "SELECT * FROM `users` WHERE `Username` ='%e' LIMIT 1", name);
        
mysql_tquery(g_SQL, Query, "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(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");
    }
    return 
1;
}
forward Check_Bans(playerid)
{
    if(
Account[playerid][Banned] == 1)
    {
         
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", "");
    }
    else
    {
        
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));
        
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COLOR_ORANGE"Login", string, ""COLOR_ORANGE"Login", ""COLOR_WHITE"Quit");    
    }
    return 
1;
} 
Complete this script and use


Re: Script Help! - eikzdej - 25.01.2017

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


Re: Script Help! - saffierr - 25.01.2017

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