save text under several conditions
#1

Hello! I have a problem:


I want registered 6 names with 60 characters but I also like that those registrations will not be the same: I thought to do a loop.

How do I is not got a clue how to take,
if you could help me with the code?

Thank you for any help!

Vince
Reply
#2

What do you want? Save 6 names to a file or a variable?
Reply
#3

Variable !
Reply
#4

Yes you need a loop, just check in it if the name already got added
If it doesnt add the new name to a free space, done

The code below is just an example

pawn Код:
stock AddToData(data[][], input[], i = sizeof data, const size = sizeof data[])
{
    if(!input[0]) return 0; //checks if the input is emtpy
    new free = -1; //declares free as -1
    while((--i) != -1) //A while loop
        if(!data[i][0]) free = i; //Checks if the data space is emtpy - necessary because of strcmp
        else if(!strcmp(input, data[i], true)) return 0; //Checks if the name is the same
    if(free == -1) return -1; //returns -1 if no free space was found
    strcat(data[free], input, size); //insert the input in the free data space
    return 1; //returns 1 for success
}
Reply
#5

thanks !
Reply
#6

is that you can show me an example of use?

Thanks !
Reply
#7

Quote:
Originally Posted by vardanega
Посмотреть сообщение
is that you can show me an example of use?

Thanks !
Just AddToData(YOUR_VARIABLE_WHICH_IS_6*60, THE_NAME_TO_ADD);

But its just an example if it doesnt work I dont care
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)