Need help - 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 (
/showthread.php?tid=93190)
Need help -
jakes888 - 23.08.2009
Hy,Can somebody tells me how to make:
First who kill (someplayer[random id]) get award?
pls help,thx
Re: Need help -
Khelif - 23.08.2009
this is my example
pawn Код:
new bool:FirstKill = false;
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(FirstKill == false)
{
FirstKill = true;
GivePlayerMoney(killerid, ...);
}
return 1;
}
Re: Need help -
jakes888 - 23.08.2009
thx for try,but i need also random id for player who need to be killed and other staffs

if you can help to me i will kiss you xD kidding
Re: Need help -
iMonk3y - 23.08.2009
I picked this up
pawn Код:
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;
}
usage
pawn Код:
new Randid = GetRandomID();
SendClientMessage(Randid, COLOR, "You were randomly selected.");