Author Topic: Script request !!!  (Read 5262 times)

0 Members and 1 Guest are viewing this topic.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Script request !!!
« on: May 26, 2010, 03:14:52 pm »
when a bot get killed that kick him !!!
i only want that !!!
« Last Edit: May 26, 2010, 03:56:39 pm by mich1103 »

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Script request !!!
« Reply #1 on: May 26, 2010, 04:16:14 pm »
Wrong section, but here.

Code: [Select]
var kick: array[1..32] of boolean;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
if getplayerstat(victim,'human') = false then kick[victim] := true;
end;

procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
for i := 1 to 32 do if getplayerstat(i,'active') = true then if kick[i] then kickplayer(i);
end;

procedure OnJoinGame(ID, Team: Byte);
begin
kick[ID] := false;
end;

Edit: Fixed.
« Last Edit: May 26, 2010, 05:51:05 pm by Hacktank »


Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script request !!!
« Reply #2 on: May 26, 2010, 04:27:35 pm »
10-05-26 17:26:30 
  • kickbot -> [Error] (12:65): Unknown identifier 'player'

 :'(  :-\

DarkCrusade

  • Guest
Re: Script request !!!
« Reply #3 on: May 26, 2010, 05:04:41 pm »
Code: [Select]
var kick: array[1..32] of boolean;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
if getplayerstat(victim,'human') = false then kick[victim] := true;
end;

procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
for i := 1 to 32 do if getplayerstat(i,'active') = true then if kick[i] then kickplayer(i);
end;

procedure OnJoinGame(ID, Team: Byte);
begin
kick[ID] := false;
end;

Offline Stuffy

  • Soldier
  • **
  • Posts: 182
  • Very stuffy.
    • Climb-Zone Forum
Re: Script request !!!
« Reply #4 on: May 27, 2010, 06:09:16 am »
why did you use AppOnIdle for kicking the bot?
Code: [Select]
if not GetPlayerStat(Victim, 'human') then KickPlayer(Victim); does the same, right?
The truth is out there? Does anyone know the URL?
The URL is here

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Script request !!!
« Reply #5 on: May 27, 2010, 08:36:47 am »
why did you use AppOnIdle for kicking the bot?
Code: [Select]
if not GetPlayerStat(Victim, 'human') then KickPlayer(Victim); does the same, right?
It's lame when body disappears on hit.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Script request !!!
« Reply #6 on: May 27, 2010, 08:38:58 am »
But it looks gay when you kill bot and it disappears, try it ;|

And f**king use = true for GetPlayerStat because it returns variant and not boolean and it is know of causing errors from time to time when not doing this, thanks.

Btw. I'd go with this (if you're not going to write some uber-huge script..)
Code: (pascal) [Select]
procedure OnPlayerRespawn(ID: byte);
begin
  if (GetPlayerStat(ID, 'Human') = false) and (GetPlayerStat(ID, 'Deaths') > 0) then
    KickPlayer(ID);
end;


Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Script request !!!
« Reply #7 on: May 27, 2010, 08:41:36 am »
well, no, you won't be able to see the "you killed..." message if the bot gets kicked on kill.

Also, the code done in more efficient way:
Code: [Select]
var kick: array[1..32] of boolean;
check_kick: boolean;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
  if getplayerstat(victim,'human') = false then begin
    kick[victim] := true;
    check_kick := true;
  end;
end;

procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
  if check_kick then begin
    for i := 1 to 32 do
      if kick[i] then
        kickplayer(i);
    check_kick := false;
  end;
end;

procedure OnJoinGame(ID, Team: Byte);
begin
kick[ID] := false;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
kick[ID] := false;
end;


edit
You propably should try swompie's code too

edit#2
Quote
And f**king use = true for GetPlayerStat because it returns variant and not boolean and it is know of causing errors from time to time when not doing this, thanks.
It's not confirmed afaik and never throws errors for me.
« Last Edit: May 27, 2010, 08:47:16 am by tk »

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Script request !!!
« Reply #8 on: May 27, 2010, 09:06:00 am »
Well, it's just from what I've read all over these months here in the forums.
And actually I find it looks more smooth when theres a true/false behind GetPlayerStat (I think this sure because I always used it and never seen it another way)

Btw. your code would be good if your going to write a bigger script like I said already.

DarkCrusade

  • Guest
Re: Script request !!!
« Reply #9 on: May 27, 2010, 09:40:44 am »
I always kick bots after they respawn. It looks smooth and is not annoying.

@tk: Neosano's iMod crashes often because he used GetPlayerStat like you did. You also forgot to check whether the ID is active in your loop in AppOnIdle.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Script request !!!
« Reply #10 on: May 27, 2010, 09:59:08 am »
I removed getplayerstat->active check from that code because it was not needed and would cause only useless cpu usage. There is no possibility that kick[ i] will be true for an inactive id.
« Last Edit: May 27, 2010, 10:01:28 am by tk »

DarkCrusade

  • Guest
Re: Script request !!!
« Reply #11 on: May 27, 2010, 10:21:37 am »
Oh I see, good to know this.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script request !!!
« Reply #12 on: May 27, 2010, 04:46:12 pm »
now i want a script that detect if there is human on the server !
like : when there is human (any number) each 2 min thats add bot !
Can we do that ?

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Script request !!!
« Reply #13 on: May 27, 2010, 05:20:03 pm »
Code: [Select]
const
timeper = 120; // # of seconds between bot spawning

var
countdown: integer;

procedure AppOnIdle(Ticks: integer);
begin
if numplayers - numbots > 0 then if countdown > 0 then begin
countdown := countdown - 1;
if countdown = 0 then begin
command('/addbot1 ' + randombot());
countdown := timeper;
end;
end;
if countdown <= 0 then countdown := timeper;
end;
« Last Edit: May 27, 2010, 05:23:01 pm by Hacktank »


Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script request !!!
« Reply #14 on: May 27, 2010, 05:22:18 pm »
that detect if there is some human on the server ?

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Script request !!!
« Reply #15 on: May 27, 2010, 05:23:16 pm »
Yes. Updated it too as you posted.


Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script request !!!
« Reply #16 on: May 27, 2010, 06:17:49 pm »
when a bots is added that kick him automaticly !!!
i think is due to the kickbot script !!!
« Last Edit: May 27, 2010, 06:31:53 pm by mich1103 »

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Script request !!!
« Reply #17 on: May 27, 2010, 06:36:14 pm »
Whos version of the kickbot script are you using?


Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script request !!!
« Reply #18 on: May 27, 2010, 06:42:19 pm »
This one
Code: [Select]
var kick: array[1..32] of boolean;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
if getplayerstat(victim,'human') = false then kick[victim] := true;
end;

procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
for i := 1 to 32 do if getplayerstat(i,'active') = true then if kick[i] then kickplayer(i);
end;

procedure OnJoinGame(ID, Team: Byte);
begin
kick[ID] := false;
end;

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Script request !!!
« Reply #19 on: May 27, 2010, 08:40:50 pm »
Oh, my bad. Forgot that OnJoinGame() is not called for bots...

Code: [Select]
var kick: array[1..32] of boolean;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
if getplayerstat(victim,'human') = false then kick[victim] := true;
end;

procedure AppOnIdle(Ticks: integer);
var i: byte;
begin
for i := 1 to 32 do if getplayerstat(i,'active') = true then if kick[i] then kickplayer(i);
end;

procedure OnJoinTeam(ID, Team: Byte);
begin
kick[ID] := false;
end;