Need help with random skin on spawn.
#1

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.
Reply
#2

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.
Reply
#3

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?
Reply
#4

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]
Reply
#5

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?
Reply
#6

Код:
#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;
}
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)