A multi-command.
#1

How can I make a command like this:

pawn Код:
COMMAND:search(playerid, params[])
{
         SendClientMessage(playerid, 0xFFFFFFFF, "%s starts to look through the box.", GetPlayerName(playerid);
}
Like that, but with like, 6 different things that the player can get from fishing? :3.
Reply
#2

What do you mean by multi-command? Like 3 commands with the same code script or?
If so then try strcmp and use OR operator ( || ):


pawn Код:
//under OnPlayerCommand
new cmd[256], idx;
cmd = strtok(cmdtext, idx);


if(strcmp(cmd, "/command1", true) == 0 || strcmp(cmd, "/command2", true) == 0 || strcmp(cmd, "/command3", true) == 0)
{
    //Codes here
}
Reply
#3

I mean like,

/search

then it will give a random thing, from a choice..
Reply
#4

Can you perhaps give an example of something so we all can understand you better, and now I have to guess what your meaning :S.
Please give examples of what you want..
Reply
#5

Like a /fish command.. you get like, 6 different fish, but it gives you one of the fish, at random? :S
Reply
#6

U mean, you want like 5 commands do the same thing using ZCMD? If so:
pawn Код:
COMMAND:search(playerid, cmdtext[])
{
    SendClientMessage(playerid, 0xFFFFFFFF, "%s starts to look through the box.", GetPlayerName(playerid);
}

COMMAND:iwilldothesameassearch(playerid, cmdtext[])
{
    return cmd_search(playerid, cmdtext[]);
}
Reply
#7

Quote:
Originally Posted by getty154
Посмотреть сообщение
Like a /fish command.. you get like, 6 different fish, but it gives you one of the fish, at random? :S
See now I understand what you want, and now I can help you find a solution faster which spends both of us a lot of time .

Perhaps try to experience with this.

pawn Код:
//Somewhere at the beginning of your pawno script.
forward SendRandomMsgToAll();


//I got this BEHIND    "public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])"
public SendRandomMsgToAll()
{
    switch(random(4))   //4 is the number of how many random case's it can choose.
    {
        case 0: SendClientMessageToAll(COLOR_WHITE, "Hey YOU, Stop camping!! really not cool.");
        case 1: SendClientMessageToAll(COLOR_WHITE, "Your hiding like a pussy, stand up and fight like a men should do!");
        case 2: SendClientMessageToAll(COLOR_WHITE, "If you get caught on cheating you will most probably be banned, so do it unnoticed.");
        case 3: SendClientMessageToAll(COLOR_WHITE, "Server closed the connection.");
        //You can add more case's here but remember to change the switch(random(4)) number.
    }
}


//And by calling the public use somewhere between a command or create a timer for it etc.
SendRandomMsgToAll();
Hope this helps .
Rolyy
Reply
#8

facepalm..

pawn Код:
CMD:search(playerid, params[])
{
    SendClientMessage(playerid, 0xFFFFFFFF, "%s starts to look through the box.", GetPlayerName(playerid);
    switch((random(6))
    {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 6:
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Donya
Посмотреть сообщение
pawn Код:
case 3:
case 4:
case 6:
/facepalm

"case 6:" must be "Case 5:".
Lolz



pawn Код:
CMD:search(playerid, params[])
{
    switch((random(6))
    {
        case 0: SendClientMessage(playerid, 0xFFFFFFFF, "message 1");
        case 1: SendClientMessage(playerid, 0xFFFFFFFF, "message 2");
        case 2: SendClientMessage(playerid, 0xFFFFFFFF, "message 3");
        case 3: SendClientMessage(playerid, 0xFFFFFFFF, "message 4");
        case 4: SendClientMessage(playerid, 0xFFFFFFFF, "message 5");
        case 5: SendClientMessage(playerid, 0xFFFFFFFF, "message 6");
    }
    return 1;
}
Reply
#10

basically a little mistype... you guys went way off <.<
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)