Author Topic: Question Thread  (Read 33201 times)

0 Members and 1 Guest are viewing this topic.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #220 on: May 29, 2010, 09:28:15 am »
This is the whole procedure the line was taken from: (by the way: this happens everywhere where I try to access a value via Player[ID].Weapon[Index] ... same error, too)

Code: (pascal) [Select]
// Buys a specified item
Procedure Buy(ID:Byte; Money,Item:Integer);
  begin
if Item > 0 then begin
if Item < 16 then begin
if Money >= Price[Item] then begin
Player[ID].Money := Player[ID].Money - Price[Item];
case Item of
1,2,3,4,5,6,7,8,9,10: begin
ForceWeapon(ID,Item,GetPlayerStat(ID,'Primary'),0);
SetWeaponActive(ID,Item,true);
Player[ID].Weapon[Item] := true;
end;
11: DoDamage(ID,GetPlayerStat(ID,'Health') - 150);
12: GiveBonus(ID,4);
13: GiveBonus(ID,1);
14: GiveBonus(ID,2);
15: if GetPlayerStat(ID,'Ground') = true then begin
Player[ID].Turret := SpawnObject(GetPlayerStat(ID,'X'),GetPlayerStat(ID,'Y'),Item);
WriteConsole(ID,'You can move your turret by !moveturret', White);
end else WriteConsole(ID,'You must be standing on the ground to buy a turret.', Red);
16: if not Player[ID].Zombie then begin
Player[ID].Lives := Player[ID].Lives + 1;
WriteConsole(ID,'You feel stronger..', Orange);
end else WriteConsole(ID,'You are already a zombie.', Red);
17: if Player[ID].Zombie then begin
Player[ID].Zombie := false;
SetTeam(ID,1);
WriteConsole(ID,'You feel.. good! You just raised from the dead!', Orange);
end else WriteConsole(ID,'You are not infected.', Red);
end;
end else WriteConsole(ID,'You don''t have enough money.', Red);
end else WriteConsole(ID,'Invalid item ID.', Red);
end else WriteConsole(ID,'Invalid item ID.', Red);
  end;
« Last Edit: May 29, 2010, 09:42:43 am by DarkCrusade »

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Question Thread
« Reply #221 on: May 29, 2010, 10:17:45 am »
I dont watch this topic alot but what will be the full script ?
zombie survival ?

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #222 on: May 29, 2010, 11:04:11 am »
Post the var/type.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #223 on: May 29, 2010, 11:43:55 am »
@mich: It'll be a remix of the good'ol (!KY) ZombieSurvival, the best zombie server ever imo

@piepie:

Code: (pascal) [Select]
Type Stats = Record
  Zombie,Weapon:Boolean;
  Money,Turret,Lives:Integer;
  Klasse: Byte;      // 0: human 1: zombie 2: gunner 3: knifer 4: tank
end;

var
  Player: Array[1..32] of Stats;
« Last Edit: May 29, 2010, 12:18:47 pm by DarkCrusade »

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #224 on: May 29, 2010, 12:06:14 pm »
And where's the weapon array? :@

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Question Thread
« Reply #225 on: May 29, 2010, 12:09:49 pm »
@mich: It'll be a remix of the good'ol (!KY) ZombieSurvival, the best zombie server ever imo
So i suport you for that !
and if you want a host located in canadas just ask !

DarkCrusade

  • Guest
Re: Question Thread
« Reply #226 on: May 29, 2010, 12:19:06 pm »
Wrong script :3

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #227 on: May 29, 2010, 12:27:23 pm »
Pfffffffft... seriously: /buy brains

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #228 on: May 29, 2010, 03:32:56 pm »
Lmfao..

Should be:

Code: (pascal) [Select]
Type Stats = Record
 Zombie: Boolean;
  Money, Turret, Lives: Integer;
 Weapon: Array[0..16] of Boolean;
end;

Var
 Player: Array[1..32] of Stats;

//In use:

Player[ID].Weapon[10] := True; //Should enable Minigun
Player[ID].Weapon[14] := False; //Disables Combat Knife
Player[ID].Weapon[16] := True; //Enables LAW, and there it goes.

//If you wanna use Stationarys too, go "Weapon: Array[0..17] of Boolean;".. 17 would be Stat.

//Good luck :)
//Hope I've helped :]
www.soldatx.com.br - The brazilian Soldat community.

DarkCrusade

  • Guest
Re: Question Thread
« Reply #229 on: May 29, 2010, 03:47:24 pm »
It was so basic that I didn't see it.. thanks guys (excluding Swompie >:( )

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Question Thread
« Reply #230 on: May 29, 2010, 03:48:43 pm »
Haha, no problem.

I'm using that same trick on my current Script, so.. Feel free to ask me :)
www.soldatx.com.br - The brazilian Soldat community.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Question Thread
« Reply #231 on: May 29, 2010, 04:37:27 pm »
It was so basic that I didn't see it.. thanks guys (excluding Swompie >:( )
You want me to say *RAWR* :D

DarkCrusade

  • Guest
Re: Question Thread
« Reply #232 on: May 29, 2010, 04:42:15 pm »
Yeah I missed that freaking nice *RAWR* :P

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Question Thread
« Reply #233 on: May 29, 2010, 05:44:03 pm »
Are your script finished ?
if yes , a server run it ?

DarkCrusade

  • Guest
Re: Question Thread
« Reply #234 on: May 29, 2010, 06:26:02 pm »
As soon as it's ready I'll announce it here (I will host it)

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Question Thread
« Reply #235 on: May 29, 2010, 08:30:49 pm »
Ok good  :D
Where the server will be located ?

DarkCrusade

  • Guest
Re: Question Thread
« Reply #236 on: May 29, 2010, 08:33:02 pm »
In Germany

EDIT: I wrote a mine script that should work but I'm getting this strange error:

Code: [Select]
10-05-30 03:36:16  [*] [Error] Test(Mine) -> (OnPlayerSpeak): Could not call proc
Here is the code:

Code: (pascal) [Select]
const
  White  = $FFFFFF;
  Orange = $FF7F24;
  Red    = $EE3B3B;

  MineDuration = 180;  // Time in seconds the mine lasts 
  MaxMines  = 5;       // Maximum amount of mines / map
  MineRange = 45;      // Range of mines (14 units = 1 meter)
  MineM79   = 1;       // MineXYZ increases the created bullets exponentially (MineM79 > MineGren > MineClux)
  MineGren  = 2;     
  MineClux  = 3;

Type MineStats = Record
  X,Y:Single;
  Time:Integer;
end;

Type GeneralStats = Record
  MineStat: Array of MineStats;
end;

var
  Mine: Array[1..32] of GeneralStats;
  NumMines: Byte;

Procedure DetonateMine(ID,Enemy:Byte; X,Y:Single);
var i,ii,iii:Byte;
    R1,R2:Integer; 
begin
for i := 1 to MineM79 do begin
R1 := Round(Random(-200,201) / 150);
R2 := Round(Random(100,326) / 150);
CreateBullet(X,Y,R1,R2,100,4,ID);
for ii := 1 to MineGren do begin
R1 := Round(Random(-250,251) / 125);
R2 := Round(Random(100,381) / 125);
CreateBullet(X,Y,R1,R2,100,2,ID);
for iii := 1 to MineClux do begin
R1 := Round(Random(-350,351) / 115);
R2 := Round(Random(100,501) / 115);
CreateBullet(X,Y,R1,R2,100,10,ID);
end;
end;
end;
WriteConsole(Enemy,'You stepped into a claymore.', Red);
WriteConsole(ID,IDToName(Enemy) + ' has stepped on one of your mines.', Orange);
NumMines := NumMines - 1;
  end;

Procedure CallMines();
var i,ii,iii,All:Byte;
    Dist:Single;
begin
for i := 1 to 32 do
if GetPlayerStat(i,'Active') = true then begin
All := GetArrayLength(Mine[i].MineStat);
for ii := 1 to All do begin
for iii := 1 to 32 do
if GetPlayerStat(iii,'Active') = true then
if GetPlayerStat(iii,'Alive') = true then
if (GetPlayerStat(iii,'Team') <> GetPlayerStat(i,'Team')) OR (GetPlayerStat(i,'Team') = 0) then begin
Dist := Distance(Mine[i].MineStat[ii].X,Mine[i].MineStat[ii].Y,GetPlayerStat(iii,'X'),GetPlayerStat(iii,'Y'));
if Dist <= MineRange then
DetonateMine(i,iii,Mine[i].Minestat[ii].X,Mine[i].MineStat[ii].Y);
end;
if Mine[i].MineStat[ii].Time <> - 1 then begin
Mine[i].MineStat[ii].Time := Mine[i].MineStat[ii].Time - 1;
CreateBullet(Mine[i].MineStat[ii].X,Mine[i].MineStat[ii].Y,0,0,0,7,i);
if Mine[i].MineStat[ii].Time = 0 then begin
WriteConsole(i,'One of your mines exceeds it''s duration and blows up.', Orange);
DetonateMine(i,iii,Mine[i].MineStat[ii].X,Mine[i].MineStat[ii].Y);
Mine[i].MineStat[ii].Time := - 1;
end;
end;
  end;
end;
  end;

Procedure PlaceMine(ID:Byte);
var ArrLength:Byte; 
begin
if NumMines < MaxMines then begin
if GetPlayerStat(ID,'Alive') = true then begin
if GetPlayerStat(ID,'Ground') = true then begin
ArrLength := GetArrayLength(Mine[ID].MineStat);
SetArrayLength(Mine,ArrLength + 1);
Mine[ID].MineStat[ArrLength].X := GetPlayerStat(ID,'X');
Mine[ID].MineStat[ArrLength].Y := GetPlayerStat(ID,'Y');
Mine[ID].MineStat[ArrLength].Time := MineDuration;
NumMines := NumMines + 1;
WriteConsole(ID,'You have laid a mine successfully.', White);
end else WriteConsole(ID,'You must be standing on the ground.', Red);
end else WriteConsole(ID,'You must be alive to use skills.', Red);
end else WriteConsole(ID,'There are already ' + inttostr(MaxMines) + ' mines on the map.', Red);
  end;

Procedure DestroyAllMines();
var i:Byte;
  begin
    for i := 1 to 32 do
      if GetPlayerStat(i,'Active') = true then
SetArrayLength(Mine[i].MineStat,0);
  end;

Procedure OnPlayerSpeak(ID:Byte; Text:String);
  begin
    case LowerCase(Text) of
     '!mine','!test': PlaceMine(ID);
     '!blowup','!blow': DestroyAllMines();
    end;
  end;

Procedure AppOnIdle(Ticks:Integer);
  begin
    CallMines();
  end;

Procedure OnMapChange(NewMap:String);
  begin
    DestroyAllMines();
  end;
« Last Edit: May 29, 2010, 09:10:34 pm by DarkCrusade »

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Question Thread
« Reply #237 on: May 29, 2010, 11:45:50 pm »
dynamic array indexes start at 0, not 1. So if you have an empty array and add an element to it (do setarraylength(mines,1) ), there will be no mines[1], the only element will be mines[0]

edit: fixed a dumb early-in-the-morning mistake <.<
« Last Edit: May 30, 2010, 08:03:17 am by dnmr »

DarkCrusade

  • Guest
Re: Question Thread
« Reply #238 on: May 30, 2010, 07:46:57 am »
I have a little problem. I need to know a formula which changes my input to an opposite value. 0 would return 100, 1 returns 99, 10 returns 90, 25 returns 75, 50 returns 50 and so on ...

I don't want to create a huge list that would look very retarded :3

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Question Thread
« Reply #239 on: May 30, 2010, 07:49:29 am »
result := 100 - x;
fail