Brasil SA-MP

Bem-vindo !
Então, por que você não é um membro? Junte-se agora! Esta mensagem aparecere apenas para convidados, será removida juntamente com os anúncios se logar-se.

Você não está conectado. Conecte-se ou registre-se

Using DCMD properly

Ver o tópico anterior Ver o tópico seguinte Ir para baixo Mensagem [Página 1 de 1]

#1
krueger..

krueger..


First,define dcmd right down your includes:
Código:

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
Now,go to your OnPlayerCommandText callback and include an command:
Código:

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(talk,4,cmdtext); // Command text, letters of the text, variable to compare
    return 0; // Return 0 every time you close your command callback.
}
Now,you know that,talk have 4 letters,on the second parameter,you give the function the right number of letters that your command have,in my case,four letters.

Ok,so we define a new command,but how we will use it,if OnPlayerCommandText is closed ?

Simple,you can put you dcmd command anywhere !Take a look:
Código:

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(talk,4,cmdtext); // Command text, letters of the text, variable to compare
    return 0; // Return 0 every time you close your command callback.
}

public OnPlayerDeath(playerid, killerid, reason)
{
    GameTextForPlayer(playerid, "busted",3000,6);
    //just an example
    return 1;
}

dcmd_talk(playerid, params[]) //our command,yay :D
{
    if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000FF, "|ERROR|:Don't be shy,say something!");
    ext[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(text, sizeof(text), "{808080}%s say: {700000}%s", pName, params);
    SendClientMessageToAll(-1, text);
    return 1;
}
See ?Awesome isn't ?
The only difference between ZCMD and DCMD,is that you have to set the dcmd command on the OnPlayerCommandText,and ZCMD no.

Perhaps two differences,'cuz if you don't use the "params",the compiler will give you an error,to get rid of that error,simply put this on the start of your command.
Código:

#pragma unused params
I use dcmd,for me,its the same crap that zcmd,whatever,using dcmd instead of zcmd don't change much things.

#2
N1ceWalkMan

N1ceWalkMan


very good,interesting

http://squadelite.forumclan.com

#3
Luan_Argolo

Luan_Argolo


Good job.

#4
krueger..

krueger..


Thanks guys !
Is not that hard at all..it's hard for people who didn't try to understand everything.

#5
Anonimo

Anonimo


Good Job.

NOTA: 10

http://strategypoint.com.br/

#6
Conteúdo patrocinado



Ver o tópico anterior Ver o tópico seguinte Ir para o topo Mensagem [Página 1 de 1]


Permissões neste sub-fórum
Não podes responder a tópicos