Generating a Random Number, | Rep++
#1

Hello.
I'm don't know much about random Function
Well.
I want to make something like when player request class It shows him different teams every time he requests,
Like i joined the server it shows me Team A First next time i join it shows me Team C First.
I heard about A "random" Is it possible to make Something like this if we Define A Number as a Team ID ?
Reply
#2

pawn Код:
stock randomEx(min, max)
{    
    //Credits to ******    
    new rand = random(max-min)+min;    
    return rand;
}
You can use that for random numbers, but I'm not sure how to define teams as a number.
Reply
#3

Thats the problem i am having ....
Reply
#4

well define one variable for a team, for example:
Код:
new pTeam[MAX_PLAYERS];
// for example you have 4 teams
and you can do something like this under onPlayerRequestClass
Код:
new team;
team = Random(4);
pTeam[playerid] = team;
Reply
#5

Quote:
Originally Posted by dominik523
Посмотреть сообщение
well define one variable for a team, for example:
Код:
new pTeam[MAX_PLAYERS];
// for example you have 4 teams
and you can do something like this under onPlayerRequestClass
Код:
new team;
team = Random(4);
pTeam[playerid] = team;
Thank You.
But
team = Random(4);
Error on this line
error 010: invalid function or declaration
Reply
#6

random() not Random()
Reply
#7

Quote:
Originally Posted by DeStunter
Посмотреть сообщение
random() not Random()
Still having the error.
Reply
#8



Reply
#9

I tried to compile this
Код:
new rteam;
rteam = random(11);
and I don't have any errors. Where did you put that text?
Reply
#10

Quote:
Originally Posted by dominik523
Посмотреть сообщение
I tried to compile this
Код:
new rteam;
rteam = random(11);
and I don't have any errors. Where did you put that text?
Well. I put It Under where the Teams are defined. On the Top of the Script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)