[HELP] Ask && Report
#1

What am i doing wrong? It crashes my sevrer :S

pawn Код:
dcmd_report(playerid, params[])
{
    new targetid, reason;

    if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_USAGE, "bla bla");
    else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "bla bla");
    //else if(playerid == targetid) return SendClientMessage(playerid, COLOR_ERROR, "bla bla");
    {
        new playername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], string[256];
        GetPlayerName(playerid, playername, sizeof(playername));
        GetPlayerName(targetid, targetname, sizeof(targetname));
       
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i) && IsPlayerAdmin(i))
            {
                SendClientMessage(playerid, COLOR_ADMIN, "bla bla");
               
                format(string, sizeof(string), "bla bla",playername, playerid, targetname, targetid, reason);
                SendClientMessageToAll(0xFF0000FF, string);
                return 1;
            }
        }
        return 1;
    }
   
}
pawn Код:
dcmd_ask(playerid, params[])
{
    new question;
    if(sscanf(params, "z", question)) return SendClientMessage(playerid, COLOR_USAGE, "bla bla");
    {
        new playername[MAX_PLAYER_NAME], string[256];
        GetPlayerName(playerid, playername, sizeof(playername));

        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i) && IsPlayerAdmin(i))
            {
                SendClientMessage(playerid, COLOR_ADMIN, "bla bla");
               
                format(string, sizeof(string), "bla bla",playername, playerid, question);
                SendClientMessage(i, COLOR_ADMIN, string);
                return 1;
            }
        }
        return 1;
    }
}
Reply
#2

During the 'for' function, you're not supposed to return anything.
Reply
#3

Quote:
Originally Posted by Leon_Rahil!
Посмотреть сообщение
During the 'for' function, you're not supposed to return anything.
I really know that xD, but i have tried EVERYTHING, when it dont crash then ill get:
"Report Sent"
"SERVER: Unknown Command"
Reply
#4

Have you actually replaced your messages with "bla bla," if so then you should let us see the original code as you could have messed up within your format(). The other messages don't particularly matter, but just in-case you've tried to add an %/placeholder where they shouldn't be...

For the love of god, you don't need 256-cell strings.

and

pawn Код:
new question;
    if(sscanf(params, "z", question))
is probably the source of your crash, change your code to:

pawn Код:
new question[128];
    if(sscanf(params, "z", question)) // question needs to be a string, not an integer
and for your other command...

pawn Код:
dcmd_report(playerid, params[])
{
    new targetid, reason;

    if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_USAGE, "bla bla");
Fix for it...

pawn Код:
dcmd_report(playerid, params[])
{
    new targetid, reason[128];

    if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_USAGE, "bla bla");
Reply
#5

Thanks

i got an question about the "[128]" thingy
Why [128] not [264] or [WhatEver]?
Reply
#6

Quote:
Originally Posted by Larsey123IsMe
Посмотреть сообщение
Thanks

i got an question about the "[128]" thingy
Why [128] not [264] or [WhatEver]?
Because 128 is the maximum string size that you can send to chat per line, use of 256 would have been excessive. You shouldn't ever use 256-cell strings for chat if you're only ever sending one line of chat.
Reply
#7

Because messages are limited to 128. 256 is double that limit when you don't need it. It's inefficient and a waste.
Reply
#8

Thanks to you both
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)