Randomize a word from a list
#1

Hello everybody, today I want to make something releated to my car system (again) and the mode you steal one.

Shortly, I want to take a word from a list and randomize it. Example: The word "kitchen" gets selected and the script may transform it in "nehcikt" or something.

The code I use for my list:

pawn Код:
new RandomNames[][4] =
{
    "couch",
    "ignition",
    "kitchen"
};
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=535186
Reply
#3

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
I already tried that method but I have some errors when I try to use it with a command or anything.
Reply
#4

Can be closed. Solved other way.
Reply
#5

Quote:
Originally Posted by AidanRO
Посмотреть сообщение
Can be closed. Solved other way.
You should have posted the function. Anyway, here:
pawn Код:
// ** INCLUDES

#include <a_samp>

// ** DEFINES

// *** FUNCTIONS

#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)

// ** MAIN

main()
{
    print("Loaded \"mix_up_characters_in_string.amx\".");

    printf("%s", MixUpCharactersInString("testing"));
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

// ** FUNCTIONS

stock MixUpCharactersInString(string[])
{
    new new_string[128], temp[2];
    strcpy(new_string, string, 128);

    for(new i = 0, j = strlen(string); i < j; i ++)
    {
        temp[0] = string[i];
        temp[1] = random(j);

        new_string[i] = string[temp[1]];
        new_string[temp[1]] = temp[0];
    }
    return new_string;
}
Outputs:
Код:
nginste
eggnsts
tninngn
niggens,
etc.
P.S. The 4th output, though! If the 6th character was an "r", it would say "niggers". Hahahaha! PAWN is such a racist!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)