Spawn Bug
#1

Well guys, I need some help from you all to fix this bug

Well, when I connect to the server, it shows the login DialogBox




After that, when I enter a wrong password, it automatically spawns




It spawns to this specific location because of this code:

(NOTE: This is under OnPlayerSpawn function!)

Код:
if(gPlayerLogged[playerid] == 0)
	{

    	SetPlayerInterior(playerid,0);
		SetPlayerVirtualWorld(playerid, 20);
		SetPlayerPos(playerid, -1979.9329,138.0958,27.6875);
		SetPlayerPos(playerid,-1979.9329,138.0958,27.6875);
		SetPlayerFacingAngle(playerid, 90);
		SetCameraBehindPlayer(playerid);
		
        return 1;
 	}
This is the Login Dialogbox's code

Код:
if(dialogid == 1) //LOGIN
    {
		if(gPlayerLogged[playerid] == 1)
		{
			SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
			return 1;
		}
		if(response)
		{
		    if(!strlen(inputtext))
		    {
		        DisplayDialogForPlayer(playerid, 1); //login
				SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must enter a password.");
				return 1;
			}
			if(strlen(inputtext) >= 50)
			{
			    DisplayDialogForPlayer(playerid, 1); //login
				SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password is too long.");
				return 0;
			}
	        new tmppass[64];
	        new playername[MAX_PLAYER_NAME];
	        strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
	        GetPlayerName(playerid, playername, sizeof(playername));
			if(strlen(playername) == 3)
			{
			    if(strcmp(playername, "Smo", true) == 0)
			    {
					return 0;
			    }
			    else
			    {
			    	SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, that name is too short, please change it.");
			    	Kick(playerid);
			    	return 1;
				}
			}
	        Encrypt(tmppass);
	        OnPlayerLogin(playerid,tmppass,inputtext);
		}
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You chose to leave the server.");
	        Kick(playerid);
        }
    }
This is the login attempt code under OnPlayerLogin(playerid) function:

Код:
if(strcmp(PlayerInfo[playerid][pKey],password, true ) != 0)
		{
		    if(LogAttempt[playerid] < 3)
		    {
		        ++LogAttempt[playerid];
			    new relogstring[256];
			    format(relogstring, sizeof(relogstring), "{FF0000}You've entered a wrong password \n{FFFFFF}Please re-enter your password, and make sure that you enter it correct this time. (Case senstive)\n You have %d/3 attempts left.", LogAttempt[playerid]);
			    return ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Login", relogstring,"Login","Cancel");
		    }
		    else
		    {
			    new ip[16];
		   		GetPlayerIp(playerid, ip, sizeof(ip));
				new logstring[256];
				new year, month, day;
				getdate(year, month, day);
				SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: Password does not match your name. you have been kicked as a result.");
	    	   	format(logstring, sizeof(logstring), "%s [%d/%d/%d] Name: %s Pass: %s.", ip, day, month, year,PlayerName(playerid),password2);
				BLLog(logstring);
				LogAttempt[playerid] = 0;
				KickNew(playerid);
			}
	        return 1;
		}
Reply
#2

you have to show us the code under 'OnDialogResponse' callback, otherwise we'll not be able to know what the problem is
Reply
#3

Quote:
Originally Posted by OrMisicL
Посмотреть сообщение
you have to show us the code under 'OnDialogResponse' callback, otherwise we'll not be able to know what the problem is
Yeah, I know that, I am updating the screenshots, wait
Reply
#4

You might share your code with us, so we can actually help you. Just a tip.

(OnDialogResponse is what we need.)

EDIT: Posts above appeared after clicking post...
Reply
#5

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
You might share your code with us, so we can actually help you. Just a tip.

(OnDialogResponse is what we need.)
I am doing it, wait
Reply
#6

the code above spawns the player when he fails to login, just change '== 0' to '== 1', that Will spawn him only after login
Reply
#7

Quote:
Originally Posted by OrMisicL
Посмотреть сообщение
the code above spawns the player when he fails to login, just change '== 0' to '== 1', that Will spawn him only after login
bro it's under OnPlayerSpawn function.....
Reply
#8

its not that the problem, the code u pasted above checks if the players in not logged, if so then he spawns him
but if you change it to

pawn Код:
if(gPlayerLogged[playerid] == 1)
    {

        SetPlayerInterior(playerid,0);
        SetPlayerVirtualWorld(playerid, 20);
        SetPlayerPos(playerid, -1979.9329,138.0958,27.6875);
        SetPlayerPos(playerid,-1979.9329,138.0958,27.6875);
        SetPlayerFacingAngle(playerid, 90);
        SetCameraBehindPlayer(playerid);
       
        return 1;
    }
it will only spawn him if he login
Reply
#9

Well, sorry guys, I understood the problem. It was because in the OnPlayerRequestClass function, I did SpawnPlayer(playerid), due to which it spawned the player when showing tht dialog box. Anyway, thank you guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)