- Регистрация
- 20 Окт 2020
- Сообщения
- 96
- Лучшие ответы
- 0
- Репутация
- 3
И снова здравствуйте пользователи Pawn-Info
Снова нужна ваша помощь. Я дописал систему регистрации, но при логине/регистрации игрока не спавнит.
Снова нужна ваша помощь. Я дописал систему регистрации, но при логине/регистрации игрока не спавнит.
C++:
//-INCLUDES-//
#include <a_samp>
#include <a_mysql> // plugin mysql
#include <sscanf2> // plugin sscanf
//---------//
//-MYSQL SETTING's-//
#define MYSQL_HOST "localhost" // Õîñòèíã
#define MYSQL_USER "root" // Ïîëüçîâàòåëü
#define MYSQL_PASS "" // Ïàðîëü
#define MYSQL_DB "diamond" // Áàçà äàííûõ
new MySQL: dbHandle;
new query[256];
//-----------------//
//-ÌÀÊÐÎÑÛ-//
// Îñòàëüíîå
#define SERVER_NAME "Delaware Role Play | Test"
// Ñîîáùåíèÿ
#define SCM SendClientMessage
#define SCMTA SendClientMessageToAll
#define SPD ShowPlayerDialog
// Ñòèëè äèàëîãîâ
#define DSM DIALOG_STYLE_MSGBOX
#define DSL DIALOG_STYLE_LIST
#define DSP DIALOG_STYLE_PASSWORD
#define DSI DIALOG_STYLE_INPUT
#define DSTIL DIALOG_STYLE_TABLIST
#define DSTH DIALOG_STYLE_TABLIST_HEADERS
//---------//
//-ÖÂÅÒÀ-//
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_VALIK 0x73B461FF
#define COLOR_SHBAR_BG 0x000000FF
#define COLOR_SHBAR_BG2 0xB8CEF6FF
#define COLOR_ORANGE 0xFAAC58FF
#define COLOR_GREEN 0x42B02CFF
#define COLOR_GOLD 0xFFD700FF
#define COLOR_RED 0xBE2D2DFF
#define COLOR_LIGHTRED 0xFF6347FF
#define COLOR_LIGHTBLUE 0x6495EDFF
#define COLOR_LIGHTGREEN 0x9ACD32FF
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_BLUENEW 0xB8CEF6FF
#define COLOR_BLUE 0x94B0C1FF
#define COLOR_PURPLE 0xC2A2DAFF
#define COLOR_LIME 0x10F441FF
#define COLOR_GREY 0xAFAFAFFF
#define COLOR_CHAT 0xCECECEFF
#define COLOR_SCHAT 0xF0E68CFF
#define COLOR_DOCHAT 0x4682B4FF
#define COLOR_RACIO 0x2DB043FF
#define COLOR_DEPAR 0x3399ffFF
#define COLOR_ACHAT 0x99CC00FF
#define COLOR_ME 0xFF99FFFF
#define COLOR_GOV 0x045FB4FF
//-------//
//-ÍÅÍÓÆÍÀß ÕÓÉÍß-//
#define pName(%0) player_info[%0][NAME]
//----------------//
enum player
{
ID,
NAME[MAX_PLAYER_NAME],
PASS[30],
SEX,
COLOR,
}
new player_info[MAX_PLAYERS][player];
enum temp
{
LOGINTRIES,
}
new temp_info[MAX_PLAYERS][temp];
enum
{
DLG_NONE,
DLG_REG_CONFIRM,
DLG_REG_PASS,
DLG_REG_GENDER,
DLG_REG_COLOR,
DLG_REG_AGE,
DLG_REG_FINISH,
DLG_LOGIN,
}
main(){}
public OnGameModeInit()
{
dbHandle = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
if(mysql_errno() != 0)
{
print("[MYSQL] Íå óäàëîñü ïîäêëþ÷èòüñÿ ê áàçå äàííûõ");
return SendRconCommand("exit");
}
else
{
print("[MYSQL] Ïîäêëþ÷åíèå ê áàçå äàííûõ óñïåøíî");
}
SetGameModeText("Delaware-rp Russian");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
mysql_close(dbHandle);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
SetTimerEx("CheckAccountFromMysql", 1000, false, "i", playerid);
GetPlayerName(playerid, player_info[playerid][NAME], MAX_PLAYER_NAME);
temp_info[playerid][LOGINTRIES] = 3;
return 1;
}
forward CheckAccountFromMysql(playerid);
public CheckAccountFromMysql(playerid)
{
mysql_format(dbHandle, query, sizeof(query), "SELECT * FROM `accounts` WHERE `name` = '%e'", player_info[playerid][NAME]);
mysql_tquery(dbHandle, query, "GetPlayerAccountFromMysql", "i", playerid);
}
forward GetPlayerAccountFromMysql(playerid);
public GetPlayerAccountFromMysql(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows)
{
// Åñëè åñòü ñîâïàäåíèÿ, ïîêàçûâàåì àâòîðèçàöèþ
cache_get_value_name(0, "password", player_info[playerid][PASS], 31);
new tempstring[403+(-2+MAX_PLAYER_NAME)];
format(tempstring, sizeof(tempstring), "{ffffff}Äîáðî ïîæàëîâàòü íà {E88813}Delaware Role Play{FFFFFF}\n\nÂâåäèòå ñâîé ïàðîëü\nÏîïûòîê äëÿ ââîäà ïàðîëÿ: {28910B}%i", temp_info[playerid][LOGINTRIES]);
SPD(playerid, DLG_LOGIN, DSP, "{E88813}Àâòîðèçàöèÿ", tempstring, "Ïðèíÿòü", "Âûõîä");
}
else
{
// Åñëè íåòó ñîâïàäåíèé, ïîêàçûâàåì ðåãèñòðàöèþ
SPD(playerid, DLG_REG_CONFIRM, DSM, "{E88813}ß íå ðîáîò{FFFFFF}",
"{FFFFFF}×òîáû ïðîéòè ïðîâåðêó íà {E88813}ðîáîòà{FFFFFF}, íàæìèòå 'Äàëåå'\n\nÇíàéòå, ÷òî åñëè âû áóäåòå çàïóñêàòü áîòîâ. Âû áóäåòå çàáåíåíû ïî àéïè.",
"Äàëåå", "Âûõîä");
}
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return false;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DLG_REG_CONFIRM:
{
if(response)
{
PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0); // BIKE_AWARD_TRACK_START
new tempstring[403+(-2+MAX_PLAYER_NAME)];
format(tempstring, sizeof(tempstring), "{ffffff}Äîáðî ïîæàëîâàòü, {205CA2} %s{ffffff}\nÝòîò àêêàóíò {FF6347}íå çàðåãèñòðèðîâàí{ffffff} íà íàøåì ñåðâåðå.\nÄëÿ ðåãèñòðàöèè ââåäèòå ïàðîëü.\nÎí áóäåò èñïîëüçîâàòüñÿ äëÿ àâòîðèçàöèè íà íàø¸ì ñåðâåðå.", player_info[playerid][NAME]);
SPD(playerid, DLG_REG_PASS, DSI, "{E88813}(1/4) Ïàðîëü", tempstring, "Ïðèíÿòü", "Âûõîä");
}
else
{
Kick(playerid);
}
}
case DLG_REG_PASS:
{
if(response)
{
if(strlen(inputtext) < 6 || strlen(inputtext) > 30)
{
new tempstring[403+(-2+MAX_PLAYER_NAME)];
format(tempstring, sizeof(tempstring), "{ffffff}Äîáðî ïîæàëîâàòü, {205CA2} %s\nÝòîò àêêàóíò {FF6347}íå çàðåãèñòðèðîâàí{ffffff} íà íàøåì ñåðâåðå.\nÄëÿ ðåãèñòðàöèè ââåäèòå ïàðîëü.\nÎí áóäåò èñïîëüçîâàòüñÿ äëÿ àâòîðèçàöèè íà íàø¸ì ñåðâåðå.", player_info[playerid][NAME]);
SPD(playerid, DLG_REG_PASS, DSI, "{E88813}(1/4) Ïàðîëü", tempstring, "Ïðèíÿòü", "Âûõîä");
}
else if(strlen(inputtext) < 6)
{
new tempstring[403+(-2+MAX_PLAYER_NAME)];
format(tempstring, sizeof(tempstring), "{ffffff}Äîáðî ïîæàëîâàòü, íà{205CA2} %s{ffffff}\nÝòîò àêêàóíò {FF6347}íå çàðåãèñòðèðîâàí{ffffff} íà íàøåì ñåðâåðå.\nÄëÿ ðåãèñòðàöèè ââåäèòå ïàðîëü.\nÎí áóäåò èñïîëüçîâàòüñÿ äëÿ àâòîðèçàöèè íà íàø¸ì ñåðâåðå.", player_info[playerid][NAME]);
SPD(playerid, DLG_REG_PASS, DSI, "{E88813}(1/4) Ïàðîëü", tempstring, "Ïðèíÿòü", "Âûõîä");
}
else
{
format(player_info[playerid][PASS], 31, inputtext);
SPD(playerid, DLG_REG_GENDER, DSL, "{E88813}[2/4] Âûáåðèòå âàø ïîë", "Ìóæñêîé\nÆåíñêèé", "Äàëåå", " íà÷àëî");
}
return 1;
}
else
{
Kick(playerid);
}
}
case DLG_REG_GENDER:
{
if(response)
{
if(listitem == 0)
{
player_info[playerid][SEX] = 1;
return SPD(playerid, DLG_REG_COLOR, DSL, "{E88813}[3/4] Âûáåðèòå öâåò êîæè", "Ñâåòëûé\nÒ¸ìíûé", "Äàëåå", " íà÷àëî");
}
if(listitem == 1)
{
player_info[playerid][SEX] = 2;
return SPD(playerid, DLG_REG_COLOR, DSL, "{E88813}[3/4] Âûáåðèòå öâåò êîæè", "Ñâåòëûé\nÒ¸ìíûé", "Äàëåå", " íà÷àëî");
}
}
else
{
player_info[playerid][PASS][0] = EOS;
player_info[playerid][SEX] = 0;
player_info[playerid][COLOR] = 0;
}
}
case DLG_REG_COLOR:
{
if(response)
{
if(listitem == 0)
{
player_info[playerid][COLOR] = 1;
RegFinish(playerid);
return 1;
}
if(listitem == 1)
{
player_info[playerid][COLOR] = 2;
RegFinish(playerid);
return 1;
}
}
else
{
player_info[playerid][PASS][0] = EOS;
player_info[playerid][SEX] = 0;
player_info[playerid][COLOR] = 0;
}
}
case DLG_LOGIN:
{
if(response)
{
if(strcmp(player_info[playerid][PASS], inputtext) != 0)
{
temp_info[playerid][LOGINTRIES] --;
if(temp_info[playerid][LOGINTRIES] <= 0) return Kick(playerid);
cache_get_value_name(0, "password", player_info[playerid][PASS], 31);
new tempstring[403+(-2+MAX_PLAYER_NAME)];
format(tempstring, sizeof(tempstring), "{ffffff}Äîáðî ïîæàëîâàòü íà {E88813}Delaware Role Play{FFFFFF}\n\nÂâåäèòå ñâîé ïàðîëü\nÏîïûòîê äëÿ ââîäà ïàðîëÿ: {28910B}%i", temp_info[playerid][LOGINTRIES]);
SPD(playerid, DLG_LOGIN, DSP, "{E88813}Àâòîðèçàöèÿ", tempstring, "Ïðèíÿòü", "Âûõîä");
}
return 1;
}
else
{
Kick(playerid);
}
}
}
return 1;
}
forward RegFinish(playerid);
public RegFinish(playerid)
{
mysql_format(dbHandle, query, sizeof(query),
"INSERT INTO `accounts` (`name`, `password`, `sex`, `color`) VALUES ('%e', '%e', '%d', '%d')",
player_info[playerid][NAME], player_info[playerid][PASS], player_info[playerid][SEX], player_info[playerid][COLOR]);
mysql_tquery(dbHandle, query);
SCM(playerid, COLOR_VALIK, "[Ïîäñêàçêà] {FFFFFF}Ñïàñèáî âàì çà ðåãèñòðàöèþ íà íàøåì ñåðâåðå");
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}