SA-MP Forums Archive
/n chat crash server wtf ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /n chat crash server wtf ? (/showthread.php?tid=247861)



[HELP]Newbie chat - NotoriousMOB - 11.04.2011

Solved.


Re: /n chat crash server wtf ? - NotoriousMOB - 11.04.2011

Bump sorry but instead of making a new post i just edited this.


Re: /n chat crash server wtf ? - Retardedwolf - 11.04.2011

Try debugging.


Re: /n chat crash server wtf ? - Skylar Paul - 11.04.2011

pawn Код:
if(strcmp(cmd, "/newbie", true) == 0 || strcmp(cmd, "/n", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
                return 1;
            }
            if(nonewbie == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "Newbie chat is off.");
                return 1;
            }
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/n)ewbie [newbie chat]");
                return 1;
            }
            new
                sendername[MAX_PLAYER_NAME]
            ;
            GetPlayerName(playerid, sendername, sizeof(sendername));
             if(PlayerInfo[playerid][pHelper] < 1) format(string, sizeof(string), "** Helper %s: %s", sendername, result);
               else if(PlayerInfo[playerid][pHelper] < 2) format(string, sizeof(string), "** Master %s: %s", sendername, result);
               else if(PlayerInfo[playerid][pHelper] < 3) format(string, sizeof(string), "** VIP %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pAdmin] < 4242) format(string, sizeof(string), "** Admin %s: %s", sendername, result);
            else format(string, sizeof(string), "** Newbie %s: %s", sendername, result);
            SendClientMessageToAll(0x9ACD32AA, string);
            printf("%s", string);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
            format(string, sizeof(string), "[%d/%d/%d](%d:%d:%d) %s (newbie): (%s)",d,m,y,h,mi,s, sendername, result);
        }
        return 1;
    }
You forgot to create the variable "sendername" and store the player's name in it.


Re: /n chat crash server wtf ? - NotoriousMOB - 11.04.2011

Thanks for taking time.
Gettin this.
pawn Код:
(21679) : warning 219: local variable "sendername" shadows a variable at a preceding level



Re: /n chat crash server wtf ? - Skylar Paul - 11.04.2011

Quote:
Originally Posted by NotoriousMOB
Посмотреть сообщение
Thanks for taking time.
Gettin this.
pawn Код:
(21679) : warning 219: local variable "sendername" shadows a variable at a preceding level
Righto.

Remove this:

pawn Код:
new
                sendername[MAX_PLAYER_NAME]
            ;



Re: /n chat crash server wtf ? - NotoriousMOB - 11.04.2011

Oh that helped, thanks for taking time!