Author Topic: Tag script (need help)  (Read 1853 times)

0 Members and 1 Guest are viewing this topic.

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Tag script (need help)
« on: September 04, 2007, 08:44:34 pm »
I still need help with this script, it works now, but the timers don't work

==SEE LAST POST FOR SCRIPT==
« Last Edit: September 09, 2007, 06:55:59 pm by Kavukamari »
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Martino

  • Major(1)
  • Posts: 18
Re: Tag script (need help)
« Reply #1 on: September 05, 2007, 12:57:12 pm »
I'm ont sure but I don't think that you can get every 3 bonusses at once. So I thin that this is problem.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Tag script (need help)
« Reply #2 on: September 05, 2007, 02:42:44 pm »
Quote from: www.enesce.com/help
procedure KillObject(ObjID: Integer): integer;
var
F, P, Z, V, C: string;
First thing I saw: look at the bolded stuff, you can't try to KillObject having the argument being a string. They should be an integer.

Date Posted: September 05, 2007, 03:41:05 PM
Saw something else that could be rewritten:
Quote
((Killer = IT) = false)
into
(Killer <> IT)

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Tag script (need help)
« Reply #3 on: September 05, 2007, 11:07:31 pm »
I'm ont sure but I don't think that you can get every 3 bonusses at once. So I thin that this is problem.

notice the bolded, underlined, capitol OR between the cluster nade and vest descriptions, I knew that little guy would go unnoticed

Date Posted: September 06, 2007, 12:04:07 AM
@ DorkeyDear: it still doesn't work, any more changes needed?
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: Tag script (need help)
« Reply #4 on: September 05, 2007, 11:58:57 pm »
You do look at the compilation error output, don't you? ... and half of that just doesn't make any sense at all. Oh well.

  • 1stKill is not a valid variable name as it starts with a digit. Change it into firstkill or anything else valid.
  • All your WriteConsole calls are messed up, seeing as you left out the color argument.
  • PowerUP = true; -> PowerUP := true;
  • There's a missing end; in OnPlayerKill.
  • (UP:='flame'); ... seriously. It's UP:='flame';, nothing else.

You should be able to compile it just fine by now, but there's still some major issues in it.

  • Using sleep won't work the way you think. It will pause up the entire script. If you really need a counter for that, either use ThreadFunc (buggy) or count a variable down once per AppOnIdle call instead.
  • The global declarations of upg and rade are unnecessary as you only use them in OnPlayerCommand. Same goes for F, P, Z, V, C.
  • F, P, Z, V, C should rather be bytes instead of integers (and especially not strings).
  • Use GetPlayerStat(id,'name') instead of IDtoName(id).
  • And then, AppOnIdle, which makes no bloody sense at all if I am to follow the description you wrote for the script. You spawn all the powerups at the player's position, then killing.. the one.. he wanted to get, leaving him with the four others? Oh well, have fun with that.

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Tag script (need help)
« Reply #5 on: September 07, 2007, 10:35:27 pm »
I don't even get a compilation error

Quote
The global declarations of upg and rade are unnecessary as you only use them in OnPlayerCommand. Same goes for F, P, Z, V, C.

if I leave this as-is, will it cause MAJOR problems?

and what does ThreadFunc do?

(And I changed the dang discription >.<)

Date Posted: September 06, 2007, 11:06:16 PM
and how do I spawn an item and save the byte for killing it if needed?

Date Posted: September 06, 2007, 11:08:53 PM
and it STILL doesn't work

Date Posted: September 07, 2007, 09:58:24 PM
nvm, I made it work, except, the timers don't work and it automatically spawns all of the bonuses, help!
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: Tag script (need help)
« Reply #6 on: September 08, 2007, 12:33:17 am »
and what does ThreadFunc do?
Runs a procedure or function under a separate thread. Have fun googling what that really means. Simple variable timers will suffice for your needs though.

and how do I spawn an item and save the byte for killing it if needed?
Assign the value returned from SpawnObject to a variable.

and it STILL doesn't work
As ya do.

nvm, I made it work, except, the timers don't work and it automatically spawns all of the bonuses, help!
Declare some integer variable (as a global one, not just inside AppOnIdle), set it to whatever you want, and count it down every AppOnIdle -- and voilĂ , you got yourself a timer right there. The reason why the timers "doesn't work" is because you actually never check on it using an if statement in that code you pasted here most recently.

And yes, it spawns all the bonuses because that's exactly what your script does. I do hope you know that SpawnObject.. spawns an object, whilst KillObject removes it. If you know that much, then you should be able to work the kinks out yourself.

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Tag script (need help)
« Reply #7 on: September 08, 2007, 07:07:50 pm »
I have an obvious (should've asked before) question, do I really need the kill objects?

(I only want it to kill the object if it isn't picked up)

Date Posted: September 08, 2007, 06:28:00 PM
now it works, but it doesn't spawn objects anymore, I updated the script code in the first post, can you tell what's wrong?

Date Posted: September 08, 2007, 07:40:32 PM
and what is the syntax for threadfunc?

Threadfunc(Function:string;Ticks:integer) ???
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Tag script (need help)
« Reply #8 on: September 08, 2007, 07:50:41 pm »
ThreadFunc works like this...

Code: [Select]
procedure Monkey(ID: byte; Text: string);
begin
  WriteLn(GetPlayerStat(ID,'IP') + ' is a ' + Text);
  Sleep(1000);
  WriteLn('Don''t you dare lie to me!');
end;

procedure OnFlagGrab(ID, TeamFlag: byte;GrabbedInBase: boolean);
begin
  ThreadFunc([ID,'freak'],'Monkey');
end;

for an example
examples are much easier to understand then words i think.
ThreadFunc(Arguments: array of variant; function: string); i would think.

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Tag script (need help)
« Reply #9 on: September 09, 2007, 06:53:24 pm »
here's the current script:
Code: [Select]
var
IT: Byte;
FirstKill, PowerUP, NewIT: boolean;
pause, UP: integer;

procedure OnMapChange(NewMap: string);
begin
//-----Reset vars-----
FirstKill:=false;
IT:=0;
pause:=0;
PowerUP:=false;
NewIT:=false;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
//-----First IT-----
if (FirstKill = false) then begin
  if (Killer <> Victim) then begin
  NewIT:=true;
  pause:=1;
  FirstKill:=true;
  IT:=Victim;
    WriteConsole(0,GetPlayerStat(IT,'Name')+' is it! Run away!',RGB(192,192,64));
    DrawText(0,GetPlayerStat(IT,'Name')+' is now it!',2500,RGB(192,64,64),0.20,40,240);
    PowerUP:=true;
  end;
end;
//-----New IT-----
if (Firstkill = true) and (IT > 0) then begin
  if (IT > 0) and (Victim <> IT) and (Killer = IT) then begin
  IT:=Victim;
  pause:=1;
  NewIT:=true;
    WriteConsole(0,GetPlayerStat(IT,'Name')+' is it! Run away!',RGB(192,192,64));
    DrawText(0,GetPlayerStat(IT,'Name')+' is now it!',2500,RGB(192,64,64),0.20,40,240);
    if (NewIT = true) then begin
    PowerUP:=true;
    if (pause = 0) then begin
    NewIT:=false;
    end;
    end;
  end;
//-----Power Up!-----
  if (PowerUP = true) and (NewIT = true) then begin
    DrawText(IT,'You are now it.',2500,RGB(192,64,64),0.25,40,240);
    SayToPlayer(IT,'You are now it. Please choose your "it" powerup');
    SayToPlayer(IT,'/upgrade flame, /upgrade pred, /upgrade zerk, /upgrade vest, or /upgrade clust');
  end;
//-----Extra Points!-----
    if (Victim = IT) and (Killer <> IT) and (pause = 0) then begin
    NewIT:=false;
    SayToPlayer(Killer,'You get 2 extra points for killing "it"');
    SetScore(Killer,GetPlayerStat(Killer,'Kills') + 2);
  end;
end;
end;

function OnPlayerCommand(ID:Byte;Text:string):boolean;
begin
  result:=false;
//-----Upgrade-----
  if GetPiece(LowerCase(Text), ' ', 0) = '/upgrade' then begin
    if (ID = IT) then begin
//-----flame-----
      if (GetPiece((Text), ' ', 1) = 'flame') and (PowerUP = true) then begin
      UP:=18;
      PowerUP:=false;
      end;
//-----pred-----
      if (GetPiece((Text), ' ', 1) = 'pred') and (PowerUP = true) then begin
      UP:=20;
      PowerUP:=false;
      end;
//-----zerk-----
      if (GetPiece((Text), ' ', 1) = 'zerk') and (PowerUP = true) then begin
      UP:=21;
      PowerUP:=false;
      end;
//-----vest-----
      if (GetPiece((Text), ' ', 1) = 'vest') and (PowerUP = true) then begin
      UP:=19;
      PowerUP:=false;
      end;
//-----clust-----
      if (GetPiece((Text), ' ', 1) = 'clust') and (PowerUP = true) then begin
      UP:=22;
      PowerUP:=false;
      end;
    end;
  end;
end;

procedure AppOnIdle(Ticks:integer);
var
  Time: integer;
  Spawn: boolean;
begin
  Time:=0;
if (Time = 0) then begin
  Spawn:=true;
end;
if (Time > 0) then begin
  Time:=Time-1;
  Spawn:=false;
end;
if (pause > 0) then begin
  pause:=pause-1;
end;
if (IT > 0) and (PowerUP = false) then begin
//-----flame-----
  if (UP = 18) and (Time = 0) then begin
  if (Spawn = true) then begin
  Time:=120;
    SpawnObject(GetPlayerStat(IT,'x'),GetPlayerStat(IT,'y'),18);
  end;
  end;
//-----pred-----
  if (UP = 20) and (Time = 0) then begin
  if (Spawn = true) then begin
  Time:=26;
    SpawnObject(GetPlayerStat(IT,'x'),GetPlayerStat(IT,'y'),20);
  end;
  end;
//-----zerk-----
  if (UP = 21) and (Time = 0) then begin
  if (Spawn = true) then begin
  Time:=16;
    SpawnObject(GetPlayerStat(IT,'x'),GetPlayerStat(IT,'y'),21);
  end;
  end;
//-----vest-----
  if (UP = 19) and (GetPlayerStat(IT,'Vest') < 100) then begin
    SpawnObject(GetPlayerStat(IT,'x'),GetPlayerStat(IT,'y'),19);
  end;
//-----clust-----
  if (UP = 22) and (GetPlayerStat(IT,'Grenades') = 0) then begin
    SpawnObject(GetPlayerStat(IT,'x'),GetPlayerStat(IT,'y'),22);
  end;
end;
end;

can anyone tell me why my timers don't work (the vest and clust packs work fine, the flamer, pred, and berserker packs spawn even if the timer says not to) help T_T (stupid timers *bangs on timers*)
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: Tag script (need help)
« Reply #10 on: September 09, 2007, 11:36:50 pm »
Declare some integer variable (as a global one, not just inside AppOnIdle), set it to whatever you want, and count it down every AppOnIdle -- and voilĂ , you got yourself a timer right there.

It doesn't work because it's a local variable only used within AppOnIdle; and you reset it on every procedure call.
Remote Time:=0; from AppOnIdle and move the Time: integer; declaration to the top of the file (where the global ones are declared).

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Tag script (need help)
« Reply #11 on: September 10, 2007, 08:23:38 pm »
ok, the tag script is operational, I want to see if my server is running, go to this link:

soldat://172.190.173.110:23073 (the IP might change, I'm on AOL)
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."