SA-MP Forums Archive
Joke command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Joke command (/showthread.php?tid=259664)



Joke command - ColdIce - 05.06.2011

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?


Re: Joke command - geerdinho8 - 05.06.2011

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;
}



Re: Joke command - ColdIce - 05.06.2011

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


Re: Joke command - ColdIce - 05.06.2011

pawn Код:
warning 225: unreachable code



Re: Joke command - sleepysnowflake - 05.06.2011

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;
    }



Re: Joke command - geerdinho8 - 05.06.2011

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


Re: Joke command - ColdIce - 05.06.2011

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;
}
??


Re: Joke command - Mean - 05.06.2011

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!


Re: Joke command - CoaPsyFactor - 05.06.2011

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)


Re: Joke command - Mean - 05.06.2011

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.