[CRASH]: OnPlayerLogin?
#1

Hey guys,

Well I posted a topic recently explaining a problem that occurred which I thought I had solved. Anyhow, here's the problem which I believe is generating the error as the server only crashes once OnPlayerLogin is called. Although, I'm not able to find anything under the callback which could cause it.

Here's a copy of my OnPlayerLogin-

pawn Код:
public OnPlayerLogin(playerid, password[])
{
    new string[128], Year, Month, Day, Minute, Hour, Second, Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "Accounts/%s.ini", Name);
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    if(IsPlayerConnected(playerid) && PlayerLogged[playerid] == 0)
    {
        strmid(PlayerInfo[playerid][pPassword],dini_Get(string,"Password"),0,strlen(dini_Get(string,"Password")),255);
        if(strcmp(PlayerInfo[playerid][pPassword],password, true) == 0)
        {
            PlayerInfo[playerid][pAdmin] = dini_Int(string,"AdminLevel");
            PlayerInfo[playerid][pConnectTime] = dini_Int(string,"ConnectTime");
            PlayerInfo[playerid][pModel] = dini_Int(string,"Model");
            PlayerInfo[playerid][pLastX] = dini_Float(string,"LastX");
            PlayerInfo[playerid][pLastY] = dini_Float(string,"LastY");
            PlayerInfo[playerid][pLastZ] = dini_Float(string,"LastZ");
            PlayerInfo[playerid][pLastWorld] = dini_Int(string,"LastWorld");
            PlayerInfo[playerid][pLastInt] = dini_Int(string,"LastInt");
            PlayerInfo[playerid][pLastLoginMinute] = dini_Int(string,"LastLoginMinute");
            PlayerInfo[playerid][pLastLoginHour] = dini_Int(string,"LastLoginHour");
            PlayerInfo[playerid][pLastLoginDay] = dini_Int(string,"LastLoginDay");
            PlayerInfo[playerid][pLastLoginMonth] = dini_Int(string,"LastLoginMonth");
            PlayerInfo[playerid][pLastLoginYear] = dini_Int(string,"LastLoginYear");
            strmid(PlayerInfo[playerid][pLastIP], dini_Get(string,"LastIP"), 0, 24, 255);
            dini_IntSet(string,"LastLoginMinute",Minute);
            dini_IntSet(string,"LastLoginHour",Hour);
            dini_IntSet(string,"LastLoginDay",Day);
            dini_IntSet(string,"LastLoginMonth",Month);
            dini_IntSet(string,"LastLoginYear",Year);
            SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pModel],REG_POSX,REG_POSY,REG_POSZ,0,0,0,0,0,0,0);
            SpawnPlayer(playerid);
            SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pLastWorld]);
            SetPlayerInterior(playerid, PlayerInfo[playerid][pLastInt]);
            SetPlayerColor(playerid,COLOR_WHITE);
            ClearChatbox(playerid, 15);
            SendClientMessage(playerid,COLOR_LBLUE,"{EE0000}|{FFFFFF}_____________________________________________________{EE0000}|{FFFFFF}");
            format(string,sizeof(string),"{FFCC66}[INFO]: {FFFFFF}Welcome back to {EE0000}%s{FFFFFF},%s.",SERVER_NAME,GPN(playerid));
            SendClientMessage(playerid,COLOR_WHITE,string);
            format(string,sizeof(string),"{FFCC66}[INFO]: {FFFFFF}Version: {EE0000}%s",SERVER_VERS);
            SendClientMessage(playerid,COLOR_WHITE,string);
            format(string,sizeof(string),"{FFCC66}[INFO]: {FFFFFF}Website: {EE0000}%s",SERVER_URL);
            SendClientMessage(playerid,COLOR_WHITE,string);
            SendClientMessage(playerid,COLOR_LBLUE,"{EE0000}|{FFFFFF}_____________________________________________________{EE0000}|{FFFFFF}");
            format(string,sizeof(string),"{FFCC66}[INFO]: {FFFFFF}You've successfully logged in.",SERVER_VERS);
            SendClientMessage(playerid,COLOR_WHITE,string);
            new mtext[54];
            switch(PlayerInfo[playerid][pLastLoginMonth])
            {
                case 1: mtext = "January";
                case 2: mtext = "Febuary";
                case 3: mtext = "March";
                case 4: mtext = "April";
                case 5: mtext = "May";
                case 6: mtext = "June";
                case 7: mtext = "July";
                case 8: mtext = "August";
                case 9: mtext = "September";
                case 10: mtext = "October";
                case 11: mtext = "November";
                case 12: mtext = "December";
            }
            if(PlayerInfo[playerid][pAdmin] == 0)
            {
                if(PlayerInfo[playerid][pLastLoginMinute] < 10)
                {
                    format(string,sizeof(string),"{FFCC66}[INFO]: {FFFFFF}Last logged in: %d %s %d, %d:0%d",PlayerInfo[playerid][pLastLoginDay],mtext,PlayerInfo[playerid][pLastLoginYear],PlayerInfo[playerid][pLastLoginHour],PlayerInfo[playerid][pLastLoginMinute]);
                }
                else
                {
                    format(string,sizeof(string),"{FFCC66}[INFO]: {FFFFFF}Last logged in: %d %s %d, %d:%d",PlayerInfo[playerid][pLastLoginDay],mtext,PlayerInfo[playerid][pLastLoginYear],PlayerInfo[playerid][pLastLoginHour],PlayerInfo[playerid][pLastLoginMinute]);
                }
            }
            else
            {
                if(PlayerInfo[playerid][pLastLoginMinute] < 10)
                {
                    format(string,sizeof(string),"{FFCC66}[INFO]: {FFFFFF}Last logged in: %d %s %d, %d:0%d (IP: %s)",PlayerInfo[playerid][pLastLoginDay],mtext,PlayerInfo[playerid][pLastLoginYear],PlayerInfo[playerid][pLastLoginHour],PlayerInfo[playerid][pLastLoginMinute], PlayerInfo[playerid][pLastIP]);
                }
                else
                {
                    format(string,sizeof(string),"{FFCC66}[INFO]: {FFFFFF}Last logged in: %d %s %d, %d:%d (IP: %s)",PlayerInfo[playerid][pLastLoginDay],mtext,PlayerInfo[playerid][pLastLoginYear],PlayerInfo[playerid][pLastLoginHour],PlayerInfo[playerid][pLastLoginMinute], PlayerInfo[playerid][pLastIP]);
                }
            }
            SendClientMessage(playerid,COLOR_WHITE,string);
            PlayerPlaySound(playerid, 1069, 0.0, 0.0, 0.0);
            PlayerLogged[playerid] = 1;
        }
        else
        {
            SendClientMessage(playerid,COLOR_LBLUE,"{EE0000}|{FFFFFF}_____________________________________________________{EE0000}|{FFFFFF}");
            SendClientMessage(playerid,COLOR_WHITE,"{FFCC66}[INFO]: {FFFFFF}It appears this account is already registered.");
            SendClientMessage(playerid,COLOR_WHITE,"{FFCC66}[INFO]: {FFFFFF}Please login or connect using a different name.");
            SendClientMessage(playerid,COLOR_LBLUE,"{EE0000}|{FFFFFF}_____________________________________________________{EE0000}|{FFFFFF}");
            PlayerLogTries[playerid]++;
            new loginstring[128];
            format(loginstring,sizeof(loginstring),"{FFFFFF}Welcome, {EE0000}%s\n{FFFFFF}That nick is registered.\nYou can now login:",GPN(playerid));
            ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"{00CCFF}FL-RP: {FFFFFF}Login",loginstring,"Login","Exit");
            if(PlayerLogTries[playerid] == 3)
            {
                Kick(playerid);
            }
            return 1;
        }
    }
    return 1;
}
And the crash code:

pawn Код:
--------------------------

SA-MP Server: 0.3c RC1



Exception At Address: 0x77BE6BF0



Registers:

EAX: 0x00000024 EBX: 0x00000050 ECX: 0x004E54F0 EDX: 0x00000000

ESI: 0x00000024 EDI: 0x00000020 EBP: 0x0012FBB0 ESP: 0x0012FB9C

EFLAGS: 0x00010212



Stack:

+0000: 0x02789148   0x00000000   0x00000001   0x75E94990

+0010: 0x00000000   0x0012FBEC   0x004A218E   0x00000020

+0020: 0x004A27DE   0x00000000   0x02789148   0x00000000

+0030: 0x00000050   0x0012FC10   0x0012FBC4   0x0012F7A8

+0040: 0x0012FE04   0x004A65D4   0x004C1210   0xFFFFFFFF

+0050: 0x00000000   0x0040551E   0x00000050   0x00000000

+0060: 0x0278913C   0x0012FC1C   0x00000000   0x004059AF

+0070: 0x00000001   0x01541EC8   0x02772EB8   0x00000013

+0080: 0x0276AF8C   0x00402C20   0x01541EC8   0x02789148

+0090: 0x01541EC8   0x01541EC8   0x0166E520   0x0278AC18

+00A0: 0x00000000   0x00013148   0x00016284   0x00016D48

+00B0: 0x00012D4C   0x00016698   0x00012D4C   0x02769D1C

+00C0: 0x02772EB8   0x61006574   0x02769450   0x0000919C

+00D0: 0x00483540   0x01541EC8   0x0012FC88   0x0000000D

+00E0: 0x01541EC8   0x00000000   0x01668E08   0x00000001

+00F0: 0x0000000D   0x00499D2B   0x00000000   0x7650EF66

+0100: 0x01668E08   0x0166E520   0x77CE9F8C   0x6F4E14C8

+0110: 0x00000000   0x78440000   0x9C9244C9   0x0473C511

+0120: 0x04EE4162   0x00003F35   0x00000000   0x04F80000

+0130: 0x0064BF35   0x58840000   0xB0AABD36   0x20E0BBC7
Reply
#2

Might not be the script but the 0.3c version.
Reply
#3

Yeah, thanks for posting- To be honest, it wasn't even OnPlayerLogin that was causing it but OnPlayerUpdate which was using a simple check to check if he was on foot or in a vehicle- But it's fixed now, thanks!
Reply
#4

You are using YSI include?

or

Streamer Plugins ?
Reply
#5

Change it to easy register and login and true

Код:
 	     if(strcmp(cmd, "/register", true) == 0)
    {
	    new tmp[256], pname[24], string[128];
	    tmp = strtok(cmdtext, idx);
	    GetPlayerName(playerid, pname, sizeof playername);
	    if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /register [password]");
        }
        else
        {
            if (!dini_Exists(udb_encode(pname)))
            {
                dini_Create(udb_encode(pname));
                dini_IntSet(udb_encode(pname), "password", udb_hash(tmp));
                dini_IntSet(udb_encode(pname), "adminlevel", 0);
                format(string, sizeof(string), "Account %s created! You can now login with /login %s", pname, tmp);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                dini_IntSet("file", "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
            }
            else
            {
                format(string, sizeof(string), "%s is already registered.", pname,tmp);
                SendClientMessage(playerid, COLOR_BRIGHTRED, string);
            }
        }
        return 1;
    }

    if(strcmp(cmd, "/login", true) == 0)
    {
    	new tmp[256], tmp2[256], name[24], string[128];
		GetPlayerName(playerid, name, 24);
        if(logged[playerid] == -2) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You cannot use commands because you are jailed.");
        else
        if(logged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_BRIGHTRED, "You are already logged in.");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /login [password]");
        }
        else
        {
            if (dini_Exists(udb_encode(name)))
            {
                tmp2 = dini_Get(udb_encode(name), "password");
                if (udb_hash(tmp) != strval(tmp2))
                {
                    SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid Password");
                }
                else
                {
                    logged[playerid] = 1;
                    format(string, sizeof(string), "%s, you are now logged in .", playername);
                    SendClientMessage(playerid, COLOR_GREEN, string);
                    GivePlayerMoney(playerid, money[playerid]);
                    PlayerInfo[playerid][pAdminLevel] = dini_Int("file", "AdminLevel");
                }
            }
            else
			{
                format(string, sizeof(string), "You are not registered Type /register [password] to create an account!", name);
                SendClientMessage(playerid, COLOR_BRIGHTRED, string);
            }
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)