Quick STRCMP to DCMD Tutorial please
#1

Can someone please give me some Turorials on DCMD or show me what is changed from the STRCMP code to the DCMD code,Ill a example with STRCMP if someone could kindly convert and deaply explain how its diffrent to me plz

And are the fuctions the same just the codeing?

eg. My command codes start from this base..

Код:
        if (strcmp("/command", cmdtext, true) == 0)
        {
        //functions
        return 1;
        }
Thanks in advanced
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
        dcmd(examplecmd,11,cmdtext); //command, length of command, then the command text itself..
        return 0;
}

dcmd_examplecmd(playerid,params[])
    #pragma unused params
    {
        SendClientMessage(playerid,BLUE,"IT WORKS!");
    return 1;
}
you use
pawn Код:
#pragma unused params
if you dont have any params

Reply
#3

#pragma unused params needs to be inside the brackets.
Reply
#4

Quote:
Originally Posted by Seven.
Посмотреть сообщение
#pragma unused params needs to be inside the brackets.
#pragma/param?

Please give me examples...Make a /heal and a /help plz
Reply
#5

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
        dcmd(heal,4,cmdtext); // heal has 4 letters so you enter a 4
        dcmd(help,4,cmdtext); // same here..
        return 0;
}
pawn Код:
dcmd_heal(playerid,params[])
{
#pragma unused params
SetPlayerHealth(playerid,100);
return true;
}
pawn Код:
dcmd_help(playerid,params[])
{
#pragma unused params
SendClientMessage(playerid,color,"Help message?");
return true;
}
Reply
#6

Quote:
Originally Posted by Seven.
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
        dcmd(heal,4,cmdtext); // heal has 4 letters so you enter a 4
        dcmd(help,4,cmdtext); // same here..
        return 0;
}
pawn Код:
dcmd_heal(playerid,params[])
{
#pragma unused params
SetPlayerHealth(playerid,100);
return true;
}
pawn Код:
dcmd_help(playerid,params[])
{
#pragma unused params
SendClientMessage(playerid,color,"Help message?");
return true;
}
So this dcmd(heal,4,cmdtext);

is like this new cmd[256]; ?

And wow how easy is DCMD :O i now see how its processed faster and it acually looks easier to type xD

BTW no includes or special functions?? And callbacks stay the same?

Kool thanks dude ima start scripting in DCMD now


EDIT: this #pragma unused params is needed for every single command?
Reply
#7

Quote:
Originally Posted by Seven.
Посмотреть сообщение
#pragma unused params needs to be inside the brackets.
no it doesnt....
Reply
#8

Can someone teach me? So what exactly this #pragma unused params do?And also explain me about return true; for what is it used?
Reply
#9

Quote:
Originally Posted by karakana7
Посмотреть сообщение
Can someone teach me? So what exactly this #pragma unused params do?And also explain me about return true; for what is it used?
If you don't use the parameters, DCMD will complain about that params is unused. #pragma unused params will fix this.
Reply
#10

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
If you don't use the parameters, DCMD will complain about that params is unused. #pragma unused params will fix this.
Thank you for the helping.What parameters you can use for dcmd,zcmd?And also one last thing about that is what doing the return true; code?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)