16.05.2013, 16:40
Well, yesterday I was scripting a command which when sometimes a player type /attempt it'll appear success and sometimes it'll appear fails, but I've faced a problem it only says 'Failed' I've set the random between 0 and 1 if its 1 = success 0 = fail, but as I said it only appear 'failed' can anyone help me with this? or tell me the right function?
Thank you very much!
Код:
if(strcmp(cmd, "/attempt", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "[INFO]:You havent logged in yet !");
return 1;
}
GetPlayerNameEx(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[96];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /attempt [action]");
return 1;
}
if(PlayerInfo[playerid][pMask] == 1)
{
new rn = random(1);
if (rn == 0) // failed
{
format(string, sizeof(string), "* Stranger tried to %s and failed.", result);
}
else // succeded
{
format(string, sizeof(string), "* Stranger tried to %s and succeeded.", result);
}
}
else
{
new rn = random(1);
if (rn == 0) // failed
{
format(string, sizeof(string), "* %s tried to %s and failed.", sendername, result);
}
else // succeded
{
format(string, sizeof(string), "* %s tried to %s and succeeded.", sendername, result);
}
}
ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
}
return 1;
}

