do I have to use dcmd && sscanf?
#10

Quote:
Originally Posted by [WF]Demon
Посмотреть сообщение
Well i never got strtok not sure how anyone ever did, sscanf and zcmd is shorter (Not ZCMD its about the same size as strcmp) but sscanf is indeed shorter and easier, i dont care if its faster or more efficient i say simpler is better, you can argue with me all day for saying this i will not reply back, but yes i do recommend using sscanf and zcmd, ill show you why

STRCMP And STRTOK PM:

pawn Код:
if(strcmp("/pm", cmd, true) == 0)
    {
        tmp = strtok(cmdtext,idx);
       
        if(!strlen(tmp) || strlen(tmp) > 5) {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
            return 1;
        }
       
        new id = strval(tmp);
    gMessage = strrest(cmdtext,idx);
   
        if(!strlen(gMessage)) {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
            return 1;
        }
       
        if(!IsPlayerConnected(id)) {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Bad player ID");
            return 1;
        }
       
        if(playerid != id) {
            GetPlayerName(id,iName,sizeof(iName));
            GetPlayerName(playerid,pName,sizeof(pName));
            format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
            SendClientMessage(playerid,PM_OUTGOING_COLOR,Message);
            format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
            SendClientMessage(id,PM_INCOMING_COLOR,Message);
            PlayerPlaySound(id,1085,0.0,0.0,0.0);
           
            printf("PM: %s",Message);
           
        }
        else {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"You cannot PM yourself");
        }
        return 1;
    }
long ass command right?

ZCMD And SSCANF PM

pawn Код:
COMMAND:pm(playerid, params[])
{
        new otherid, message[100], pname[24], string[128];
        if(sscanf(params, "is", otherid, message)) return SendClientMessage(playerid, 0xFFFFFFFF, "Command Syntax: /pm [ID] [Message]");
        if(!IsPlayerConnected(otherid)) return SendClientMessage(playerid, 0xFFFFFFFF, "That Player Is Not Connected");
        GetPlayerName(playerid, pname, sizeof(pname));
        format(string, sizeof(string), "PM From %s : %s", pname, message);
        SendClientMessage(otherid, 0xFFFFFFFF, string);
        return 1;
}
I made that last PM in 3 minutes or less, see what i mean?

i just recommend ZCMD and SSCANF, i will not reply unless the topic starter is replying to me.
That's b*llshit, you didn't put half of the code in ZCMD one, like IsPlayerConnected, yes I go for ZCMD, it's faster and shorter, but these are 2 diffrent commands!

You should use ZCMD and SSCANF, it's much faster than STRTOK and STRCMP.
Reply


Messages In This Thread
do I have to use dcmd && sscanf? - by bijoyekuza - 28.02.2011, 18:40
AW: do I have to use dcmd && sscanf? - by dUDALUS - 28.02.2011, 19:29
Re: do I have to use dcmd && sscanf? - by bijoyekuza - 28.02.2011, 19:37
Re: do I have to use dcmd && sscanf? - by dice7 - 28.02.2011, 19:38
Re: do I have to use dcmd && sscanf? - by Mean - 28.02.2011, 19:59
Re: do I have to use dcmd && sscanf? - by admantis - 28.02.2011, 20:15
Re: do I have to use dcmd && sscanf? - by dice7 - 28.02.2011, 20:30
Re: do I have to use dcmd && sscanf? - by [WF]Demon - 28.02.2011, 21:22
Re: do I have to use dcmd && sscanf? - by bijoyekuza - 01.03.2011, 04:36
Re: do I have to use dcmd && sscanf? - by Mean - 01.03.2011, 09:13

Forum Jump:


Users browsing this thread: 2 Guest(s)