How do read stuff from a specific file? (AddPlayerClass.)
#1

I'm looking to add all of the sa-mp's skins to the class selection, but I don't want to add 299 of them to my main game mode. How can I add them to a file, and have it read it from the file upon game initiation?

Help is appreciated, thank you.
Reply
#2

pawn Код:
public OnGameModeInit()
{
    for(new s = 0; s < 300; s++)
    {
        if(IsInvalidSkin(s)) continue;
        else AddPlayerClass(s, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    }
    return 1;
}

stock IsInvalidSkin(skinid)
{
    #define MAX_BAD_SKINS  14
    if(skinid > 310) return true;
    new badSkins[MAX_BAD_SKINS] = {
        3, 4, 5, 6, 8, 42, 65, 74, 86,
        119, 149, 208, 273, 289
    };
    for (new i = 0; i < MAX_BAD_SKINS; i++)
    {
      if (skinid == badSkins[i]) return true;
    }
    return false;
}
Is this what you are after?
Reply
#3

Quote:
Originally Posted by V1ceC1ty
Посмотреть сообщение
pawn Код:
stock IsInvalidSkin(skinid)
Just so you know, the only invalid skin at the moment is skin 74. The rest is usable.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Just so you know, the only invalid skin at the moment is skin 74. The rest is usable.
Yes but he asked "I don't want to add 299 of them to my main game mode." so from an old code he can easily figure out how to add/remove skins he does and doesn't want to use.
Reply
#5

Not quit sure how to read that code. Could you cut it down for me, so I understand for future reference please?

Thank you.
Reply
#6

Oh well, you could just add a line or two on OnGameModeInit and create a variable which will store the 'bad' skin IDs.. and that would be alot more efficent and easy.

But you could use a INI include ( such as Y INI and Dini ) and store them into a file.
I'd use the first option if you'd ask me.
Reply
#7

pawn Код:
public OnGameModeInit()
{
    for(new s = 1; s < 300; s++) // run a loop that starts with ID 1, and ends in ID 299
    {
        if(s == 74) continue; // skin ID 74 is invalid, so when the loop hits that ID, skip it
        else AddPlayerClass(s, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); // the skin ID isn't 74, add the "class"
    }
    return 1;
}
Reply
#8

Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)