The point is I want to spawn knifes only if all the players (after one of them performs the command) don't have knifes so I need to check all of them. e.g. If there are 4 players in game and one of them types "/give knife plz" then I want to spawn knifes for all that 4 players but only if they do not have knifes already. If one of them has a knife then I won't spawn any knife for anybody. And I was pretty sure the knife was 12... Well thanks anyway, I'll try with that 14.
EDIT:
I think I made it... it still needs testing but it seems to work for one player.
After typing !knifes script checks if any living player on the map has a knife. If so, then it does nothing but if no one has a knife then it checks if there are still active knifes from last spawn. When there aren't any it spawns one knife right in front of each player.
var
knifes: array[1..10] of integer;
players: array[1..10] of byte;
GiveKnifes: byte;
procedure spawn(ID: byte);
var
i: byte;
begin
for i:=1 to 10 do
begin
if (GetObjectStat(knifes[i],'Active') = true) then GiveKnifes:=0;
end;
if (GiveKnifes = 1) then
begin
knifes[ID]:=SpawnObject(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 12);
end;
end;
procedure OnPlayerSpeak(ID: Byte; Text: string);
var
i: byte;
begin
GiveKnifes:=1;
if(Text = '!knifes') then
begin
for i:=1 to 10 do
begin
if (GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Health') > 0) then
begin
players[i]:=1;
if (GetPlayerStat(i,'Primary') = 14) or (GetPlayerStat(i,'Secondary') = 14) then GiveKnifes:=0;
end;
end;
if (GiveKnifes =1) then
begin
for i:=1 to 10 do
begin
if players[i]=1 then spawn(i);
end;
end;
end;
end;
I'm still new to scripting so if someone knows how to make it more efficient or correct eventual bugs then please do it.