SA-MP Forums Archive
Minor problem - 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: Minor problem (/showthread.php?tid=134794)



Minor problem - Desert - 17.03.2010

Hey i made an ooc command which looks like this

pawn Code:
dcmd_ooc(playerid,params[])
{
    new text,name[MAX_PLAYER_NAME],string[128];
    if(sscanf(params,"s",text)) SendClientMessage(playerid,COLOUR_RED,"Usage: /ooc message");
    else
    {
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"OOC %s: %s",name,text);
        SendClientMessageToAll(COLOUR_WHITE,string);
        }
    return 1;
}
Which works fine exept it sends the text plus an "SERVER: Unknown command" no matter where i put the return 1; Any ideas?


Re: Minor problem - Correlli - 17.03.2010

You should return the message ( return SendClientMessage(...); ).


Re: Minor problem - Desert - 17.03.2010

Had no effect.

Even tried return both messages


Re: Minor problem - PowerSurge - 17.03.2010

pawn Code:
dcmd_ooc(playerid, params[])
    {
    new sendername[32];
    new idx;
    new string[128];

    GetPlayerName(playerid, sendername, sizeof(sendername));
    new length = strlen(params);
    while ((idx < length) && (params[idx] <= ' '))
    {
    idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
    result[idx - offset] = params[idx];
    idx++;
    }
    result[idx - offset] = EOS;
    if(!strlen(result))
    {
    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
    return 1;
    }
    format(string, sizeof(string), "OOC [%d]%s: %s", playerid, sendername, result);
    SendClientMessageToAll(COLOR_WHITE,string);
    printf("%s", string);
    return 1;
    }



Re: Minor problem - Desert - 17.03.2010

Thanks worked