[HELP] Not work login
#1

Hello, why im got error:
Код:
Player TheNerka(0) - SSCANF loading error
My Gamemode:

Код:
/*---------------------------------------
* Name: Base RP
* Version: 0.0.1 [ALPHA]
* Author: FeaR
* Last Update: 13/07/2010
---------------------------------------*/




#include <a_samp>
#include <a_mysql>
#include <sscanf2>
#include <zcmd>
#include <foreach>
#include <streamer>
#include <colors>
#include <OPVD>
//#include <wep_anticheat>
#include "../gamemodes/mysql.dat"


//--------- Server Configuration ---------//

#define server_name         	"Test" // Your Server Name
#define server_version      	"0.0.1[Alpha]" // Your Server Version
#define server_author       	"FeaR" // The author name
#define server_website          "www.sa-mp.com" // The server website
#define server_folder           "baserp" // The server data folder
#define server_log              "logs" // The logs folder
#define server_debug_file       "debug.txt" // The server debug file
#define server_error_file       "errorlog.txt" // The server error log file

//--------- Mysql Configuration ---------//

#define mysql_account_table     "accounts" // The table to store accounts to
#define mysql_user_string       "e<p<|>ds[24]s[64]s[16]ds[32]dddffffdddddffddddddddds[20]>"
#include <mysql_functions>

//--------- Script Configuration ---------//

#define MAX_PASSWORD_LEN        (64) // Max length of Password
#define MAX_COUNTRY_LEN         (32) // Max length of Country

#define starting_money      	50 // Starting cash
#define starting_posx       	0 // Starting pos x
#define starting_posy       	0 // Starting pos y
#define starting_posz       	0 // Starting pos z
#define starting_posr           0 // Starting pos rot
#define starting_interior   	0 // Starting pos interior
#define starting_virtualworld   0 // Starting pos virtual world

#define selection_audiostream   "www.youtube.com/watch?v=CDmWJbN8bDo" // Background music for class selection

// ---- Spawning, Camera positions, questions, etc..

#define spawn_posx          		1449.1631 // Spawn Pos X
#define spawn_posy          		-2286.2107 // Spawn Pos Y
#define spawn_posz              	13.5469 // Spawn Pos Z
#define spawn_posr              	90.0 // Spawn Pos Rot

#define class_posx                  209.1801 // Class player position x
#define class_posy                  -33.9721 // Class player position y
#define class_posz                  1001.9297 // Class player position z
#define class_posr                  122.3167 // Class player position rot
#define class_camera_posx           206.9333 // Class camera position x
#define class_camera_posy           -35.4596 // Class camera position y
#define class_camera_posz           1001.8047 // Class camera position z
#define class_interior              1 // Class player interior

#define start_camera_posx       	-1864.1298 // Intial Camera Positon X
#define start_camera_posy       	58.9673 // Intial Camera Positon Y
#define start_camera_posz       	1055.0 // Intial Camera Positon Z
#define start_cameralook_posx       -1845.6288 // Intial Camera LookAt Positon X
#define start_cameralook_posy       70.5333 // Intial Camera LookAt Positon Y
#define start_cameralook_posz       1057.1436 // Intial Camera LookAt Positon Z
#define start_camera_interior   	14 // Intial Camera Interior

#define questions_camera_posx   	363.0773 // Camera pos x when questioning
#define questions_camera_posy   	154.3276 // Camera pos y when questioning
#define questions_camera_posz   	1025.7964 // Camera pos z when questioning
#define questions_cameralook_posx   363.0884 // Camera pos lookat x when questioning
#define questions_cameralook_posy   153.9999 // Camera pos lookat y when questioning
#define questions_cameralook_posz   1025.7964 // Camera pos lookat z when questioning
#define questions_camera_interior   3 // Camera interior when questioning

// --------------

#define timer_global            (1000) // Milliseconds

#define CHAT_RADIUS             (30.0) // The radius the player can see the chat msg
#define QUESTIONS_REQUIRED      (3) // Number of correct questions answered to be allowed into the server.
#define GENDER_MALE     		(0)
#define GENDER_FEMALE   		(1)

#define time_minute             (10) // Seconds to 1 minute game  time

#define color_successful        (0xAEFFAEFF)
#define color_error             (0xFF9797FF)
#define color_info              (0xFFFF9FFF)
#define color_questions         (0xBFFFFFFF)
#define color_lightblue         (0xBFFFFFFF)
#define color_grey              (0x9B9B9BFF)

//---------Macros ---------//

#define RELEASED(%0) \
	(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define HOLDING(%0) \
	((newkeys & (%0)) == (%0))

//--------- Dialog Configuration ---------//

#define DIALOG_REGISTER      	1
#define DIALOG_LOGIN         	2
#define DIALOG_TUTORIAL     	3
#define DIALOG_QUESTIONS        5

//--------- Enumerators & Arrays ---------//

// WARNING!!!!!!
// Enum must be in the SAME ORDER!! as the player stats mysql structure or the sscanf loading WILL NOT WORK!

//----------- PlayerInfo
enum pInfo
{
	//Saving Data
	
	pID,
	pName[MAX_PLAYER_NAME],
	pPassword[MAX_PASSWORD_LEN],
	pIP[16],
	pGender,
	pCountry[MAX_COUNTRY_LEN],
	pScore,
	pMoney,
	pIsNew,
	Float:pPosX,
	Float:pPosY,
	Float:pPosZ,
	Float:pPosR,
	pFightStyle,
	pSkin,
	pBanned,
	pAdmin,
	pVip,
	Float:pArmour,
	Float:pHealth,
	pInterior,
	pWantedLevel,
	pKills,
	pDeaths,
	pVirtualWorld,
	pLocked,
	pHelper,
	pMuted,
	pConnectedTime,
	pLastLogin[20],
	
	// Local Data
	pLoggedIn,
	pRegistered,
	pSpawned,
	pQuestionIdx,
	pQuestions
}

new PlayerInfo[MAX_PLAYERS][pInfo];

//----------- Questions
enum qinfo
{
	Question[128],
	Choice1[128],
	Choice2[128],
	Choice3[128],
	Answer
}

new qData[][qinfo] =
{
	{"What does the acronym 'RP' stand for?", "Real Patriot", "Real Plancake", "Role Play", 2},
	{"Are you allowed to Deathmatch?", "Never", "Yes", "Only if there's a valid roleplay reason to do so.", 2},
	{"Which /me usage is correct?", "/me lol", "/me picks a weapon up off of the floor", "/me arghhhh!", 1},
	{"If there was somebody injured, what would you do?", "Call an ambulance", "Walk away", "Injure him more", 0},
	{"What does the acronym 'OOC' mean?", "Out Of Chat", "Out Of Christmas", "Out Of Character", 2}
};

//----------- Skins

enum skininfo
{
	SkinID,
	SkinGender
}

new SkinInfo[][skininfo] =
{
    {2, GENDER_MALE}, {3, GENDER_MALE}, {4, GENDER_MALE}, {5, GENDER_MALE}, {6, GENDER_MALE}, {7, GENDER_MALE},
    {9, GENDER_FEMALE}, {12, GENDER_FEMALE}, {13, GENDER_FEMALE}, {15, GENDER_MALE}, {17, GENDER_MALE},
    {19, GENDER_MALE}, {20, GENDER_MALE}, {21, GENDER_MALE}, {22, GENDER_MALE}, {28, GENDER_MALE}, {29, GENDER_MALE},
    {30, GENDER_MALE}, {35, GENDER_MALE}, {37, GENDER_MALE}, {40, GENDER_FEMALE}, {43, GENDER_MALE}, {44, GENDER_MALE},
    {46, GENDER_MALE}, {47, GENDER_MALE}, {48, GENDER_MALE}, {55, GENDER_FEMALE}, {56, GENDER_MALE}, {58, GENDER_MALE},
    {59, GENDER_MALE}, {60, GENDER_MALE}, {66, GENDER_MALE}, {67, GENDER_MALE}, {69, GENDER_FEMALE}, {72, GENDER_MALE},
    {90, GENDER_FEMALE}, {91, GENDER_FEMALE}, {93, GENDER_FEMALE}, {98, GENDER_MALE}, {101, GENDER_MALE}, {169, GENDER_FEMALE},
    {170, GENDER_MALE}, {183, GENDER_MALE}, {184, GENDER_MALE}, {188, GENDER_MALE}, {192, GENDER_FEMALE}, {193, GENDER_FEMALE},
    {226, GENDER_FEMALE}, {240, GENDER_MALE}, {250, GENDER_MALE}, {258, GENDER_MALE}, {259, GENDER_MALE}
};

//----------- Bot Engine

#define MAX_BOTS        (1)

enum botinfo
{
	BotName[MAX_PLAYER_NAME],
	Script[64],
	Skinid,
	VehicleModel,
	VehicleID,
	Color1, Color2,
	AnimationLib[32],
	AnimationName[32],
	AnimationTime,
	AnimationLoop
}

new BotInfo[MAX_BOTS][botinfo] =
{
	{"Immigration Officer", "immigration_officer", 147, -1, INVALID_VEHICLE_ID, -1, -1, "PED", "IDLE_CHAT", 0, 1}
};

//----------- Time System

new Text:TimeTD, hour, minute, TimeTick = -1;

//--------- Arrays & Strings ---------//

new smallstr[64]; // This is for small sized strings.
new str[128]; // This is for normal sized strings.
new bigstr[256]; // This is for strings that may become larger than 128 cells, such as lists, queries etc.
new largestr[1024]; // This is for very big strings that need to be formatted, when query string is in use.
new query[512]; // This is for mysql queries, as they can get very large. (It may become 1024 cells in the future!)

new Float:X, Float:Y, Float:Z;

//--------- Varibles ---------//

new GlobalTimer = -1;

//--------- Forwards ---------//

forward OnAccountConnect(playerid);
forward SetPlayerSpawn(playerid);
forward SetupCamera(playerid);
forward SpawnAccount(playerid);
forward RespawnPlayer(playerid);
forward globaltimer();

//-----------------------------//

main()
{
	print("Server Loaded!");
}

public OnGameModeInit()
{
	SetGameModeText(server_name);
	ManualVehicleEngineAndLights();
	SetNameTagDrawDistance(CHAT_RADIUS);
	UsePlayerPedAnims();
	
	CreateTextdraws();
	
	MysqlConnect(mysql_host, mysql_user, mysql_pass, mysql_db);

	GlobalTimer = SetTimer("globaltimer", timer_global, true);
	
	UpdateTime();
	
	for(new a = 0; a < sizeof(SkinInfo); a++)
	{
	    AddPlayerClass(SkinInfo[a][SkinID], spawn_posx, spawn_posy, spawn_posz, spawn_posr, 0, 0, 0, 0, 0, 0);
	}
	
	for(new b = 0; b < sizeof(BotInfo); b++)
	{
	    ConnectNPC(BotInfo[b][BotName], BotInfo[b][Script]);

		if(BotInfo[b][VehicleModel] != -1)
		{
		    BotInfo[b][VehicleID] = CreateVehicle(BotInfo[b][VehicleModel], 0.0, 0.0, 0.0, 0.0, BotInfo[b][Color1], BotInfo[b][Color2], -1);
		}
	}
	
	return 1;
}

public OnGameModeExit()
{
	for(new a = 0, b = GetMaxPlayers(); a < b; a++)
	{
	    if(PlayerInfo[a][pLoggedIn] == 1)
	    {
	        OnPlayerDisconnect(a, 0);
		}
	}
	
	KillTimer(GlobalTimer);
	GlobalTimer = -1;
	
	DestroyTextdraws();
	return 1;
}

public OnPlayerConnect(playerid)
{
	if(IsPlayerNPC(playerid)) return 1;
	
	OnAccountConnect(playerid);

	ResetPlayerCash(playerid);
	format(smallstr, sizeof(smallstr), "%s has logged into the server!", PlayerInfo[playerid][pName]);
	SendClientMessageToAllEx(playerid, color_grey, smallstr);

	SetPlayerTime(playerid, hour, minute);
	
	return 1;
}

public OnAccountConnect(playerid)
{
    new PlayerName[MAX_PLAYER_NAME], Escape[2][MAX_PLAYER_NAME], IP[2][16];

	GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, "%s", PlayerName);
	GetPlayerIp(playerid, IP[1], 16);
 	format(PlayerInfo[playerid][pIP], 16, "%s", IP[1]);
 	
	printf("pIP: %s, IP-1: %s", PlayerInfo[playerid][pIP], IP[1]);

	PlayerInfo[playerid][pRegistered] = 0;
	PlayerInfo[playerid][pLoggedIn] = 0;
	PlayerInfo[playerid][pIsNew] = 1;
	PlayerInfo[playerid][pSpawned] = 0;
	
	mysql_real_escape_string(mysql_account_table, Escape[0]);
	mysql_real_escape_string(PlayerName, Escape[1]);

	format(query, sizeof(query), "SELECT * FROM `%s` WHERE `username` = '%s' LIMIT 1", Escape[0], Escape[1]);
	mysql_query(query);
	mysql_store_result();
    
    WipeChat(playerid);
    
	if(mysql_num_rows())
	{
	    mysql_debug(1);
	    mysql_fetch_field_row(IP[0], "ip");
	    mysql_debug(0);

        printf("IP-0: %s", IP[0]);
        
	    if(!strcmp(IP[0], IP[1], true))
	    {
	        LoadAccount(playerid);
	        SetTimerEx("RespawnPlayer", 100, false, "i", playerid);
	        
			WipeChat(playerid);
			SendClientMessage(playerid, color_info, "Welcome back to the server!");
			SendClientMessage(playerid, color_info, "You have been automatically logged in!");
			format(str, sizeof(str), "Your last visit was: %s", PlayerInfo[playerid][pLastLogin]);
			SendClientMessage(playerid, color_info, str);
			format(str, sizeof(str), "Admin level: %d, VIP Level: %d, Helper Level: %d", PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pVip], PlayerInfo[playerid][pHelper]);
			SendClientMessage(playerid, color_info, str);
			
	        mysql_free_result();
			return 1;
		}

        PlayerInfo[playerid][pLoggedIn] = 0;
        PlayerInfo[playerid][pRegistered] = 1;

		SetupCamera(playerid);
		mysql_free_result();
  		return 1;
	}

	SetPlayerTime(playerid, 12, 00);
	mysql_free_result();
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(IsPlayerLoggedIn(playerid))
	{
		switch(reason)
		{
		    case 0: format(smallstr, sizeof smallstr, "%s left the server. (Timed out)", PlayerInfo[playerid][pName]);
	        case 1: format(smallstr, sizeof smallstr, "%s left the server. (Leaving)", PlayerInfo[playerid][pName]);
	        case 2: format(smallstr, sizeof smallstr, "%s left the server. (Kicked/Banned)", PlayerInfo[playerid][pName]);
		}
		
		SendClientMessageToAll(color_error, smallstr);
		SaveAccount(playerid);
	}
	
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
	    case DIALOG_REGISTER:
	    {
	        if(response)
			{
			    if(isnull(inputtext) || strlen(inputtext) > MAX_PASSWORD_LEN)
	            {
	                format(str, sizeof(str), "Your password must be more than 0 and less than %d characters long.", MAX_PASSWORD_LEN);
	                SendClientNewMessage(playerid, color_error, str);
	                format(str, sizeof(str), "Please register by typing a password below.\n{FF9797}Password must be more than 0 and less than %d characters long!", MAX_PASSWORD_LEN);
					ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{FFFFA8}Registration", str, "Register", "Quit");
	            }
	            else
		        {
		            format(PlayerInfo[playerid][pPassword], 16, "%s", inputtext);
					PlayerInfo[playerid][pIsNew] = 1;
					
					WipeChat(playerid);
					SendClientMessage(playerid, color_lightblue, "Customs Officer: Hi! Please fill out this form, it is required if you wish to gain entry to the server.");
					SendClientMessage(playerid, color_lightblue, "Customs Officer: Please write down the country you were born in.");

					ShowPlayerDialog(playerid, DIALOG_TUTORIAL, DIALOG_STYLE_INPUT, "{FFFFA8}Country", "Please type where your character was born in the box below.", "Next", "");
		        }
			}
			else
			{
			    SendClientMessage(playerid, color_error, "You must register before logging in!");
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{FFFFA8}Registration", "Please register by typing a password below.\n{FF9797}Please enter a password!", "Register", "Quit");
			}
		}
		case DIALOG_LOGIN:
		{
		    if(response)
			{
			    new Escape[3][MAX_PASSWORD_LEN];

			    mysql_real_escape_string(mysql_account_table, Escape[0]);
	            mysql_real_escape_string(inputtext, Escape[1]);
	            mysql_real_escape_string(PlayerInfo[playerid][pName], Escape[2]);
	            
	            format(query, sizeof(query), "SELECT * FROM `%s` WHERE `username` = '%s' AND password = SHA1('%s')", Escape[0], Escape[2], Escape[1]);
	            mysql_query(query);
	            mysql_store_result();
	            
	            if(mysql_num_rows())
				{
				    LoadAccount(playerid);
			        
			        WipeChat(playerid);
					SendClientMessage(playerid, color_info, "Welcome back to the server!");
					format(str, sizeof(str), "Your last visit was: %s", PlayerInfo[playerid][pLastLogin]);
					SendClientMessage(playerid, color_info, str);
					format(str, sizeof(str), "Admin level: %d, VIP Level: %d, Helper Level: %d", PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pVip], PlayerInfo[playerid][pHelper]);
					SendClientMessage(playerid, color_info, str);
			
			        RespawnPlayer(playerid);
			        mysql_free_result();
				}
				else
				{
					SendClientMessage(playerid, color_error, "Incorrect password!");
	    			ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FFFFA8}Login", "Please register by typing a password below.\n{FF9797}Incorrect Password!", "Register", "Quit");
				}
				
	            mysql_free_result();
			}
			else
			{
                Kick(playerid);
			}
		}
		case DIALOG_TUTORIAL:
		{
		    if(response)
			{
			    format(PlayerInfo[playerid][pCountry], MAX_COUNTRY_LEN, inputtext);

			    WipeChat(playerid);
			    format(str, sizeof(str), "Customs Officer: Ok, so you were born in %s... Let me just get the questionaire.", PlayerInfo[playerid][pCountry]);
			    SendClientMessage(playerid, color_lightblue, str);
				SendClientMessage(playerid, color_lightblue, "Customs Officer: Alright, here it is... before you are allowed entry to the server, you must answer some questions...");
				SendClientMessage(playerid, color_lightblue, " ");

				StartQuestions(playerid);
			}
		}
	    case DIALOG_QUESTIONS:
	    {
	        if(response)
	        {
				if(listitem == qData[PlayerInfo[playerid][pQuestionIdx]][Answer])
				{
					PlayerInfo[playerid][pQuestions]++;
				}

				if(PlayerInfo[playerid][pQuestionIdx] >= (sizeof(qData))-1)
				{
				    if(PlayerInfo[playerid][pQuestions] < QUESTIONS_REQUIRED)
				    {
				        WipeChat(playerid);
					    SendClientMessage(playerid, color_questions,"Customs Officer: I'm sorry, but you did not get enough answers right to be allowed through customs.");
					    SendClientMessage(playerid, color_questions," ");
					    format(str, sizeof(str), "Please visit '%s' and read the rules and guides to become familiar with Roleplay, then try and answer the questions again.", server_website);
					    SendClientMessage(playerid, color_error, str);
						Kick(playerid);
					}
					else
					{
					    CreateAccount(playerid, PlayerInfo[playerid][pName], inputtext);
						PlayerInfo[playerid][pIsNew] = 0;
						PlayerInfo[playerid][pRegistered] = 1;
						PlayerInfo[playerid][pPosX] = spawn_posx;
						PlayerInfo[playerid][pPosY] = spawn_posy;
						PlayerInfo[playerid][pPosZ] = spawn_posz;
						PlayerInfo[playerid][pPosR] = spawn_posr;

					    WipeChat(playerid);
						SendClientMessage(playerid, color_questions,"Customs Officer: You have got enough answers right to be allowed through customs into the server.");
	                    SendClientMessage(playerid, color_questions,"Customs Officer: I have got all of the documents you require, here is your VISA.");
	                    SendClientMessage(playerid, color_questions,"Customs Officer: I Hope you enjoy your stay in the server, goodbye!");

                        StopAudioStreamForPlayer(playerid);
	                    SpawnAccount(playerid);
					}
				}
				else
				{
				    new qidx;
					PlayerInfo[playerid][pQuestionIdx]++;
					qidx = PlayerInfo[playerid][pQuestionIdx]+1;

					format(bigstr, sizeof(bigstr), "%s\n%s\n%s", qData[PlayerInfo[playerid][pQuestionIdx]][Choice1], qData[PlayerInfo[playerid][pQuestionIdx]][Choice2], qData[PlayerInfo[playerid][pQuestionIdx]][Choice3]);
					format(str, sizeof(str), "{FFFFA8}%s", qData[PlayerInfo[playerid][pQuestionIdx]][Question]);

					ShowPlayerDialog(playerid, DIALOG_QUESTIONS, DIALOG_STYLE_LIST, str, bigstr, "Next", "Quit");

					format(str, sizeof(str), "Customs Officer: Question %s, %s", ((qidx == 2) ? ("Two") : (qidx == 3) ? ("Three") : (qidx == 4) ? ("Four") : (qidx == 5) ? ("Five") : ("NULL")), qData[PlayerInfo[playerid][pQuestionIdx]][Question]);
					SendClientNewMessage(playerid, color_questions, str);
				}
			}
			else
			{
				Kick(playerid);
			}
		}
	}
	return 1;
}

public OnPlayerSpawn(playerid)
{
    Preloadanims(playerid);
    
	if(IsPlayerNPC(playerid))
	{
	    new pBotName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pBotName, MAX_PLAYER_NAME);
	    
	    for(new b = 0; b < sizeof(BotInfo); b++)
	    {
	        if(!strcmp(pBotName, BotInfo[b][BotName], true))
	        {
	            SetPlayerSkin(playerid, BotInfo[b][Skinid]);
	            SetPlayerColor(playerid, 0xFFFFFF00);
	            
	            if(BotInfo[b][VehicleID] != INVALID_VEHICLE_ID)
	            {
	                PutPlayerInVehicle(playerid, BotInfo[b][VehicleID], 0);
				}
				
				if(strcmp(BotInfo[b][AnimationLib], "NULL", true))
				{
				    ApplyAnimation(playerid, BotInfo[b][AnimationLib], BotInfo[b][AnimationName], 4.1, BotInfo[b][AnimationLoop], 0, 0, 0, BotInfo[b][AnimationTime], 1);
				}
			}
		}
		
		return 1;
	}
	
    PlayerInfo[playerid][pSpawned] = 1;
    
    TextDrawShowForPlayer(playerid,TimeTD);
    
    SetPlayerColor(playerid, 0xFFFFFFFF);
    SetPlayerTime(playerid, hour, minute);
    
    if(PlayerInfo[playerid][pIsNew] == 1)
    {
        new pskin = GetPlayerSkin(playerid);

		for(new a = 0; a < sizeof(SkinInfo); a++)
		{
		    if(pskin == SkinInfo[a][SkinID])
		    {
		        PlayerInfo[playerid][pGender] = SkinInfo[a][SkinGender];
		        PlayerInfo[playerid][pSkin] = pskin;
		        PlayerInfo[playerid][pSpawned] = 0;
		        SetupCamera(playerid);
				return 1;
			}
		}
		
		return 1;
	}
    
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    if(PlayerInfo[playerid][pIsNew] == 0)
    {
        SetTimerEx("RespawnPlayer", 100, false, "i", playerid);
        return 1;
	}
    
    SetupPlayerForClassSelection(playerid);
    
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerInfo[playerid][pSpawned] = 0;
 	TextDrawHideForPlayer(playerid,TimeTD);
	return 1;
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	format(str, sizeof(str), "{FFFFFF}%s says: {BFFFFF}%s", PlayerInfo[playerid][pName], text);
	RangeMessage(playerid, 30.0, str);
	
	ApplyAnimation(playerid, "PED", "IDLE_chat", 4.1, 1, false, false, false, strlen(text)*100, 1);
	//ApplyAnimation(playerid,"MISC","Idle_Chat_02",4.1,1,0,0,0,strlen(text)*100, 1);
	return 0;
}

stock Preloadanims(playerid)
{
	ApplyAnimation(playerid, "PED", "NULL", 4.1, 1, 0, 0, 0, 0, 0);
	ApplyAnimation(playerid, "MISC", "NULL", 4.1, 1, 0, 0, 0, 0, 0);
}
	
stock UpdateTime()
{
    TimeTick = GetTickCount();

	if(minute == 60)
	{
 		minute = 0;
  		hour++;

		if(hour == 24)
  		{
			hour = 0;
		}
	}
	else
	{
 		minute++;
	}

	format(str, sizeof(str), "%02d:%02d", hour, minute);
	TextDrawSetString(TimeTD, str);
}

stock CreateTextdraws()
{
    TimeTD = TextDrawCreate(605.0,25.0,"--:--");
	TextDrawUseBox(TimeTD, 0);
	TextDrawFont(TimeTD, 3);
	TextDrawSetShadow(TimeTD,0);
    TextDrawSetOutline(TimeTD,2);
    TextDrawBackgroundColor(TimeTD,0x000000FF);
    TextDrawColor(TimeTD,0xFFFFFFFF);
    TextDrawAlignment(TimeTD,3);
	TextDrawLetterSize(TimeTD,0.5,1.5);
}

stock DestroyTextdraws()
{
	TextDrawDestroy(TimeTD);
}

public globaltimer()
{
	if(GetTickCount() - TimeTick >= (time_minute*1000))
	{
	    UpdateTime();
	}
	
	for(new a = 0, b = GetMaxPlayers(); a < b; a++)
	{
	    if(PlayerInfo[a][pSpawned] == 1)
	    {
        	SetPlayerTime(a, hour, minute);
		}
        
	    if(PlayerInfo[a][pSpawned] == 1)
	    {
	        GetPlayerHealth(a, PlayerInfo[a][pHealth]);
	        GetPlayerArmour(a, PlayerInfo[a][pArmour]);
	        PlayerInfo[a][pInterior] = GetPlayerInterior(a);
	        PlayerInfo[a][pVirtualWorld] = GetPlayerVirtualWorld(a);
	        GetPlayerPos(a, PlayerInfo[a][pPosX], PlayerInfo[a][pPosY], PlayerInfo[a][pPosZ]);
	        GetPlayerFacingAngle(a, PlayerInfo[a][pPosR]);
	       	PlayerInfo[a][pInterior] = GetPlayerInterior(a);
	        PlayerInfo[a][pVirtualWorld] = GetPlayerVirtualWorld(a);
		}
	}
	
	return 1;
}
	        
// --------- Functions ------------- //

stock MysqlConnect(host[], user[], pass[], db[])
{
	mysql_connect(host, user, db, pass);
	if(mysql_ping() == 1)
	{
	    print("Mysql: Mysql Connected!");
	    return 1;
	}
	else
	{
	    print("Mysql: Mysql Connection Refused... Retrying..");
	    if(mysql_ping() == 1)
		{
		    print("Mysql: Mysql Connected!");
		    return 1;
		}
		else
		{
		    print("Mysql: Mysql Connection Failed");
		    print("Mysql: Server Disconnected");
			GameModeExit();
			return 0;
		}
	}
}

stock CreateAccount(playerid, Name[], Password[])
{
    mysql_createaccount(Name, Password);
    mysql_setint(mysql_account_table, Name, "money", starting_money, "username");
    mysql_setstr(mysql_account_table, Name, "IP", PlayerInfo[playerid][pIP], "username");
    mysql_setfloat(mysql_account_table, Name, "PosX", starting_posx, "username");
    mysql_setfloat(mysql_account_table, Name, "PosY", starting_posy, "username");
    mysql_setfloat(mysql_account_table, Name, "PosZ", starting_posz, "username");
    mysql_setfloat(mysql_account_table, Name, "PosR", starting_posr, "username");
    mysql_setint(mysql_account_table, Name, "interior", starting_interior, "username");
    mysql_setint(mysql_account_table, Name, "virtual_world", starting_virtualworld, "username");
    mysql_setint(mysql_account_table, Name, "isnew", 0, "username");
    
    ResetAccount(playerid);
    
    PlayerInfo[playerid][pLoggedIn] = 1;
	PlayerInfo[playerid][pRegistered] = 1;
	PlayerInfo[playerid][pIsNew] = 0;
    mysql_free_result();
	        
    return 1;
}

stock LoadAccount(playerid)
{
	new Escape[2][MAX_PLAYER_NAME];

	mysql_real_escape_string(PlayerInfo[playerid][pName], Escape[0]);
	mysql_real_escape_string(mysql_account_table, Escape[1]);

	format(query, sizeof(query), "SELECT * FROM `%s` WHERE `username` = '%s'", Escape[1], Escape[0]);
	mysql_query(query);
	mysql_store_result();

	if(mysql_num_rows())
	{
		if(mysql_fetch_row(largestr))
		{
            if(!sscanf(largestr, mysql_user_string, PlayerInfo[playerid]))
			{
        		PlayerInfo[playerid][pLoggedIn] = 1;
        		PlayerInfo[playerid][pRegistered] = 1;
        		PlayerInfo[playerid][pIsNew] = 0;
                printf("[DEBUG]: Player %s(%d) Stats loaded!", PlayerInfo[playerid][pName], playerid);
				return 1;
			}
			format(str, sizeof(str), "Player %s(%d) - SSCANF loading error", PlayerInfo[playerid][pName], playerid);
			Error("MYSQL", str);
			AccountError(playerid);
			mysql_free_result();
			return 1;
		}
		format(str, sizeof(str), "Player %s(%d) - Cannot fetch player row", PlayerInfo[playerid][pName], playerid);
		Error("MYSQL", str);
		AccountError(playerid);
		mysql_free_result();
		return 1;
	}
	format(str, sizeof(str), "Player %s(%d) - Cannot find player in the mysql database", PlayerInfo[playerid][pName], playerid);
    Error("MYSQL", str);
    AccountError(playerid);
	mysql_free_result();
	return 1;
}

stock SaveAccount(playerid)
{
	new Day, Month, Year;
	getdate(Year, Month, Day);
	format(PlayerInfo[playerid][pLastLogin], 20, "%02d/%02d/%02d", Day, Month, Year);

	PlayerInfo[playerid][pSpawned] = 0; // So globaltimer stops updating while he is being disconnected..
	
	mysql_setstr(mysql_account_table, PlayerInfo[playerid][pName], "ip", PlayerInfo[playerid][pIP], "username");
 	mysql_setstr(mysql_account_table, PlayerInfo[playerid][pName], "country", PlayerInfo[playerid][pCountry], "username");
 	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "gender", PlayerInfo[playerid][pGender], "username");
	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "score", GetPlayerScore(playerid), "username");
	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "money", PlayerInfo[playerid][pMoney], "username");
 	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "isnew", PlayerInfo[playerid][pIsNew], "username");
  	mysql_setfloat(mysql_account_table, PlayerInfo[playerid][pName], "PosX", PlayerInfo[playerid][pPosX], "username");
  	mysql_setfloat(mysql_account_table, PlayerInfo[playerid][pName], "PosY", PlayerInfo[playerid][pPosY], "username");
  	mysql_setfloat(mysql_account_table, PlayerInfo[playerid][pName], "PosZ", PlayerInfo[playerid][pPosZ], "username");
  	mysql_setfloat(mysql_account_table, PlayerInfo[playerid][pName], "PosR", PlayerInfo[playerid][pPosR], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "fight_style", GetPlayerFightingStyle(playerid), "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "skin", PlayerInfo[playerid][pSkin], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "admin", PlayerInfo[playerid][pAdmin], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "vip", PlayerInfo[playerid][pVip], "username");
  	mysql_setfloat(mysql_account_table, PlayerInfo[playerid][pName], "armour", PlayerInfo[playerid][pArmour], "username");
  	mysql_setfloat(mysql_account_table, PlayerInfo[playerid][pName], "health",  PlayerInfo[playerid][pHealth], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "interior", PlayerInfo[playerid][pInterior], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "wanted_level", GetPlayerWantedLevel(playerid), "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "kills", PlayerInfo[playerid][pKills], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "deaths", PlayerInfo[playerid][pDeaths], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "virtual_world", PlayerInfo[playerid][pVirtualWorld], "username");
 	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "helper", PlayerInfo[playerid][pHelper], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "muted", PlayerInfo[playerid][pMuted], "username");
  	mysql_setint(mysql_account_table, PlayerInfo[playerid][pName], "connected_time", PlayerInfo[playerid][pConnectedTime], "username");
 	mysql_setstr(mysql_account_table, PlayerInfo[playerid][pName], "last_login", PlayerInfo[playerid][pLastLogin], "username");

	Debug(playerid, "Stats Saved!");
	return 1;
}

stock ResetAccount(playerid)
{
    PlayerInfo[playerid][pMoney] = starting_money;
    PlayerInfo[playerid][pPosX] = starting_posx;
    PlayerInfo[playerid][pPosY] = starting_posy;
    PlayerInfo[playerid][pPosZ] = starting_posz;
	PlayerInfo[playerid][pPosR] = starting_posr;
    PlayerInfo[playerid][pInterior] = starting_interior;
    PlayerInfo[playerid][pVirtualWorld] = starting_virtualworld;
    PlayerInfo[playerid][pHealth] = 100.0;
    PlayerInfo[playerid][pSpawned] = 0;
    return 1;
}

SetupPlayerForClassSelection(playerid)
{
	WipeChat(playerid);
 	SetPlayerInterior(playerid,class_interior);
	SetPlayerPos(playerid,class_posx, class_posy, class_posz);
	SetPlayerFacingAngle(playerid, class_posr);
	SetPlayerCameraPos(playerid,class_camera_posx, class_camera_posy, class_camera_posz);
	SetPlayerCameraLookAt(playerid,class_posx, class_posy, class_posz);
}

stock ShowRegisterDialog(playerid, text[])
{
	ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", text, "Register", "");
}
stock ShowLoginDialog(playerid, text[])
{
	ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", text, "Login", "");
}
stock ShowQuizDialog(playerid, dialogid, title[], items[])
{
    ShowPlayerDialog(playerid,dialogid,DIALOG_STYLE_LIST,title,items,"Select","Quit");
}
stock MsgBox(playerid, title[], text[])
{
	ShowPlayerDialog(playerid, 32761, DIALOG_STYLE_MSGBOX, title, text, "OK", "");
}
stock InputBox(playerid, dialogid, title[], text[])
{
	ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, title, text, "ACCEPT", "CANCEL");
}
stock ListBox(playerid, dialogid, text[], list[])
{
	ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, text, list, "SELECT", "CANCEL");
}


/*stock GivePlayerAllWeapons(playerid)
{
    if(!strcmp(strzFWeapon, "N/A", true)){}
    else
	{
	    sscanf(strzFWeapon, "p<,>A<i>(-1)[10]", weapons);
		for(new i; i < sizeof(weapons); i++)
		{
			GivePlayerWeapon(playerid, i, 99999);
		}
	}
}*/

public SpawnAccount(playerid)
{
    SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosR]);
    SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
  	SetPlayerFightingStyle(playerid, PlayerInfo[playerid][pFightStyle]);
   	SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pWantedLevel]);
   	SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
   	SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
   	SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVirtualWorld]);
   	SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pWantedLevel]);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
	SetPlayerCash(playerid, PlayerInfo[playerid][pMoney]);
    SetCameraBehindPlayer(playerid);
    TogglePlayerControllable(playerid, true);
    
    PlayerInfo[playerid][pSpawned] = 1;
    
    SendClientMessage(playerid, color_successful, " ");
    SendClientMessage(playerid, color_info, "Welcome to the server!");
    format(str, sizeof(str), "For more information, please visit the server's website at '%s'.", server_website);
    SendClientMessage(playerid, color_info, str);
    
    return 1;
}

public RespawnPlayer(playerid)
{
    SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pPosR], 0, 0, 0, 0, 0, 0);
	SpawnPlayer(playerid);
	return 1;
}

public SetupCamera(playerid)
{
    SetPlayerTime(playerid, 12, 00);
	SetPlayerPos(playerid, start_camera_posx, start_camera_posy, start_camera_posz+10.0);
	TogglePlayerControllable(playerid, false);
	SetPlayerCameraPos(playerid, start_camera_posx, start_camera_posy, start_camera_posz);
	SetPlayerCameraLookAt(playerid, start_cameralook_posx, start_cameralook_posy, start_cameralook_posz);
	SetPlayerInterior(playerid, start_camera_interior);
	
	if(PlayerInfo[playerid][pRegistered] == 0)
	{
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{FFFFA8}Registration", "Please register by typing a password below.", "Register", "Quit");
		return 1;
	}
	else if(PlayerInfo[playerid][pRegistered] == 1 && PlayerInfo[playerid][pLoggedIn] == 0)
	{
	    SetSpawnInfo(playerid, 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
		SpawnPlayer(playerid);
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{FFFFA8}Login", "Please login by typing a password below.", "Login", "Quit");
		return 1;
	}
	else if(PlayerInfo[playerid][pLoggedIn] == 1)
	{
	    SpawnAccount(playerid);
	    return 1;
	}
	
	return 1;
}

stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
}

stock Log(File[], Text[])
{
	new File: LogFile, Day, Month, Year, Hour, Minute, Second;

	getdate(Year, Month, Day);
	gettime(Hour, Minute, Second);

	format(str, sizeof(str), "[%02d/%02d/%02d - %02d:%02d] %s\r\n", Day, Month, Year, Hour, Minute, Text);
	format(smallstr, sizeof(smallstr), "%s/%s/%s", server_folder, server_log, File);

	LogFile = fopen(smallstr, io_append);
	fwrite(LogFile, str);
	fclose(LogFile);
	return 1;
}

stock Debug(playerid, Message[])
{
	format(str, sizeof(str), "[DEBUG]: Player %s(%d) - %s", PlayerInfo[playerid][pName], playerid, Message);
	print(str);
	Log(server_debug_file, str);
	return 1;
}

stock Error(Source[], Message[])
{
	format(str, sizeof(str), "[%s ERROR]: %s", Source, Message);
	print(str);
	Log(server_error_file, str);
}

stock AccountError(playerid)
{
    SendClientMessage(playerid, color_error, "There is an error with your account, you have been ejected from the server.");
	SendClientMessage(playerid, color_error, "Please visit the forums and post this in the bug section.");
	format(str, sizeof(str), "Forums: %s", server_website);
	SendClientMessage(playerid, color_error, str);
	Kick(playerid);
	return 1;
}

stock WipeChat(playerid)
{
	for(new a = 0; a < 10; a++)
	{
	    SendClientMessage(playerid, 0xFFFFFFFF, " ");
	}
	
	return 1;
}

stock IsPlayerLoggedIn(playerid)
{
	if(PlayerInfo[playerid][pLoggedIn] == 1)
	{
		return 1;
	}
	
	return 0;
}

stock SendClientNewMessage(playerid, color, Message[])
{
	WipeChat(playerid);
	SendClientMessage(playerid, color, Message);
	return 1;
}

stock SendClientMessageToAllEx(playerid, color, Message[])
{
	for(new a = 0, b = GetMaxPlayers(); a < b; a++)
	{
	    if(a != playerid)
	    {
	        SendClientMessage(a, color, Message);
		}
	}
	
	return 1;
}

stock RangeMessage(playerid, Float:Range, Message[])
{
	GetPlayerPos(playerid, X, Y, Z);
	for(new a = 0, b = GetMaxPlayers(); a < b; a++)
	{
	    if(IsPlayerInRangeOfPoint(a, Range, X, Y, Z))
	    {
			format(str, sizeof(str), "%s", Message);
	        SendClientMessage(a, COLOR_SILVER, str);
		}
	}
}

stock GivePlayerCash(playerid, money)
{
    PlayerInfo[playerid][pMoney] += money;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
    return Cash[playerid];
}
stock SetPlayerCash(playerid, money)
{
    PlayerInfo[playerid][pMoney] = money;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
    return PlayerInfo[playerid][pMoney];
}
stock ResetPlayerCash(playerid)
{
    PlayerInfo[playerid][pMoney] = 0;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
    return PlayerInfo[playerid][pMoney];
}

stock StartQuestions(playerid)
{
	PlayerInfo[playerid][pQuestionIdx] = 0;
	PlayerInfo[playerid][pQuestions] = 0;

	TogglePlayerControllable(playerid, false);
	SetPlayerTime(playerid, 12, 00);
	SetPlayerPos(playerid, questions_camera_posx, questions_camera_posy, questions_camera_posz+10.0);
	SetPlayerCameraPos(playerid, questions_camera_posx, questions_camera_posy, questions_camera_posz);
	SetPlayerCameraLookAt(playerid, questions_cameralook_posx, questions_cameralook_posy, questions_cameralook_posz);
	SetPlayerInterior(playerid, questions_camera_interior);
	
	format(bigstr, sizeof(bigstr), "%s\n%s\n%s", qData[0][Choice1], qData[0][Choice2], qData[0][Choice3]);
	format(str, sizeof(str), "{FFFFA8}%s", qData[0][Question]);

	ShowPlayerDialog(playerid, DIALOG_QUESTIONS, DIALOG_STYLE_LIST, str, bigstr, "Next", "Quit");

	format(str, sizeof(str), "Customs Officer: Question one, %s", qData[0][Question]);
	SendClientMessage(playerid, color_questions, str);
	return 1;
}

stock GenderStr(GenderValue)
{
	switch(GenderValue)
	{
	    case GENDER_MALE:
	    {
			format(str, sizeof(str), "Male");
		}
		case GENDER_FEMALE:
		{
		    format(str, sizeof(str), "Female");
		}
	}

	return str;
}

stock FormalGender(GenderValue)
{
    switch(GenderValue)
	{
	    case GENDER_MALE:
	    {
			format(str, sizeof(str), "Sir");
		}
		case GENDER_FEMALE:
		{
		    format(str, sizeof(str), "Madam");
		}
	}

	return str;
}

//-------- COMMANDS


//-------------------
Im trying delete #include <sscanf2> and #define mysql_user_string "e<p<|>ds[24]s[64]s[16]ds[32]dddffffdddddffddddddddds[20]>"

but does not work anymore login or register

Sorry for my bad English :/
Reply
#2

Do you have the sscanf plugin and the most up to date one?
Reply
#3

My sscanf plugin version is 2.8.1
Reply
#4

Help please
Reply
#5

Please download new version of sscanf include and check the version of your plugin at here: https://sampforum.blast.hk/showthread.php?tid=120356
after that recompile your all scripts that using sscanf
Reply
#6

Код:
Player TheNerka(0) - SSCANF loading error
doesn't work

Mysql log:

Код:
[09:32:04] ---------------------------

[09:32:04] MySQL Debugging activated (07/14/14)

[09:32:04] ---------------------------

[09:32:04]  

[09:32:04] >> mysql_fetch_field_row( Connection handle: 1 )

[09:32:04] CMySQLHandler::FetchField(ip) - You cannot call this function now. (Reason: Fields/Rows are empty.)

[09:32:04] ---------------------------

[09:32:04] MySQL Debugging de-activated

[09:32:04] ---------------------------
Reply
#7

Quote:
Originally Posted by TheNerka
Посмотреть сообщение
Код:
Player TheNerka(0) - SSCANF loading error
doesn't work

Mysql log:

Код:
[09:32:04] ---------------------------

[09:32:04] MySQL Debugging activated (07/14/14)

[09:32:04] ---------------------------

[09:32:04]  

[09:32:04] >> mysql_fetch_field_row( Connection handle: 1 )

[09:32:04] CMySQLHandler::FetchField(ip) - You cannot call this function now. (Reason: Fields/Rows are empty.)

[09:32:04] ---------------------------

[09:32:04] MySQL Debugging de-activated

[09:32:04] ---------------------------
You missed something in your script. Try to download new version of mysql. Maybe your mysql host not working
Reply
#8

But all save im mysql, my mysql host: Ampps
Reply
#9

My mysql version R5
Reply
#10

anyone going to help?

PS: saffierr im sending pm skype
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)