23.08.2009, 18:46
Hy,Can somebody tells me how to make:
First who kill (someplayer[random id]) get award?
pls help,thx
First who kill (someplayer[random id]) get award?
pls help,thx
new bool:FirstKill = false;
public OnPlayerDeath(playerid, killerid, reason)
{
if(FirstKill == false)
{
FirstKill = true;
GivePlayerMoney(killerid, ...);
}
return 1;
}
stock GetRandomID() //thanks to Boylett
{
new bool:connected[ALL_PLAYERS] = false, amount = 0;
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i))
{
connected[i] = true;
amount++;
}
}
if(amount == 0) return -1;
new rand = random(amount), done = 0;
for(new i = 0; i < MAX_PLAYERS; i++) {
if(connected[i])
{
if(done == rand) return i;
done++;
}
}
return -1;
}
new Randid = GetRandomID();
SendClientMessage(Randid, COLOR, "You were randomly selected.");