0 Members and 1 Guest are viewing this topic.
var hasflag: array[1..32] of boolean;procedure ActivateServer();var i: byte;beginfor i := 1 to 32 do begin hasflag[i] := false end;end;procedure OnFlagDrop(ID: byte);begin//stuff hereend;procedure AppOnIdle(Ticks: integer);var i: byte;beginfor i := 1 to 32 do begin if getplayerstat(i,'active') = true then begin if getplayerstat(i,'flagger') = true then hasflag[i] := true; if (getplayerstat(i,'flagger') = false) AND (hasflag[i] = true) then begin hasflag[i] := false OnFlagDrop(i); end; if getplayerstat(i,'flagger') = false then hasflag[i] := false; end; endend;
var FlagHolders: array[1..2] of byte;procedure OnFlagDropped(const Id, Flag: byte);begin// your OnFlagDropped eventend;procedure AppOnIdle(Ticks: cardinal);begin // or could do for i := 1 to 2 do but not too necessary when you want to call only 2 functions per each of the 2 iterations if (GetPlayerStat(FlagHolders[1], 'Flagger') = false) then begin // if the old alpha flag holder no longer has the flag OnFlagDropped(FlagHolders[1], 1); FlagHolders[1] := 0; // clear the alpha flag holder end; if (GetPlayerStat(FlagHolders[2], 'Flagger') = false) then begin OnFlagDropped(FlagHolders[2], 2); FlagHolders[2] := 0; end;// other contentsend;procedure OnFlagGrab(Id, TeamFlag: byte; GrabbedInBase: boolean);begin // note OnFlagDropped will be called first if a person drops the flag, and picks it back up within a second (or less); if you need to use this function, put your stuff after this code if (FlagHolders[TeamFlag] <> 0) then // if there was an old flag holder (can be the same person) OnFlagDropped(FlagHolder[TeamFlag], TeamFlag); FlagHolder[TeamFlag] := Id; // set the new flag holder for the given team flag// other contentsend;