/try command help
#2

pawn Код:
if (strcmp(cmd, "/try", true)==0)
        {
        new plyName[MAX_PLAYER_NAME];
        new buffer[128];
        new rand = random(2);
        new message[256];
        tmp = strtok(cmdtext, idx);
        new option[128];
        option = strtok(cmdtext, idx);
        if(!strlen(option))
        {
            SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "USA: /try [accion]");
            return 1;
        }
        GetPlayerName(playerid, plyName, sizeof(plyName));
        if(strcmp(option,"smoke",true) == 0)
            {
          if(rand == 2)
            {
                format(buffer, sizeof(buffer), "* %s intenta %s y lo consigue", plyName, message);
       }
            else
            {
            format(buffer, sizeof(buffer), "* %s intenta %s pero falla", plyName, message);
            }
          SendClientMessage(playerid, 0x00FFFF, buffer);
                }
            }
    return 1;
}
Try that, took me a while you had a lot of errors, by default you can use the variable playerid which is the ID that is executing the command, then use the GETPLAYERNAME command to get the players name for the string, go read on the wiki for more info.
Note:Not tested, might not work 100%, if it doesn't work tell me.

What I changed: I changed your random count from 20 to 2, since it has the same effect, just uses less memory,
added GetPlayerName.
You need STRTOK to use this.

I recommend you look through this:
https://sampwiki.blast.hk/wiki/GetPlayerName


- Paladin
Reply


Messages In This Thread
/try command help - by pablodc - 26.08.2009, 12:05
Re: /try command help - by Paladin - 26.08.2009, 12:44
Re: /try command help - by pablodc - 26.08.2009, 13:12
Re: /try command help - by Paladin - 26.08.2009, 13:17
Re: /try command help - by MenaceX^ - 26.08.2009, 13:20
Re: /try command help - by pablodc - 26.08.2009, 13:29
Re: /try command help - by MenaceX^ - 26.08.2009, 13:29
Re: /try command help - by pablodc - 26.08.2009, 13:30
Re: /try command help - by MenaceX^ - 26.08.2009, 13:35
Re: /try command help - by pablodc - 26.08.2009, 13:43

Forum Jump:


Users browsing this thread: 1 Guest(s)