Author Topic: Need some help...  (Read 1321 times)

0 Members and 1 Guest are viewing this topic.

Offline Rag

  • Major(1)
  • Posts: 18
Need some help...
« on: December 29, 2008, 02:19:33 pm »
Well, I have wrote a simple script called "Killer". It kills all players or players in selected teams.. Of course it depends on chosen command by admin. There is no bug in language(pascal).

Plz help me, I don't know how to fix it...

If you want- click http://www.speedyshare.com/681568292.html to download it


P.S.: Sry for my english- It's not very well...

Code: [Select]
//  Script:    "Killer"             by Rag                  
//  This script will kill all players OR  players in Alpha or Bravo or Charlie or Delta or None team
//  commands for player  !killer     
//  for admin:  /killer  /killall  /killA  /killB  /killC  /killD  /killN



const
 maincolor=$0000FF;
 infocolor=$32CD32;
 teamcolor=$FFD700;
 actioncolor1=$FFD700;
 actioncolor2=$BA55D3;
 errorcolor=$FF0000;


var
i: byte;
scriptOn: byte;


procedure ActivateServer();
begin
scriptOn:=0;
WriteLn('Killer is OFF');
end;


procedure OnJoinGame(ID, Team: byte);
begin
for i:=1 to MaxPlayers do
begin
if (scriptOn=1) then
begin
Writeconsole(i,'Script "Killer" LOADED.', maincolor);
Writeconsole(i,'"Killer" status: ENABLED.', maincolor);
end
else
begin
Writeconsole(i,'"Killer" is DISABLED.', maincolor);
end;
end;
end;


procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
if (Text = '!killer') then
begin
if (scriptOn=1) then
begin
Writeconsole(i,'"Killer" is Enabled. BEEWARE on admin xD', infocolor);
end
else
begin
Writeconsole(i,'"Killer" is Disabled.', infocolor);
end;
end;
end;


procedure KillerAll();
var
MaxPlayers: byte;
begin
for i:=1 to MaxPlayers do
begin
if ((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Health') > 0) and (GetPlayerStat(i,'Team') <> 5)) then
begin
WriteConsole(0,'WATCH OUT!!', actioncolor1);
WriteLn('"Killer" in action....');
DoDamage(ID,4000)
end
else
if ((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = false) and (GetPlayerStat(i,'Team') <> 5)) then
begin
WriteConsole(i,'You have gotta be kidding ME!! You buster.', actioncolor2);
end
else
if ((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Team') = 5)) then
begin
WriteConsole(i,'You have gotta be kidding ME!! You buster.', actioncolor2);
end;
end;
end;


procedure KillerA();
var
AlphaPlayers: byte;
MaxPlayers: byte;
begin
for i:=1 to MaxPlayers do
begin
if AlphaPlayers=0 then
begin
WriteConsole(0,'There is NO Players in Aplha team', errorcolor);
WriteLn('Error(02): No Players in A team');
end
else
begin
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Health') > 0) and (GetPlayerStat(i,'Team') = 1)) then
begin
WriteConsole(i,'Alpha team: WATCH OUT!!', teamcolor);
DoDamage(i,4000);
WriteLn('Alpha team has been killed....');
WriteConsole(0,'Alpha team has been killed by Admin.', actioncolor1);
end;
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = false) and (GetPlayerStat(i,'Team') = 1)) then
begin
WriteConsole(i,'You have gotta be Kidding ME. Ha!', actioncolor2);
end;
if ((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Team') <> 1)) then
begin
WriteConsole(i,'You have got luck.....', actioncolor2);
end;
end;
end;
end;

procedure KillerB();
var
BravoPlayers: byte;
MaxPlayers: byte;
begin
for i:=1 to MaxPlayers do
begin
if BravoPlayers=0 then
begin
WriteConsole(0,'There is NO Players in Bravo team', errorcolor);
WriteLn('Error(03): No Players in B team');
end
else
begin
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Health') > 0) and (GetPlayerStat(i,'Team') = 2)) then
begin
WriteConsole(i,'Bravo team: WATCH OUT!!', teamcolor);
DoDamage(i,4000);
WriteLn('Bravo team has been killed....');
WriteConsole(0,'Bravo team has been killed by Admin.', actioncolor1);
end;
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = false) and (GetPlayerStat(i,'Team') = 2)) then
begin
WriteConsole(i,'You have gotta be Kidding ME. Ha!', actioncolor2);
end;
if ((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Team') <> 2)) then
begin
WriteConsole(i,'You have got luck.....', actioncolor2);
end;
end;
end;
end;


Procedure KillerC();
var
CharliePlayers: byte;
MaxPlayers: byte;
begin
for i:=1 to MaxPlayers do
begin
if CharliePlayers=0 then
begin
WriteConsole(0,'There is NO Players in Charlie team', errorcolor);
WriteLn('Error(04): No Players in C team');
end
else
begin
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Health') > 0) and (GetPlayerStat(i,'Team') = 3)) then
begin
WriteConsole(i,'Charlie team: WATCH OUT!!', teamcolor);
DoDamage(i,4000);
WriteLn('Charlie team has been killed....');
WriteConsole(0,'Charlie team has been killed by Admin.', actioncolor1);
end;
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = false) and (GetPlayerStat(i,'Team') = 3)) then
begin
WriteConsole(i,'You have gotta be Kidding ME. Ha!', actioncolor2);
end;
if ((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Team') <> 3)) then
begin
WriteConsole(i,'You have got luck.....', actioncolor2);
end;
end;
end;
end;


procedure KillerD();
var
DeltaPlayers: byte;
MaxPlayers: byte;
begin
for i:=1 to MaxPlayers do
begin
if DeltaPlayers=0 then
begin
WriteConsole(0,'There is NO Players in Delta team', errorcolor);
WriteLn('Error(05): No Players in D team');
end
else
begin
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Health') > 0) and (GetPlayerStat(i,'Team') = 4)) then
begin
WriteConsole(i,'Delta team: WATCH OUT!!', teamcolor);
DoDamage(i,4000);
WriteLn('Delta team has been killed....');
WriteConsole(0,'Delta team has been killed by Admin.', actioncolor1);
end;
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = false) and (GetPlayerStat(i,'Team') = 4)) then
begin
WriteConsole(i,'You have gotta be Kidding ME. Ha!', actioncolor2);
end;
if ((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Team') <> 4)) then
begin
WriteConsole(i,'You have got luck.....', actioncolor2);
end;
end;
end;
end;


procedure KillerN();
var
DeathmatchPlayers: byte;
MaxPlayers: byte;
begin
for i:=1 to MaxPlayers do
begin
if DeathmatchPlayers=0 then
begin
WriteConsole(0,'There is NO Players in None team', errorcolor);
WriteLn('Error(06): No Players in N team');
end
else
begin
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Health') > 0) and (GetPlayerStat(i,'Team') = 0)) then
begin
WriteConsole(i,'None team: WATCH OUT!!', teamcolor);
DoDamage(i,4000);
WriteLn('None team has been killed....');
WriteConsole(0,'None team has been killed by Admin.', actioncolor1);
end;
if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = false) and (GetPlayerStat(i,'Team') = 0)) then
begin
WriteConsole(i,'You have gotta be Kidding ME. Ha!', actioncolor2);
end;
if ((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Team') <> 0)) then
begin
WriteConsole(i,'You have got luck.....', actioncolor2);
end;
end;
end;
end;


function OnCommand(ID: Byte; Text: string): boolean;
begin
if (Text = '/killer') then
begin
if (scriptOn=0) then
begin
scriptOn:=1;
WriteConsole(0,'"Killer" has been Enabled. Watch out!', maincolor);
WriteLn('"Killer" has been turned ON.');
end
else
begin
scriptOn:=0;
WriteConsole(0,'"Killer" has been diasbled. Uff.', maincolor);
WriteLn('"Killer" has been turned OFF');
end;
end;


if (Text = '/killall') then
begin
if (scriptOn=1) then
begin
KillerAll();
end
else
begin
WriteConsole(0,'You can not preform script, if it is disabled', errorcolor);
WriteLn('Error(01): Script is OFF.');
end;
end;


if (Text = '/killA') then
begin
if (scriptOn=1) then
begin
KillerA();
end
else
begin
WriteConsole(0,'You can not preform script, if it is disabled', errorcolor);
WriteLn('Error(01): Script is OFF.');
end;
end;


if (Text = '/killB') then
begin
if (scriptOn=1) then
begin
KillerB();
end
else
begin
WriteConsole(0,'You can not preform script, if it is disabled', errorcolor);
WriteLn('Error(01): Script is OFF.');
end;
end;


if (Text = '/killC') then
begin
if (scriptOn=1) then
begin
KillerC();
end
else
begin
WriteConsole(0,'You can not preform script, if it is disabled', errorcolor);
WriteLn('Error(01): Script is OFF.');
end;
end;


if (Text = '/killD') then
begin
if (scriptOn=1) then
begin
KillerD();
end
else
begin
WriteConsole(0,'You can not preform script, if it is disabled', errorcolor);
WriteLn('Error(01): Script is OFF.');
end;
end;


if (Text = '/killN') then
begin
if (scriptOn=1) then
begin
KillerN();
end
else
begin
WriteConsole(0,'You can not preform script, if it is disabled', errorcolor);
WriteLn('Error(01): Script is OFF.');
end;
end;
end;


Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Need some help...
« Reply #1 on: December 29, 2008, 04:03:32 pm »
Well aside from some pretty crazy programming stuff that looks like it will still work but can cut the length of the script by a lot (we can talk about that too), the bigger issue that I see just glancing over your script is that you DO NOT have to define variables provided by the scriptcore in your script. Things like MaxPlayers and AlphaPlayers and such, get rid of them from the beginnings of your procedures.

Offline Rag

  • Major(1)
  • Posts: 18
Re: Need some help...
« Reply #2 on: December 29, 2008, 05:03:08 pm »
Yeah I'll try to do it, but I've got problem with define var i  with ID :| . As you can see it works on SoldatServer 263, but it don't kill.
Only function '/killer' and messages about script status (On, Off) works good.

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Need some help...
« Reply #3 on: December 29, 2008, 06:04:13 pm »
first of all you're using "ID" instead of "i" on line 72 ("DoDamage(ID,4000)"). Idk how it compiled for you, as it didnt for me... It has to be "i", because "ID" is not defined in KillerAll() and you want it to be "i" anyway, since its the iteration var you're using.

Secondly, as iDante said you should not even try to declare the built-in vars, such as MaxPlayers, AlphaPlayers etc. That makes them local variables, which have values different from the global variables with the same name. So naturally it didnt even start the for loops in any of the killing procedures, because MaxPlayers and such were equal to 0 :G

Offline Rag

  • Major(1)
  • Posts: 18
Re: Need some help...
« Reply #4 on: December 31, 2008, 09:43:07 am »
Thanks. Now it works fine...  I've changed some things because few messages were shown for eight times.
And one word more: It's been created for survival mode, but usefull for all.
« Last Edit: January 02, 2009, 04:13:49 am by Rag »

Offline Rag

  • Major(1)
  • Posts: 18
Re: Need some help...
« Reply #5 on: January 03, 2009, 06:37:37 pm »
It's me again^^. Now i cut it short. But I've got 1 problem..


[Error] (79:110): Close round expected
 That problem appeared after i added "s[k]".. but it should be ok.... idk..
Code: [Select]
78 if((GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = false) and (GetPlayerStat(i,'Team') s[k] TNr[j])) then
79 begin

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Need some help...
« Reply #6 on: January 03, 2009, 06:43:17 pm »
what is (GetPlayerStat(i,'Team') s[k] TNr[j]) supposed to mean? Oo

Offline Rag

  • Major(1)
  • Posts: 18
Re: Need some help...
« Reply #7 on: January 03, 2009, 06:48:26 pm »
well

s[k] means sign "="  or "<>" expressed in char.... idk exactly is that correct..?
TNr[j] is a given player team... from 0 to 5

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Need some help...
« Reply #8 on: January 03, 2009, 06:53:14 pm »
well

s[k] means sign "="  or "<>" expressed in char.... idk exactly is that correct..?
You cannot do that. Split it into two expressions.

Offline Rag

  • Major(1)
  • Posts: 18
Re: Need some help...
« Reply #9 on: January 03, 2009, 07:08:43 pm »
thx for help again