Random player skins
#1

In my server everybody uses the same skin, simply because it is the first one. Now i want to put them in a random order when they choose one on startup. How do i get them in random order?

my array:
pawn Код:
new PlayerSkins[35] = {
27,45,54,56,63,64,70,75,77,82,83,84,87,89,92,130,138,139,140,144,145,152,167,178,198,205,237,239,264,257,244,245,246,249,256
};
Reply
#2

https://sampwiki.blast.hk/wiki/AddPlayerClass
Reply
#3

Yes i know, but that's not random
Reply
#4

Quote:
Originally Posted by martin149
Посмотреть сообщение
Yes i know, but that's not random
You mean that when they are playing skins will change time to time ?
Reply
#5

Check here if it help: https://sampforum.blast.hk/showthread.php?tid=139456
Reply
#6

pawn Код:
new PlayerSkins[35] = {
27,45,54,56,63,64,70,75,77,82,83,84,87,89,92,130,138,139,140,144,145,152,167,178,198,205,237,239,264,257,244,245,246,249,256
};

public OnPlayerSpawn(playerid)
{
   new r = random(sizeof(PlayerSkins));
   SetPlayerSkin(playerid, PlayerSkins[r]);
   return 1;
}
Reply
#7

Im sorry, but that's not what i am looking for... I want to give people a choice. So i want to add the classes in a random order. That way, everybody will see another skin when they start, but still have the opportunity to choose one.
Reply
#8

Bump
Reply
#9

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(setskin,7,cmdtext);
return 0;
}
pawn Код:
dcmd_setskin(playerid, params[])
{
    if(!CmdLevelCheck(playerid,"setskin")) return CmdLevelError(playerid,"setskin");
    new id,skinid,string[128];
    if(sscanf(params, "ud", id, skinid)) return SendClientMessage(playerid, RED, "USAGE: /SETSKIN [ID / NICK] [SKINID]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, RED, "This player is offline");
    if(IsSkinWrong(skinid)) return SendClientMessage(playerid,RED,"Error: enter a valid skin-ID");
    SendCommandMsg(playerid,"setskin");
    if(playerid != id) format(string,sizeof(string),"Administrator: %s have set your skin to %d",AdminName(playerid),skinid);
    else format(string,sizeof(string),"You have set your own skin to %d",skinid);
    SendClientMessage(id,YELLOW,string);
    format(string,sizeof(string),"You have set %s his skin to %d",Name(id),skinid);
    SendClientMessage(playerid,YELLOW,string);
    return SetPlayerSkin(id,skinid);
}
Try this.
Reply
#10

I am now trying to implement the Fisher-Yates Shuffle algorithm... You will hear from thos soon...

I all is very nice but let me explain again...

Whar i want is when somebody connects, they get the default class-selection options, but instead of showing them in a fixed order to erveryone, i want to show them in random order.

So if my classes are 1,2 and 3 for example, everybody will use 1 in the default selection. What i want is making the options random, so everybody will be different but will still have a choice.

So what a basically need is a method to shuffle an array, just like the php shuffle function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)