How do read stuff from a specific file? (AddPlayerClass.) -
rangerxxll - 21.03.2013
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.
Re: How do read stuff from a specific file? (AddPlayerClass.) -
V1ceC1ty - 21.03.2013
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?
Re: How do read stuff from a specific file? (AddPlayerClass.) -
Vince - 21.03.2013
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.
Re: How do read stuff from a specific file? (AddPlayerClass.) -
V1ceC1ty - 21.03.2013
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.
Re: How do read stuff from a specific file? (AddPlayerClass.) -
rangerxxll - 21.03.2013
Not quit sure how to read that code. Could you cut it down for me, so I understand for future reference please?
Thank you.
Re: How do read stuff from a specific file? (AddPlayerClass.) -
Denying - 21.03.2013
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.
Re: How do read stuff from a specific file? (AddPlayerClass.) -
Scenario - 21.03.2013
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;
}
Re: How do read stuff from a specific file? (AddPlayerClass.) -
rangerxxll - 21.03.2013
Thank you.