client crashes when invalid /skin is chosen. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: client crashes when invalid /skin is chosen. (
/showthread.php?tid=143731)
client crashes when invalid /skin is chosen. -
[LF]Mr.Lucci - 24.04.2010
Код:
if(strcmp(cmd, "/clothes", true) == 0) {
tmp = strtok(cmdtext,idx);
SetPlayerSkin(playerid,strval(tmp));
return 1;
Works fine as long as the skin id is a valid one. But how can I make it so it doesn't crash if someone does something like /clothes 1313 ?
Re: client crashes when invalid /skin is chosen. -
M4S7ERMIND - 24.04.2010
Search for IsValidSkin.
Re: client crashes when invalid /skin is chosen. -
Eliran Pesahov - 24.04.2010
Код:
forward IsValidSkin(skinid);
public IsValidSkin(skinid)
{
#define MAX_BAD_SKINS 22
new badSkins[MAX_BAD_SKINS] =
{ 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 268, 273, 289 };
if (skinid < 0 || skinid > 299) return false;
for (new i = 0; i < MAX_BAD_SKINS; i++) { if (skinid == badSkins[i]) return false; }
#undef MAX_BAD_SKINS
return 1;
}
Try it, hope It will work for you.
Re: client crashes when invalid /skin is chosen. -
[LF]Mr.Lucci - 28.04.2010
Update, thanks for the help I got it to compile now but it still is not preventing crashes..