22.09.2017, 17:28
i cannot go to class selection after register or login.it show the spawn button but the button cannot spawn if i click.
p.s:i use gammix gammode.sorry noob.i dont no where is error or bug in the script.
PHP код:
public OnPlayerRequestClass(PID, classid)
{
if (!GetPVarInt(playerid, "LoggedIn"))
{
if(IsPlayerNPC(PID)) return 1;
PlayerTextDrawShow(PID,Textdraw0);
PlayerTextDrawShow(PID,Textdraw1);
PlayerTextDrawShow(PID,Textdraw2);
PlayerTextDrawShow(PID,Textdraw3);
if(gPlayerHasCitySelected[PID]) {
ClassSel_SetupCharSelection(PID);
if(gPlayerCitySelection[PID] == CITY_LOS_SANTOS)
{
new string[250];
format(string,sizeof(string),"City: ~y~Las Venturas~n~~w~~h~Skin: ~y~%d",GetPlayerSkin(PID));
PlayerTextDrawSetString(PID,Textdraw3,string);
ApplyAnimation (PID, "ON_LOOKERS", "Wave_loop", 1, 1, 1, 1, 0, 0);
}
else if(gPlayerCitySelection[PID] == CITY_LAS_VENTURAS)
{
new string[250];
format(string,sizeof(string),"City: ~y~Las Venturas~n~~w~~h~Skin: ~y~%d",GetPlayerSkin(PID));
PlayerTextDrawSetString(PID,Textdraw3,string);
ApplyAnimation (PID, "ON_LOOKERS", "Wave_loop", 1, 1, 1, 1, 0, 0);
}
else if(gPlayerCitySelection[PID] == CITY_SAN_FIERRO)
{
new string[250];
format(string,sizeof(string),"City: ~y~San Fierro~n~~w~~h~Skin: ~y~%d",GetPlayerSkin(PID));
PlayerTextDrawSetString(PID,Textdraw3,string);
ApplyAnimation (PID, "ON_LOOKERS", "Wave_loop", 1, 1, 1, 1, 0, 0);
}
return 1;
} else {
if(GetPlayerState(PID) != PLAYER_STATE_SPECTATING) {
TogglePlayerSpectating(PID,1);
gPlayerCitySelection[PID] = -1;
}
}
}
return 0;
}
PHP код:
Dialog:LOGIN(playerid, response, listitem, inputtext[])
{
if (!response)
{
Dialog_Show(playerid, OPTIONS, DIALOG_STYLE_LIST, "Account Options...", "Forgot password\nForgot username\nExit to desktop", "Select", "Back");
return 1;
}
new string[256];
new hash[64];
SHA256_PassHash(inputtext, User[playerid][USER_SALT], hash, sizeof(hash));
if (strcmp(hash, User[playerid][USER_PASSWORD]))
{
if (++iLoginAttempts[playerid] == MAX_LOGIN_ATTEMPTS)
{
new lock_timestamp = gettime() + (MAX_ACCOUNT_LOCKTIME * 60);
new ip[18];
GetPlayerIp(playerid, ip, 18);
format(string, sizeof(string), "INSERT INTO `temp_blocked_users` VALUES('%s', %i, %i)", ip, lock_timestamp, User[playerid][USER_ID]);
db_query(db, string);
SendClientMessage(playerid, COLOR_RED, "Sorry! The account has been temporarily locked on your IP. due to "#MAX_LOGIN_ATTEMPTS"/"#MAX_LOGIN_ATTEMPTS" failed login attempts.");
format(string, sizeof(string), "If you forgot your password/username, click on 'Options' in login window next time (you may retry in %s).", ReturnTimelapse(gettime(), lock_timestamp));
SendClientMessage(playerid, COLOR_RED, string);
return Kick(playerid);
}
Dialog_Show(playerid, LOGIN, DIALOG_STYLE_INPUT, "Account Login...", white "Insert your secret password to access this account. If you failed in "yellow""#MAX_LOGIN_ATTEMPTS" "white"attempts, account will be locked for "yellow""#MAX_ACCOUNT_LOCKTIME" "white"minutes.", "Continue", "Options");
format(string, sizeof(string), "Incorrect password! Your login tries left: %i/"#MAX_LOGIN_ATTEMPTS" attempts.", iLoginAttempts[playerid]);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
new name[MAX_PLAYER_NAME],
ip[18];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
GetPlayerIp(playerid, ip, 18);
format(string, sizeof(string), "UPDATE `users` SET `lastlogin_timestamp` = %i, `ip` = '%s', `longip` = %i WHERE `id` = %i", gettime(), ip, IpToLong(ip), User[playerid][USER_ID]);
db_query(db, string);
format(string, sizeof(string), "Successfully logged in! Welcome back to our server %s, we hope you enjoy your stay. [Last login: %s ago]", name, ReturnTimelapse(User[playerid][USER_LASTLOGIN_TIMESTAMP], gettime()));
SendClientMessage(playerid, COLOR_GREEN, string);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
SetPVarInt(playerid, "LoggedIn", 1);
OnPlayerRequestClass(playerid, 0);
return 1;
}
Dialog:REGISTER(playerid, response, listitem, inputtext[])
{
if (!response)
{
Dialog_Show(playerid, OPTIONS, DIALOG_STYLE_LIST, "Account Options...", "Forgot password\nForgot username\nExit to desktop", "Select", "Back");
return 1;
}
if (!(MIN_PASSWORD_LENGTH <= strlen(inputtext) <= MAX_PASSWORD_LENGTH))
{
Dialog_Show(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "Account Registeration... [Step: 1/3]", white "Welcome to our server. We will take you through "green"3 simple steps "white"to register your account with a backup option in case you forgot your password!\nPlease enter a password, "red"case sensitivity"white" is on.", "Continue", "Options");
SendClientMessage(playerid, COLOR_RED, "Invalid password length, must be between "#MIN_PASSWORD_LENGTH" - "#MAX_PASSWORD_LENGTH" characters.");
return 1;
}
#if defined SECURE_PASSWORD_ONLY
new bool:contain_number,
bool:contain_highercase,
bool:contain_lowercase;
for (new i, j = strlen(inputtext); i < j; i++)
{
switch (inputtext[i])
{
case '0'..'9':
contain_number = true;
case 'A'..'Z':
contain_highercase = true;
case 'a'..'z':
contain_lowercase = true;
}
if (contain_number && contain_highercase && contain_lowercase)
break;
}
if (!contain_number || !contain_highercase || !contain_lowercase)
{
Dialog_Show(playerid, REGISTER, DIALOG_STYLE_INPUT, "Account Registeration... [Step: 1/3]", white "Welcome to our server. We will take you through "white"3 simple steps "white"to register your account with a backup option in case you forgot your password!\nPlease enter a password, "red"case sensitivity"white" is on.", "Continue", "Options");
SendClientMessage(playerid, COLOR_RED, "Password must contain atleast a Highercase, a Lowercase and a Number.");
return 1;
}
#endif
for (new i; i < 64; i++)
{
User[playerid][USER_SALT][i] = (random('z' - 'A') + 'A');
}
User[playerid][USER_SALT][64] = EOS;
SHA256_PassHash(inputtext, User[playerid][USER_SALT], User[playerid][USER_PASSWORD], 64);
new list[2 + (sizeof(SECURITY_QUESTIONS) * MAX_SECURITY_QUESTION_SIZE)];
for (new i; i < sizeof(SECURITY_QUESTIONS); i++)
{
strcat(list, SECURITY_QUESTIONS[i]);
strcat(list, "\n");
}
Dialog_Show(playerid, SEC_QUESTION, DIALOG_STYLE_LIST, "Account Registeration... [Step: 2/3]", list, "Continue", "Back");
SendClientMessage(playerid, COLOR_WHITE, "[Step: 2/3] Select a security question. This will help you retrieve your password in case you forget it any time soon!");
PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
return 1;
}
Dialog:SEC_QUESTION(playerid, response, listitem, inputtext[])
{
if (!response)
{
Dialog_Show(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "Account Registeration... [Step: 1/3]", white "Welcome to our server. We will take you through "green"3 simple steps "white"to register your account with a backup option in case you forgot your password!\nPlease enter a password, "red"case sensitivity"white" is on.", "Continue", "Options");
SendClientMessage(playerid, COLOR_WHITE, "[Step: 1/3] Enter your new account's password.");
return 1;
}
new meow[256];
format(User[playerid][USER_SECURITY_QUESTION], MAX_SECURITY_QUESTION_SIZE, SECURITY_QUESTIONS[listitem]);
format(meow, sizeof(meow), red"%s\n"white"Insert your answer below in the box. (don't worry about CAPS, answers are NOT case sensitive).", SECURITY_QUESTIONS[listitem]);
Dialog_Show(playerid, SEC_ANSWER, DIALOG_STYLE_INPUT, "Account Registeration... [Step: 3/3]", meow, "Confirm", "Back");
SendClientMessage(playerid, COLOR_WHITE, "[Step: 3/3] Write the answer to your secuirty question and you'll be done :)");
PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
return 1;
}
Dialog:SEC_ANSWER(playerid, response, listitem, inputtext[])
{
if (!response)
{
new list[2 + (sizeof(SECURITY_QUESTIONS) * MAX_SECURITY_QUESTION_SIZE)];
for (new i; i < sizeof(SECURITY_QUESTIONS); i++)
{
strcat(list, SECURITY_QUESTIONS[i]);
strcat(list, "\n");
}
Dialog_Show(playerid, SEC_QUESTION, DIALOG_STYLE_LIST, "Account Registeration... [Step: 2/3]", list, "Continue", "Back");
SendClientMessage(playerid, COLOR_WHITE, "[Step: 2/3] Select a security question. This will help you retrieve your password in case you forget it any time soon!");
return 1;
}
new string[512];
if (strlen(inputtext) < MIN_PASSWORD_LENGTH || inputtext[0] == ' ')
{
format(string, sizeof(string), green"%s\n"white"Insert your answer below in the box. (don't worry about CAPS, answers are NOT case sensitive).", SECURITY_QUESTIONS[listitem]);
Dialog_Show(playerid, SEC_ANSWER, DIALOG_STYLE_INPUT, "Account Registeration... [Step: 3/3]", string, "Confirm", "Back");
SendClientMessage(playerid, COLOR_RED, "Security answer cannot be an less than "#MIN_PASSWORD_LENGTH" characters.");
return 1;
}
for (new i, j = strlen(inputtext); i < j; i++)
{
inputtext[i] = tolower(inputtext[i]);
}
SHA256_PassHash(inputtext, User[playerid][USER_SALT], User[playerid][USER_SECURITY_ANSWER], 64);
new name[MAX_PLAYER_NAME],
ip[18];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
GetPlayerIp(playerid, ip, 18);
format(string, sizeof(string), "INSERT INTO `users`(`name`, `ip`, `longip`, `password`, `salt`, `sec_question`, `sec_answer`, `register_timestamp`, `lastlogin_timestamp`) VALUES('%s', '%s', %i, '%q', '%q', '%q', '%q', %i, %i)", name, ip, IpToLong(ip), User[playerid][USER_PASSWORD], User[playerid][USER_SALT], User[playerid][USER_SECURITY_QUESTION], User[playerid][USER_SECURITY_ANSWER], gettime(), gettime());
db_query(db, string);
format(string, sizeof(string), "SELECT `id` FROM `users` WHERE `name` = '%q' LIMIT 1", name);
new DBResult:result = db_query(db, string);
User[playerid][USER_ID] = db_get_field_int(result, 0);
db_free_result(result);
format(string, sizeof(string), "Successfully registered! Welcome to our server %s, we hope you enjoy your stay. [IP: %s]", name, ip);
GivePlayerMoney(playerid, 5000);
SendClientMessage(playerid, COLOR_GREEN, string);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
SetPVarInt(playerid, "LoggedIn", 1);
return 1;
}
PHP код:
public OnPlayerConnect(PID)
{
new str[128];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(PID,PlayerName,sizeof(PlayerName));
format(str,sizeof(str),"%s {F40006}[ID %i] {B7F523} has joined the server from ",PlayerName ,PID);
scms(LIGHTORANGE,str);
playerCar[PID] = INVALID_VEHICLE_ID;
rBit2_Set(CC LEL, PID, false);
KillStreak[PID] = 0;
DM[PID] = 0;
gRoomP[playerid] = 0;
gPlayerCitySelection[PID] = -1;
gPlayerHasCitySelected[PID] = 0;
gPlayerLastCitySelectionTick[PID] = GetTickCount();
Textdraw0 = CreatePlayerTextDraw(PID,14.000000, 300.000000, "~r~C~w~~h~C ~r~B~w~~h~UKIT");
PlayerTextDrawBackgroundColor(PID,Textdraw0, 255);
PlayerTextDrawFont(PID,Textdraw0, 3);
PlayerTextDrawLetterSize(PID,Textdraw0, 0.740000, 2.400000);
PlayerTextDrawColor(PID,Textdraw0, -1);
PlayerTextDrawSetOutline(PID,Textdraw0, 1);
PlayerTextDrawSetProportional(PID,Textdraw0, 1);
PlayerTextDrawSetSelectable(PID,Textdraw0, 0);
Textdraw1 = CreatePlayerTextDraw(PID,149.000000, 315.000000, "#MALAYSIA");
PlayerTextDrawBackgroundColor(PID,Textdraw1, 255);
PlayerTextDrawFont(PID,Textdraw1, 0);
PlayerTextDrawLetterSize(PID,Textdraw1, 0.550000, 1.700000);
PlayerTextDrawColor(PID,Textdraw1, -1);
PlayerTextDrawSetOutline(PID,Textdraw1, 1);
PlayerTextDrawSetProportional(PID,Textdraw1, 1);
PlayerTextDrawSetSelectable(PID,Textdraw1, 0);
Textdraw2 = CreatePlayerTextDraw(PID,16.000000, 328.000000, "Welcome to GTA: CC LEL server. i hope you will enjoy your stay!~n~~n~Press LMB or RMB to switch cities and Press MMB to selec");
PlayerTextDrawBackgroundColor(PID,Textdraw2, 255);
PlayerTextDrawFont(PID,Textdraw2, 1);
PlayerTextDrawLetterSize(PID,Textdraw2, 0.150000, 0.700000);
PlayerTextDrawColor(PID,Textdraw2, -1);
PlayerTextDrawSetOutline(PID,Textdraw2, 0);
PlayerTextDrawSetProportional(PID,Textdraw2, 1);
PlayerTextDrawSetShadow(PID,Textdraw2, 1);
PlayerTextDrawUseBox(PID,Textdraw2, 1);
PlayerTextDrawBoxColor(PID,Textdraw2, 0);
PlayerTextDrawTextSize(PID,Textdraw2, 149.000000, 0.000000);
PlayerTextDrawSetSelectable(PID,Textdraw2, 0);
Textdraw3 = CreatePlayerTextDraw(PID,16.000000, 365.000000, "City: ~y~Los Santos~n~~w~~h~Skin: ~y~285");
PlayerTextDrawBackgroundColor(PID,Textdraw3, 255);
PlayerTextDrawFont(PID,Textdraw3, 1);
PlayerTextDrawLetterSize(PID,Textdraw3, 0.250000, 1.200000);
PlayerTextDrawColor(PID,Textdraw3, -1);
PlayerTextDrawSetOutline(PID,Textdraw3, 0);
PlayerTextDrawSetProportional(PID,Textdraw3, 1);
PlayerTextDrawSetShadow(PID,Textdraw3, 1);
PlayerTextDrawUseBox(PID,Textdraw3, 1);
PlayerTextDrawBoxColor(PID,Textdraw3, 0);
PlayerTextDrawTextSize(PID,Textdraw3, 149.000000, 0.000000);
PlayerTextDrawSetSelectable(PID,Textdraw3, 0);
GameTextForPlayer(PID,"~w~Welcome to LEL",6000,4);
scm(PID,0x2685B4AA,"{C19D53} Welcome to {B7F523}CC{C4C035}LL");
SetTimerEx("OnPlayerJoin", 0001, false, "i", playerid);
return 1;
}
PHP код:
forward OnPlayerJoin(playerid);
public OnPlayerJoin(playerid)
{
new string[150];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string, sizeof(string), "SELECT * FROM `users` WHERE `name` = '%q' LIMIT 1", name);
new DBResult:result = db_query(db, string);
if (db_num_rows(result) == 0)
{
User[playerid][USER_ID] = -1;
User[playerid][USER_PASSWORD][0] = EOS;
User[playerid][USER_SALT][0] = EOS;
User[playerid][USER_KILLS] = 0;
User[playerid][USER_DEATHS] = 0;
User[playerid][USER_SCORE] = 0;
User[playerid][USER_MONEY] = 0;
User[playerid][USER_ADMIN] = 0;
User[playerid][USER_VIP] = 0;
User[playerid][USER_REGISTER_TIMESTAMP] = 0;
User[playerid][USER_LASTLOGIN_TIMESTAMP] = 0;
User[playerid][USER_SECURITY_QUESTION][0] = EOS;
User[playerid][USER_SECURITY_ANSWER][0] = EOS;
Dialog_Show(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "Account Registeration... [Step: 1/3]", "white" "Welcome to our server. We will take you through "green"3 simple steps "white"to register your account with a backup option in case you forgot your password!\nPlease enter a password, "red"case sensitivity"white" is on.", "Continue", "Options");
SendClientMessage(playerid, COLOR_WHITE, "[Step: 1/3] Enter your new account's password.");
}
else
{
iLoginAttempts[playerid] = 0;
iAnswerAttempts[playerid] = 0;
User[playerid][USER_ID] = db_get_field_assoc_int(result, "id");
format(string, sizeof(string), "SELECT `lock_timestamp` FROM `temp_blocked_users` WHERE `user_id` = %i LIMIT 1", User[playerid][USER_ID]);
new DBResult:lock_result = db_query(db, string);
if (db_num_rows(lock_result) == 1)
{
new lock_timestamp = db_get_field_int(lock_result, 0);
if ((gettime() - lock_timestamp) < 0)
{
SendClientMessage(playerid, COLOR_RED, "Sorry! The account is temporarily locked on your IP. due to "#MAX_LOGIN_ATTEMPTS"/"#MAX_LOGIN_ATTEMPTS" failed login attempts.");
format(string, sizeof(string), "You'll be able to try again in %s.", ReturnTimelapse(gettime(), lock_timestamp));
SendClientMessage(playerid, COLOR_RED, string);
db_free_result(result);
db_free_result(lock_result);
return Kick(playerid);
}
else
{
new ip[18];
GetPlayerIp(playerid, ip, 18);
format(string, sizeof(string), "DELETE FROM `temp_blocked_users` WHERE `user_id` = %i AND `ip` = '%s'", User[playerid][USER_ID], ip);
db_query(db, string);
}
}
db_free_result(lock_result);
db_get_field_assoc(result, "password", User[playerid][USER_PASSWORD], 64);
db_get_field_assoc(result, "salt", User[playerid][USER_SALT], 64);
User[playerid][USER_SALT][64] = EOS;
User[playerid][USER_KILLS] = db_get_field_assoc_int(result, "kills");
User[playerid][USER_DEATHS] = db_get_field_assoc_int(result, "deaths");
User[playerid][USER_SCORE] = db_get_field_assoc_int(result, "score");
User[playerid][USER_MONEY] = db_get_field_assoc_int(result, "money");
User[playerid][USER_ADMIN] = db_get_field_assoc_int(result, "adminlevel");
User[playerid][USER_VIP] = db_get_field_assoc_int(result, "viplevel");
User[playerid][USER_REGISTER_TIMESTAMP] = db_get_field_assoc_int(result, "register_timestamp");
User[playerid][USER_LASTLOGIN_TIMESTAMP] = db_get_field_assoc_int(result, "lastlogin_timestamp");
db_get_field_assoc(result, "sec_question", User[playerid][USER_SECURITY_QUESTION], MAX_SECURITY_QUESTION_SIZE);
db_get_field_assoc(result, "sec_answer", User[playerid][USER_SECURITY_ANSWER], MAX_PASSWORD_LENGTH * 2);
Dialog_Show(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Account Login...", white "Insert your secret password to access this account. If you failed in "yellow""#MAX_LOGIN_ATTEMPTS" "white"attempts, account will be locked for "yellow""#MAX_ACCOUNT_LOCKTIME" "white"minutes.", "Continue", "Options");
}
db_free_result(result);
return 1;
}
PHP код:
public OnPlayerDisconnect(PID, reason)
{
new str[128];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(PID,PlayerName,sizeof(PlayerName));
format(str,sizeof(str),"%s {F40006} [ID %i] {B7F523} has left the server",PlayerName ,PID);
scms(YELLOW,str);
Delete3DTextLabel(label[PID]);
DestroyDynamic3DTextLabel(wanted[PID]);
DestroyVehicle(playerCar[PID]);
KillStreak[PID] = 0;
DM[PID] = 0;
if (GetPVarInt(playerid, "LoggedIn"))
{
new string[1024],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string, sizeof(string), "UPDATE `users` SET `name` = '%s', `password` = '%q', `salt` = '%q', `kills` = %i, `deaths` = %i, `score` = %i, `money` = %i, `adminlevel` = %i, `viplevel` = %i WHERE `id` = %i",
name, User[playerid][USER_PASSWORD], User[playerid][USER_SALT], User[playerid][USER_KILLS], User[playerid][USER_DEATHS], GetPlayerScore(playerid), GetPlayerMoney(playerid), User[playerid][USER_ADMIN], User[playerid][USER_VIP], User[playerid][USER_ID]);
db_query(db, string);
}
return 1;
}
p.s:i use gammix gammode.sorry noob.i dont no where is error or bug in the script.