SA-MP Forums Archive
Need help with random skin on spawn. - 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: Need help with random skin on spawn. (/showthread.php?tid=88840)



Need help with random skin on spawn. - Celson - 29.07.2009

Ok so I wanna make it so when a player spawns his skin will change randomly.

This is what I've got...


new mafiaskin[][1] = {{111},{112},{125},{126}};

public OnPlayerSpawn(playerid)
{

new rand = random(sizeof(mafiaskin));
SetPlayerSkin(playerid,mafiaskin[rand][1]);

}

Can anyone explain to me what the 1 in my code actually means? Like what am I suppose to put there? I can't find any guides about it. It would be much appreciated.



Re: Need help with random skin on spawn. - Daren_Jacobson - 29.07.2009

use this
pawn Код:
new mafiaskin[] = {111},{112},{125},{126};

public OnPlayerSpawn(playerid)
{

new rand = random(sizeof(mafiaskin));
SetPlayerSkin(playerid,mafiaskin[rand]);

}
there may be something else wrong with it, i just fixed the obvious.


Re: Need help with random skin on spawn. - Celson - 29.07.2009

Quote:
Originally Posted by Daren_Jacobson
use this
pawn Код:
new mafiaskin[] = {111},{112},{125},{126};

public OnPlayerSpawn(playerid)
{

new rand = random(sizeof(mafiaskin));
SetPlayerSkin(playerid,mafiaskin[rand]);

}
there may be something else wrong with it, i just fixed the obvious.
When I use this

pawn Код:
new mafiaskin[] = {111},{112},{125},{126};

public OnPlayerSpawn(playerid)
{

new rand = random(sizeof(mafiaskin));
SetPlayerSkin(playerid,mafiaskin[rand]);

}
I get this error " C:\samp02X.win32\gamemodes\Jetpack.pwn(237) : error 020: invalid symbol name ""
C:\samp02X.win32\gamemodes\Jetpack.pwn(3781) : warning 203: symbol is never used: "" "


But if I use this...

pawn Код:
new mafiaskin[] = {{111},{112},{125},{126}};

public OnPlayerSpawn(playerid)
{

new rand = random(sizeof(mafiaskin));
SetPlayerSkin(playerid,mafiaskin[rand]);

}
Then I get " C:\samp02X.win32\gamemodes\Jetpack.pwn(237) : error 008: must be a constant expression; assumed zero "


Any other ideas?


Re: Need help with random skin on spawn. - NeedAName - 30.07.2009

Quote:
Originally Posted by Daren_Jacobson
But if I use this...

pawn Код:
new mafiaskin[] = {{111},{112},{125},{126}};

public OnPlayerSpawn(playerid)
{

new rand = random(sizeof(mafiaskin));
SetPlayerSkin(playerid,mafiaskin[rand]);

}
Then I get " C:\samp02X.win32\gamemodes\Jetpack.pwn(237) : error 008: must be a constant expression; assumed zero "


Any other ideas?
pawn Код:
new mafiaskin[4] = {{111},{112},{125},{126}};

public OnPlayerSpawn(playerid)
{

new rand = random(sizeof(mafiaskin));
SetPlayerSkin(playerid,mafiaskin[rand]);

}
mafiaskin[] must be a constant expression, so should be mafiaskin[4]


Re: Need help with random skin on spawn. - D3nnis - 30.07.2009

excuse me, but wouldn't
pawn Код:
new mafiaskin[][1] = {{111},{112},{125},{126}};

public OnPlayerSpawn(playerid)
{

new rand = random(sizeof(mafiaskin));
SetPlayerSkin(playerid,mafiaskin[rand][0]);

}
work fine?


Re: Need help with random skin on spawn. - Jefff - 30.07.2009

Код:
#define MAX_MAFIA_SKINS 4
new mafiaskin[MAX_MAFIA_SKINS] = {111,112,125,126};
public OnPlayerSpawn(playerid)
{
	SetPlayerSkin(playerid, mafiaskin[random(MAX_MAFIA_SKINS)]);
	return 1;
}



Re: Need help with random skin on spawn. - Antonio [G-RP] - 30.07.2009

Jefff your a pro LOL,
but please tell my why my "PlayerToPoint" wont work