26.08.2009, 12:44
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;
}
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