Author Topic: Help with basic script  (Read 7805 times)

0 Members and 1 Guest are viewing this topic.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #40 on: June 02, 2010, 01:49:07 am »
very simple problem , probably a solution thats staring me in da face

ok i have added an item to my shop which when the person buys the item and captures the Blue flag, this then Teleports them to where the red flag is, problem is, the player warps without the flag, is there any way i can warp the player with the captured flag?

da code:
Code: (pascal) [Select]
var HBFT:Array[1..32] of Boolean;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  if Text = '/buy FTP' then begin
    if Cash < 10000 then begin
      WriteConsole(0,IdtoName(ID)+' just tried to purchase a Flag Teleport, not enough funds!',$EE81FAA1);
    end;
    if Cash >= 10000 then begin
      Cash :=Cash-10000;
      WriteConsole(0,IdtoName(ID)+' has just bought a Flag Teleport for 10000 Cash',$EE81FAA1);
      HBFT[ID]:=True;
    end;
  end;
end;

procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
  if HBFT[ID] = True then begin
    MovePlayer(ID,GetObjectStat(1,'X'), GetObjectStat(1, 'Y'));
    WriteConsole(ID,'Grab detected, moving you now...',$EE81FAA1);
    HBFT[ID]:=False;
  end;
end;
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Help with basic script
« Reply #41 on: June 02, 2010, 02:00:38 am »
No, it is a hacker preventitive measure that warping returns the flag. But you may be able to spawnobject a new flag onto him where he warps? :)


Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #42 on: June 02, 2010, 02:06:44 am »
thanks Hacktank now i got something to work off

From: June 02, 2010, 02:30:03 am
hmm, the flags arent on the Object list, i guess its definitely not possible to do

From: June 02, 2010, 02:58:36 am
hmm lol sometimes it works sometimes it doesnt, its quite unpredictable where you land if you have the flag after grabbing and it warps you With the flag, lol
« Last Edit: June 02, 2010, 02:58:36 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #43 on: June 02, 2010, 03:03:39 am »
MovePlayer() is broken...

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #44 on: June 02, 2010, 03:23:16 am »
aww what? so what else can i use to move players with? have a few new scrips in mind, need something that works with soldatserver 263

From: June 02, 2010, 01:21:14 pm
hmm was it 263 or 253? cant remember
« Last Edit: June 02, 2010, 01:21:14 pm by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #45 on: June 03, 2010, 05:50:58 am »
Blurr, I failed..
Well, actually it sometimes cause people to drop their weapons, I read that the server causes you to drop the flag because of some "anti cheat" stuff or so, jbut not sure if that's true. (But it should move to correct XY, atleast it does in eC's servers)
The object styles of alpha/bravo flags should be 1 and 2 iirc.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #46 on: June 04, 2010, 01:39:34 am »
The object styles of alpha/bravo flags should be 1 and 2 iirc.
nope, im going to have to find out how the devs on ECs servers did it

list is exactly as follows:
ObjType List:
 1        Desert Eagle
 2        HK MP5
 3        AK 74
 4        Steyr AUG
 5        Spas 12
 6        Ruger77
 7        M79
 8        Barrett M82A1
 9        Minimi
 10       Minigun
 11       USSOCOM
 12       Combat Knife
 13       Chainsaw
 14       LAW
 15       Stationary Gun
 16       Medical Kit
 17       Grenade Kit
 18       Flamer Kit
 19       Vest Kit
 20       Predator Kit
 21       Berserk Kit
 22       Cluster Kit
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #47 on: June 04, 2010, 03:13:17 am »
You've just failed.. You don't wanna tell me that eC doesn't know what the list is? >_>

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #48 on: June 04, 2010, 05:17:16 am »
no i wanna ask Ec what the exact list is, because id number 1 does actually spawn DE and id 2 actually does spawn a mp5 so if thats the case then what are the numbers for the flags?   why am i asking? because i tried all the numbers
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #49 on: June 04, 2010, 05:21:46 am »
Becuase thats SpawnObject() and not GetObjectStat()..?

Oh now I get what you want, you wanna spawn a flag with SpawnObject?

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #50 on: June 04, 2010, 05:34:17 am »
yes, and if its not Spawnobject that works, then how did Ec get the flags to correct XY pos when ppl use aether?
« Last Edit: June 04, 2010, 05:41:59 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #51 on: June 04, 2010, 06:58:40 am »
oh god, you really need to learn alot..
it's a bug/glitch w/e you wanna call it which causes the flag to respawn at the flag spawns

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Help with basic script
« Reply #52 on: June 04, 2010, 07:55:48 am »
and you cant spawn flags directly. Try moving the flag spawn point and killing the actual flag - the server should respawn it where you moved the spawnpoint

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Help with basic script
« Reply #53 on: June 04, 2010, 09:00:55 am »
SpawnObject does not work with flags. You must KillObject a flag (if it already exists), and then spawn in with SetObjetStat (that is, if I recall correctly; its been a while since I did anything like this). Refer to the wiki objects article.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #54 on: June 04, 2010, 08:02:09 pm »
i have a problem with that, how do i get the objectid for the existing flag?

im getting a type mismatch error somewhere in this section of code, im thinking its the KillObject line because its not working from a spawnobject variable, but since the flags have already been spawned, how do i get the id for the already spawned flags, Killobject only works with Spawnobect, but since i never used spawnobject to spawn the flag and it was done by server.....
Code: (pascal) [Select]
i:=KillObject(2);
SetSpawnStat(i,'x',GetPlayerStat(ID,'x'));
SetSpawnStat(i,'y',GetPlayerStat(ID,'y'));
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Help with basic script
« Reply #55 on: June 04, 2010, 08:07:59 pm »
you must loop through all the objects, check using GetObjectStat if style == a flag; if so, that is the id of the flag. You can then KillObject(that id) and do whatever else you wish (im not sure why KillObject returns anything, as it shouldn't; it might be a typo in the manual, since it says "procedure" but also ": integer" :P)

Offline absoulut1234

  • Major(1)
  • Posts: 30
Re: Help with basic script
« Reply #56 on: June 05, 2010, 07:49:43 am »
frosty??
Are you [NMJAS]Frosty?
if you are,i am DD! yahaha~ ::)  8)

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #57 on: June 05, 2010, 06:17:28 pm »
yeah!!! :cool: thats me DD :D
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #58 on: June 10, 2010, 01:25:32 am »
got another problem, trying to make a counter which counts up seconds and minutes until the player dies, problem is the values arent updating
Code: (pascal) [Select]
var
TSec,Tmin,BTSec,BTMin:Array[1..32] of Integer;
TA:Array[1..32] of Boolean;

procedure AppOnIdle(Ticks: integer);
begin
  for i:= 1 to 32 do begin
    if GetPlayerStat(i,'human') = true then if GetPlayerStat(i,'Alive') = true then TA[i]:= True;
    if TA[i] = True then begin
      TSec[i]:=TSec[i]+1;
      if TSec[i] = 60 then begin
        TMin[i]:= TMin[i]+1;
        TSec[i]:= 0;
      end;
    end;
    if GetPlayerStat(i,'human') = true then if GetPlayerStat(i,'Alive') = False then TA[i]:= False;
    If TA[i] = False then begin
      BTSec[i]:=TSec[i];
      TSec[i]:=0;
      if TMin[i]>BTMin[i] then BTMin[i]:=TMin[i];
      TMin[i]:=0;
    end;
  end;
end;

i want to show the time in this message when certain events happen:
Code: (pascal) [Select]
WriteConsole(i,'Longest Time Survived: '+inttostr(BTMin[i])+':'+inttostr(BTSec[i])+' (M:S)!',$EE81FAA1);
when the message does trigger it shows 0:0 where the vars are, which means that the values arent being assigned properly in the initial "for" loop or they are being assigned and something is causing them to be set to 0 every second

what am i missing here?

Referance:
TA sees if the player is alive and human
TSec and TMin : current time alive
BTSec and BTMin : Best time alive
check out my server! click here

If at first you don't succeed, Improvise! :D

DarkCrusade

  • Guest
Re: Help with basic script
« Reply #59 on: June 10, 2010, 01:47:22 am »
Code: (pascal) [Select]
const
  ClBad = $FFFF44;

Type
  Stats = Record
  LongTime: Boolean;
  TSec,Tmin,BTSec,BTMin: Integer;
end;

var
  Player: Array[1..32] of Stats;
LongestTime: Array[1..2] of Integer;

Procedure ResetStats(ID:Byte);
  begin
  Player[ID].LongTime := false;
end;

Procedure CheckTime(ID:Byte); 
begin
    if Player[ID].BTMin > LongestTime[1] then begin
  LongestTime[1] := Player[ID].BTMin;
LongestTime[2] := Player[ID].BTSec;
Player[ID].LongTime := true;
end else begin
      if Player[ID].BTMin = LongestTime[1] then
  if Player[ID].BTSec > LongestTime[2] then begin
  LongestTime[1] := Player[ID].BTMin;
    LongestTime[2] := Player[ID].BTSec;
    Player[ID].LongTime := true;
end;
    end;
  end;

Procedure OnJoinGame(ID,Team:Byte);
  begin
  ResetStats(ID);
end;

Procedure AppOnIdle(Ticks: integer);
var
  i:Byte;
begin
 for i:= 1 to 32 do if (GetPlayerStat(i,'Active') = true) AND (GetPlayerStat(i,'Alive') = true) then begin
if GetPlayerStat(i,'Human') = true then begin
   TSec[i]:= TSec[i]+1;
   if TSec[i] = 60 then begin
     TMin[i]:= TMin[i]+1;
     TSec[i]:= 0;
end;
   end else begin
     BTSec[i]:=TSec[i];
     TSec[i]:=0;
     if TMin[i] <> 0 then BTMin[i]:=TMin[i];
     TMin[i]:=0;
CheckTime(i);
   end;
end;
end;