Author Topic: KillObject not working properlaly?  (Read 804 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
KillObject not working properlaly?
« on: May 19, 2007, 09:28:06 pm »
Code: [Select]
procedure OnPlayerSpeak(ID: byte; Text: string);
var
  i: integer;
begin
  Cash[ID] := 16000;
  i := SpawnObject(GetPlayerStat(ID,'X') + 50,GetPlayerStat(ID,'Y'),17);
  Command('/say B4');
  Sleep(2000);
  KillObject(i);
  Command('/say AF');
end;

It just doesn't kill the grenade box when it should... Please help.

I have another question while I'm at it...
When I have the box spawn on top of you, you pick it up... But the problem is that it respawns, which is why I need to get this to work. (On a r/s server) So I can make one person pick up the box and then it goes bye bye, so no1 else gets it.
« Last Edit: May 19, 2007, 09:41:37 pm by DorkeyDear »

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: KillObject not working properlaly?
« Reply #1 on: May 20, 2007, 04:24:08 am »
afaik, KillObject works, it's only the grenade kit's graphic that stays for a bunch of seconds, it doesn't have any effect though after it was killed. you should also call the sleep() and the KillObject in a separate ThreadFunc because as far as i can see, sleep doesn't work in some of the hardcoded procedures.

Code: [Select]
procedure DelayedKillObject(ObjectID,Delay: integer);
begin
  sleep(Delay);
  KillObject(ObjectID);
end;

procedure OnPlayerSpeak(ID: byte; Text: string);
var
  i: integer;
begin
  Cash[ID] := 16000;
  i := SpawnObject(GetPlayerStat(ID,'X') + 50,GetPlayerStat(ID,'Y'),17);
  Command('/say B4');
  ThreadFunc([i,2000],'DelayedKillObject');
  Command('/say AF');
end;
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: KillObject not working properlaly?
« Reply #2 on: May 20, 2007, 08:08:39 am »
:) Thanks.. No wonder I couldn't pick up the boxes b4.
I see that I can spawn the boxes elsewhere to move the gfx out of the map too, so I might do that...
What happens when I spawn a box outside the map? Does it do the "normal spawn" at the nade spawn points? or does it just... go away? I hope it just goes away :)