Author Topic: Need Help in Scripting  (Read 7039 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Need Help in Scripting
« Reply #60 on: December 29, 2008, 11:27:23 pm »
Yes,Yes EnEsCe, i know :D sry about Triple Post :D But do someone see it the "new" if i modify Post?
A trick I use is to take the contents of my previous post, delete it, and then make a new post containing the previous post and my new post. Then you avoid double posting and you bump the topic.
smart lil' bugger :)

you could spawn a bot there at the position of the m79 and then respawn it elsewhere / kick it; not sure how smooth it could come out to be though

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #61 on: January 02, 2009, 04:45:10 am »
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var i: Byte;
begin
     for i := 1 to 32 do
     if Ticks mod (60 * 20) = 0 then
     givebonus(i,1);
end;

procedure OnPlayerRespawn(ID: byte);
begin
     givebonus(ID,1);
     ForceWeapon(ID,13,14,0);
end;

procedure ActivateServer();
var w: Byte;
begin
     for w := 1 to 14 do
     SetWeaponActive(0,w,false);
end;
AppOnIdle is workingfine but OnPlayerRespawn is not giving me Predator or Law&Saw...
And SetWeaponAktive si too not working :(
Please Help idk why

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #62 on: January 02, 2009, 05:25:27 am »
it looks like you cant give a bonus while respawn. Use this:
Code: [Select]
var
cooldown: array [1..32] of byte;
just_resp: array [1..32] of boolean;

procedure AppOnIdle(Ticks: integer);
var i: Byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
givebonus(i,1);
cooldown[i] := 20;
if just_resp[i] then
begin
ForceWeapon(i,13,14,0);
just_resp[i] := false;
end;
end;
end;

procedure OnPlayerRespawn(ID: byte);
begin
cooldown[id] := 1;
just_resp[id] := true;
end;

procedure ActivateServer();
var w: Byte;
begin
     for w := 1 to 14 do
     SetWeaponActive(0,w,false);
end;

edit1
setweaponactive in this script works for me. Disables all weapons in menu.
« Last Edit: January 02, 2009, 05:34:03 am by tk »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #63 on: January 02, 2009, 05:42:12 am »
Thanks again ;) but do u know why
Code: [Select]
procedure ActivateServer();
var w: Byte;
begin
     for w := 1 to 14 do
     SetWeaponActive(0,w,false);
end;

SetWeaponActive not work?
« Last Edit: January 02, 2009, 07:01:42 am by y0uRd34th »

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Need Help in Scripting
« Reply #64 on: January 02, 2009, 07:11:09 am »
Because SetWeaponActive is not a permanent modification. You must tell each client as they join that all weapons are disabled.

Basically, any time you call SetWeaponActive it is ONLY affecting players currently in the server.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #65 on: January 02, 2009, 11:49:48 am »
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
var w: Byte
begin
     for w := 1 to 14 do
     SetWeaponActive(ID,w,false);
end;

It won't work can you show me an example or what i have to use in this?

Offline Rag

  • Major(1)
  • Posts: 18
Re: Need Help in Scripting
« Reply #66 on: January 02, 2009, 12:33:37 pm »
http://enesce.com/help/html/Functions/SetWeaponActive.html

heh.. ONE SIGN ";"  in second line... now it's ok........ should be^^
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
var w: Byte;
begin
     for w := 1 to 14 do
     SetWeaponActive(ID,w,false);
end;

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #67 on: January 02, 2009, 12:36:30 pm »
I know i fixed it already :/ but it won't work, server starts normally no Errors or other things :(

Offline Rag

  • Major(1)
  • Posts: 18
Re: Need Help in Scripting
« Reply #68 on: January 02, 2009, 01:05:01 pm »
well...   Or             And if it's wrong  I don't know...
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
var WeaponNum: Byte;
begin
     for WeaponNum := 1 to 14 do
     SetWeaponActive(ID,WeaponNum,false);
end;

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #69 on: January 02, 2009, 01:22:53 pm »
... Argh! Do no one know how to use it :(!?= argh...

Offline GSx_Major

  • Major
  • *
  • Posts: 97
Re: Need Help in Scripting
« Reply #70 on: January 02, 2009, 04:45:33 pm »
Use it in OnJoinTeam...
...and headbutt the sucker through your banana suit!

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Need Help in Scripting
« Reply #71 on: January 02, 2009, 07:09:10 pm »
If you are using a CTF match you must use OnJoinTeam. OnJoinGame is only called for Death Match

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #72 on: January 03, 2009, 04:22:33 am »
Thanks now it works, but now the weaponmenu is bugged :(, also i want to enable 1gun and if the Player picked it he get's Saw & Law how to do it? I think with GetPlayerStat(ID,Primary) = 1 or so? idk, thanks for answers!

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #73 on: January 03, 2009, 04:46:16 am »
Using OnWeapoChange would be better.

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
  if PrimaryNum = 1 then
    forceweapon(id,15,16,0);
end;

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #74 on: January 03, 2009, 08:15:15 am »
Hurraaa!!! Thanks :)
How can i get Players Health and give it him back when he got a Bonus because Bonus heals him :/

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #75 on: January 03, 2009, 08:34:24 am »
procedure givebonus2(id,style: byte);
var hp: integer;
begin
  hp:=getplayerstat(id,'health');
  givebonus(id,style);
  if (style=1) or (style=2) then
    dodamage(id,getplayerstat(id,'health')-hp);
end;
« Last Edit: January 03, 2009, 08:37:35 am by tk »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #76 on: January 03, 2009, 08:38:15 am »
Code: [Select]
var
   cooldown: array [1..32] of byte;
   coolbarret: array [1..32] of byte;

procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
   u: Byte;
begin
     for i := 1 to 32 do
     if getplayerstat(i,'active') then
     if cooldown[i] > 0 then
        cooldown[i] := cooldown[i] - 1
          else begin
          givebonus(i,1);     
          cooldown[i] := 20;
     end;

     for u := 1 to 32 do
     if GetPlayerStat(i,'active') then
     if coolbarret[u] > 0 then
        coolbarret[u] := cooldown[i] - 1
end;


procedure OnPlayerRespawn(ID: byte);
begin
     cooldown[id] := 1;
end;

procedure OnJoinTeam(ID, Team: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
     if PrimaryNum = 1 then
     ForceWeapon(ID,15,16,0);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     GiveBonus(ID,3);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/barret' then
     if coolbarret := 0 then begin
          ForceWeapon(ID,8,16,0);
               coolbarret[id] := 120;
          end;
     end;
   Result := false;
end;

These lines i added:
Code: [Select]
   u: Byte;
     for u := 1 to 32 do
     if GetPlayerStat(i,'active') then
     if coolbarret[u] > 0 then
        coolbarret[u] := cooldown[i] - 1
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/barret' then
     if coolbarret := 0 then begin
          ForceWeapon(ID,8,16,0);
               coolbarret[id] := 120;
          end;
     end;
   Result := false;
end;

Help me please :/
Thanks tk for the thing with HP :)
« Last Edit: January 03, 2009, 08:49:42 am by y0uRd34th »

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #77 on: January 03, 2009, 08:52:42 am »
did you add global array coolbarret?

Code: [Select]
coolbarret[u] := cooldown[i] - 1 perhaps you meant
Code: [Select]
coolbarret[i] := coolbarret[i] - 1
looks like you added one end too many in onplayercommand.

In apponidle you added 2 loops when everything can be done using one
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
begin
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
givebonus(i,1);     
cooldown[i] := 20;
end;
if coolbarret[i] > 0 then
coolbarret[i] := coolbarret[i] - 1;
end;
end;
end;

Next time dont post your all fails here, just try to fing bug and fix it. You can chceck in logs/consolelog(latest).txt what is wrong
« Last Edit: January 03, 2009, 08:57:22 am by tk »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Need Help in Scripting
« Reply #78 on: January 03, 2009, 09:20:40 am »
ok thanks for the info about the console log ;) and the script and when the script don't works i often look what can be wrong :/
Quote
did you add global array coolbarret?
Yes i did

Code: [Select]
var
   cooldown: array [1..32] of byte;
   coolbarret: array [1..32] of byte;

procedure AppOnIdle(Ticks: integer);
var
   i: Byte;
   hp: integer;
begin
   for i := 1 to 32 do
      if getplayerstat(i,'active') then
      begin
         if cooldown[i] > 0 then
            cooldown[i] := cooldown[i] - 1
            else begin
               hp:=GetPlayerStat(i,'health');
               GiveBonus(i,1);
               DoDamage(i,GetPlayerStat(i,'health')-hp);     
               cooldown[i] := 20;
            end;
         -here i think its missing-
         if coolbarret[i] > 0 then
            coolbarret[i] := coolbarret[i] - 1;
      end;
end;
end;

procedure OnPlayerRespawn(ID: byte);
begin
     cooldown[id] := 1;
end;

procedure OnJoinTeam(ID, Team: byte);
var
   w: Byte;
begin
     for w := 2 to 14 do
     SetWeaponActive(ID,w,false);
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
     if PrimaryNum = 1 then
     ForceWeapon(ID,15,16,0);
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
     GiveBonus(ID,3);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
     if Text = '/barret' then
     if coolbarret := 0 then begin
          ForceWeapon(ID,8,16,0);
          coolbarret[id] := 120;
     end;
   Result := false;
end;

I don't know it's [Error] (26:1): 'BEGIN' expected i think it's in AppOnIdle tryed else begin then begin adn so but don't find the fail... ;/ There are 4ends and 3begins...

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Need Help in Scripting
« Reply #79 on: January 03, 2009, 09:24:39 am »
Code: [Select]
but don't find the fail... ;/ There are 4ends and 3begins...begin
    begin
        begin
        end;
    end;
end;

there must be ALWAYS the same count of begins and ends