Joke command
#1

I've been thinking, can I make a joke command?

if(strcmp(cmdtext, "/tellmeajoke", true) == 0)

and then it will show a random joke

I've been trying to put it together but still my skills are too low to get it to work

Can someone show me what I do this?
Reply
#2

bottom of your script:
pawn Код:
#define COLOR_BLUE 0xFF0000AA

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/tellmeajoke", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid, COLOR_BLUE, "Here the joke");
        return 1;
    }
    return 0;
}
Reply
#3

Havent tried it, but thank u very much for a quick reply!
Reply
#4

pawn Код:
warning 225: unreachable code
Reply
#5

pawn Код:
if (strcmp("/tellmeajoke", cmdtext, true, 10) == 0)
    {
    new joke = random(number of jokes);
    switch(joke)
   {
case 0: SendClientMessage(playerid, COLOR_BLUE, "Here the joke");
Etc ...  
}
    return 1;
    }
Reply
#6

You're welcome, let me know if it doesnt work!
Reply
#7

So for many random jokes:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/tellmeajoke", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid, COLOR_RED, "OLOLOLOL");
    SendClientMessage(playerid, COLOR_RED, "OLOLOLOL");
    SendClientMessage(playerid, COLOR_RED, "OLOLOLOL");
        return 1;
    }
    return 0;
}
??
Reply
#8

Ehm... Don't copy the whole public, copy the command in it and put it in OnPlayerCommandText.

Also that won't show a random joke, this will:
pawn Код:
if( !strcmp( cmdtext, "/tellmeajoke", true ) ) {
    new joke = random( 5 ); // 5 random jokes.
    switch( joke ) {
        case 0: SendClientMessage( playerid, -1, "Random joke number 1. " );
        case 1: SendClientMessage( playerid, -1, "Random joke number 2. " );
        case 2: SendClientMessage( playerid, -1, "Random joke number 3. " );
        case 3: SendClientMessage( playerid, -1, "Random joke number 4. " );
        case 4: SendClientMessage( playerid, -1, "Random joke number 5. " );
    }
    return 1;
}
EDIT: No! For more jokes add more case statements, as I wrote!
Reply
#9

Quote:
Originally Posted by geerdinho8
Посмотреть сообщение
bottom of your script:
pawn Код:
#define COLOR_BLUE 0xFF0000AA

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/tellmeajoke", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid, COLOR_BLUE, "Here the joke");
        return 1;
    }
    return 0;
}
wtf is this guy asked for random joke, and wtf is with strcmp("/tellmeajoke", cmdtext, true, 10), you can do

cmd = strtok(cmdtext, idx); and then strcmp(cmd, "/telljoke", true)
Reply
#10

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
wtf is this guy asked for random joke, and wtf is with strcmp("/tellmeajoke", cmdtext, true, 10), you can do

cmd = strtok(cmdtext, idx); and then strcmp(cmd, "/telljoke", true)
Read the scripting basics before posting PLEASE, and don't post crap like this. Strtok is for Multi-Parameter commands... If you don't know what are you talking about, don't post, if you didn't notice, this command doesn't use strtok at all...

The guy asked for a command that shows him a random joke.

About unreachable code warning, post the code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)