[Ajuda] Texto random com variбvel.
#1

Olб.

Como gerar um texto randomico e adcionar uma variбvel para cada ?

Exemplo, no random, gera o texto ' Gold ', ai seto a variбvel ' IsPlayerInGold[playerid] = true; ' ?

pawn Код:
forward MN(playerid);
public MN(playerid)
{
    new MR[5][128] =
    {
        "Ouro",
        "Diamante",
        "Ferro",
        "Chumbo",
        "Cobre"
    };

    new ss[60];
    new sc = randomEx(true, false);

    Bit1_Set(Capturou, playerid, sc);

    if(Capturou[playerid])
    {
        format(ss, 60, "- Vocк encontrou um %s, vб atй a бrea de vendas.", MR[random(sizeof(MR))]);
        SendClientMessage(playerid, CINFO, ss);
        SetPlayerCheckpoint(playerid, -1694.7881,1330.3480,7.1814, 1.0);
        return 1;
    }
    else
    {
        format(ss, 60, "- Vocк nгo encontrou nenhum minйrio, tente novamente.");
        SendClientMessage(playerid, CINFO, ss);
    }
    return 1;
}
Reply
#2

Bem, hб a funзгo strcmp :


pawn Код:
new bool:Sultan;
new bool:Turismo;
new bool:Infernus;
new Veiculos[][] =
{
    "Sultan",
    "Turismo",
    "Infernus"
};
new TextoRandom[9];
strcat(TextoRandom, Veiculos[random(sizeof(Veiculos))]);
if(!strcmp(TextoRandom, "Sultan"))
{
    Sultan = true;
}
else if(!strcmp(TextoRandom, "Turismo"))
{
    Turismo = true;
}
else if(!strcmp(TextoRandom, "Infernus"))
{
    Infernus = true;
}


Espero ter ajudado .
Reply
#3

Obrigado Rjjj.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)