[HELP] Server crashes on /stats
#1

When I type /stats ingame the server just crashes and gives me this crash report:

Код:
SA-MP Server: 0.3b R2

Exception At Address: 0x004862C8

Registers:

EAX: 0x00000000	EBX: 0x0012F634	ECX: 0x004EEE00	EDX: 0xFFFFFFFF
ESI: 0x01024290	EDI: 0x0106F15B	EBP: 0x00000000	ESP: 0x0012F5F8
EFLAGS: 0x00010286

Stack:

+0000: 0x00000004   0x01024290   0xFFFFFFFF   0x0048665B
+0010: 0x0012F634   0x0012F62C   0x0106F15B   0x00000000
+0020: 0xFFFFFFFF   0x00FD5BA8   0x0001040C   0x010125F0
+0030: 0x01008798   0x00000FF7   0x00488044   0x004EEE00
+0040: 0x00000FFF   0x00000000   0x00FD5BA8   0x0102694C
+0050: 0x0012F660   0x00FD5BA8   0x0102694C   0x0048A4F3
+0060: 0x00FD5BA8   0x0102694C   0x00000004   0x0012F67C
+0070: 0x00000000   0x00000000   0x00000100   0x00FD5BA8
+0080: 0x00FD5BA8   0x00000087   0x00401096   0x00FD5BA8
+0090: 0x01026D58   0x01013E5C   0x00402BB3   0x00FD5BA8
+00A0: 0x00000008   0x0012F6B4   0x0102694C   0x00000000
+00B0: 0x00FD5BA8   0x00000000   0x20108201   0x00000001
+00C0: 0x00012AF0   0x00012AF0   0x0001465C   0x0001067C
+00D0: 0x0001336C   0x0001067C   0x01008798   0x01013E5C
+00E0: 0x00000000   0x01007DE8   0x0000B6C4   0x00486CFB
+00F0: 0x00FD5BA8   0x0012F71C   0x00000005   0x00FD5BA8
+0100: 0x00000000   0x00FD5BA8   0x0012F72C   0x0012F720
+0110: 0x01042360   0x010244BC   0x00000000   0x00000000
+0120: 0x01042360   0x00000000   0x010244BC   0x0049C5C5
+0130: 0x00000005   0x00010660   0x0012F868   0x00ADAC90
Here is my ShowStats and I can't find any problems...

pawn Код:
public ShowStats(playerid,targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
        new Float:health;
        new name[MAX_PLAYER_NAME];
        GetPlayerName(targetid, name, sizeof(name));
        GetPlayerHealth(targetid,health);
        new Float:px,Float:py,Float:pz;
        GetPlayerPos(targetid, px, py, pz);
        new coordsstring[256];
       
        new gender[50];
        new age = PlayerInfo[targetid][pAge];
        new origin[50];
        new cash = PlayerInfo[targetid][pCash];
        new job[50];
        new leader = PlayerInfo[targetid][pLeader];
        new member = PlayerInfo[targetid][pMember];
        new rank[50];
        new team[50];
        new number = PlayerInfo[targetid][pNumber];

        if(PlayerInfo[targetid][pGender] == 1) { gender = "Male"; }
        else if(PlayerInfo[targetid][pGender] == 2) { gender = "Female"; }

        if(PlayerInfo[targetid][pOrigin] == 1) { origin = "USA"; }
        else if(PlayerInfo[targetid][pOrigin] == 2) { origin = "Africa"; }
        else if(PlayerInfo[targetid][pOrigin] == 3) { origin = "Europe"; }
        else if(PlayerInfo[targetid][pOrigin] == 4) { origin = "Asia"; }
       
        if(PlayerInfo[targetid][pJob] == 0) { job = "Unoccupied"; }
        else if(PlayerInfo[targetid][pJob] == 1) { job = "Test"; }
       
        if(PlayerInfo[targetid][pTeam] == 1)
        {
            if(PlayerInfo[targetid][pRank] == 1) { rank = "Police Officer I"; }
            else if(PlayerInfo[targetid][pRank] == 2) { rank = "Police Officer II"; }
            else if(PlayerInfo[targetid][pRank] == 3) { rank = "Senior Lead Officer"; }
            else if(PlayerInfo[targetid][pRank] == 4) { rank = "Sergeant"; }
            else if(PlayerInfo[targetid][pRank] == 5) { rank = "Staff Sergeant"; }
            else if(PlayerInfo[targetid][pRank] == 6) { rank = "Lieutenant"; }
            else if(PlayerInfo[targetid][pRank] == 7) { rank = "Captain"; }
            else if(PlayerInfo[targetid][pRank] == 8) { rank = "Commander"; }
            else if(PlayerInfo[targetid][pRank] == 9) { rank = "Assistant Chief"; }
            else if(PlayerInfo[targetid][pRank] == 10) { rank = "Chief of Police"; }
        }
       
        if(PlayerInfo[targetid][pTeam] == 2)
        {
            if(PlayerInfo[targetid][pRank] == 1) { rank = "Deputy Sheriff Generalist"; }
            else if(PlayerInfo[targetid][pRank] == 2) { rank = "Deputy Sheriff I"; }
            else if(PlayerInfo[targetid][pRank] == 3) { rank = "Deputy Sheriff II"; }
            else if(PlayerInfo[targetid][pRank] == 4) { rank = "Corporal"; }
            else if(PlayerInfo[targetid][pRank] == 5) { rank = "Sergeant"; }
            else if(PlayerInfo[targetid][pRank] == 6) { rank = "Lieutenant"; }
            else if(PlayerInfo[targetid][pRank] == 7) { rank = "Captain"; }
            else if(PlayerInfo[targetid][pRank] == 8) { rank = "Assistant Sheriff"; }
            else if(PlayerInfo[targetid][pRank] == 9) { rank = "Undersheriff"; }
            else if(PlayerInfo[targetid][pRank] == 10) { rank = "Sheriff"; }
        }
       
        if(PlayerInfo[targetid][pRank] == 0) { rank = "Civilian"; }
       
        if(PlayerInfo[targetid][pTeam] == 1) { team = "Police Department"; }
        else if(PlayerInfo[targetid][pTeam] == 2) { team = "Sheriff's Department"; }
        else if(PlayerInfo[targetid][pTeam] == 100) { team = "Civilians"; }

        format(coordsstring, sizeof(coordsstring),"------------------------------ %s ------------------------------",name);
        SendClientMessage(playerid, COLOR_GREEN,coordsstring);
        format(coordsstring, sizeof(coordsstring), "Name: [%s] Gender: [%s] Origin: [%s] Age: [%d]", name, gender, origin, age);
        SendClientMessage(playerid, COLOR_FADE1,coordsstring);
        format(coordsstring, sizeof(coordsstring), "Faction: [%s] Rank: [%s] Job: [%s] Number: [%d]", team, rank, job, number);
        SendClientMessage(playerid, COLOR_FADE2,coordsstring);
        format(coordsstring, sizeof(coordsstring), "Radio: [%s] Phone: [%s] Melee: [%s]");
        SendClientMessage(playerid, COLOR_FADE3,coordsstring);
        format(coordsstring, sizeof(coordsstring), "Player Level: [%d] Playing Hours: [%d] Donator Rank: [%s]");
        SendClientMessage(playerid, COLOR_FADE4,coordsstring);
        format(coordsstring, sizeof(coordsstring), "Cash: [$%d] Bank: [$%d] Savings: [$%d] PayCheck: [$%d]", cash);
        SendClientMessage(playerid, COLOR_FADE5,coordsstring);
    }
}
Thanks for checking this!
Reply
#2

pawn Код:
format(coordsstring, sizeof(coordsstring),"------------------------------ %s ------------------------------",name);
SendClientMessage(playerid, COLOR_GREEN,coordsstring);
format(coordsstring, sizeof(coordsstring), "Name: [%s] Gender: [%s] Origin: [%s] Age: [%d]", name, gender, origin, age);
SendClientMessage(playerid, COLOR_FADE1,coordsstring);
format(coordsstring, sizeof(coordsstring), "Faction: [%s] Rank: [%s] Job: [%s] Number: [%d]", team, rank, job, number);
SendClientMessage(playerid, COLOR_FADE2,coordsstring);
format(coordsstring, sizeof(coordsstring), "Radio: [%s] Phone: [%s] Melee: [%s]");//You have here a format without arguments..
SendClientMessage(playerid, COLOR_FADE3,coordsstring);
format(coordsstring, sizeof(coordsstring), "Player Level: [%d] Playing Hours: [%d] Donator Rank: [%s]");//You have here a format without arguments..
SendClientMessage(playerid, COLOR_FADE4,coordsstring);
format(coordsstring, sizeof(coordsstring), "Cash: [$%d] Bank: [$%d] Savings: [$%d] PayCheck: [$%d]", cash);//You have here a format with missing arguments..
SendClientMessage(playerid, COLOR_FADE5,coordsstring);
Reply
#3

First of all, I recomment to dont use 'string = "STRING" , but use 'strins'
Or, use the function I made:

pawn Код:
stock strset(astr[], astrtoinsert[])
{
    strdel(astr, 0, strlen(astr));
    strmid(astr, astrtoinsert, 0, false, strlen(astrtoinsert));
}
So instead of 'rank = "Captain"' it is 'strset(rank, "Captain")' -> I read somewhere that that was better :P
And after that, idk yet what's wrong. Unless this line:
pawn Код:
format(coordsstring, sizeof(coordsstring), "Radio: [%s] Phone: [%s] Melee: [%s]");
You forgot to give the strings. But I don't think the server is going to crash because of that?
I don't have that...
I'll take a a look

[EDIT]
Omg while I was typing this message someone already replied...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)