Author Topic: Script question ! (learning ...)  (Read 3614 times)

0 Members and 1 Guest are viewing this topic.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Script question ! (learning ...)
« on: June 14, 2010, 03:58:50 pm »
First ! Hi  ;D
Im really sorry for asking help for scripting, without give to you some break !

I got a problem with this script ! (I tried to go the far that i can ,now i need help for the random!)
Code: [Select]
const
  1 = bossname; 
  2 = bossname;
  3 = bossname;
  4 = bossname;
  5 = bossname;

procedure OnMapChange(NewMap: String);
 begin
  random = (Random(1,5)
   then begin
WriteConsole(0,''random' has been summoned kill him for reward !',$EE81FAA1);
Command('/addbot2 random');
end;
  end;

^
l l
l l
l l
l l
Here i want that when the map change a bot is added (Random(1,5)
1 should = to a name of bot !
2 same etc ...


Thanks for helping !
 :P

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: Script question ! (learning ...)
« Reply #1 on: June 14, 2010, 04:17:42 pm »
Numerical names for variables/constants/functions are forbidden.
Name your constants like 1b, 2b, 3b etc...
"random=Random(1,5)" is also completely wrong: you need to declare a var with some unique name and then assign to it a value returned by "Random(...)" function...
« Last Edit: June 14, 2010, 04:20:54 pm by VirtualTT »

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Script question ! (learning ...)
« Reply #2 on: June 14, 2010, 04:19:47 pm »
Code: [Select]
procedure OnMapChange(NewMap: String);
var name: string
begin
name := 'default boss name';
case random(1,5) of
1: name := 'boss 1';
2: name := 'boss 2';
3: name := 'boss 3';
4: name := 'boss 4';
5: name := 'boss 5';
end;
writeconsole(0,name+' has been selected to kill you',$ffaa4444);
command('/addbot2 '+name);
end;


Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #3 on: June 14, 2010, 04:23:25 pm »
Code: [Select]
name := 'default boss name';What should this mean ?!?

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: Script question ! (learning ...)
« Reply #4 on: June 14, 2010, 04:31:52 pm »
a proper code:

Code: (Pascal) [Select]
const
  PlainTextColour=$EE81FAA1;

// function description goes here
procedure SummonRandomBotBoss();
var
  NewBossName:string;
begin
  case Random(1,6) of // note that Random(1, 6) can return 1-5, but not 6!
    1: NewBossName := 'boss 1';
    2: NewBossName := 'boss 2';
    3: NewBossName := 'boss 3';
    4: NewBossName := 'boss 4';
    5: NewBossName := 'boss 5';
  end;
  Command('/addbot2 '+NewBossName);
  Writeconsole(0, NewBossName+' has been summoned! Kill him for reward!', PlainTextColour);
end;

// STD event description goes here
procedure OnMapChange(NewMap: String);
begin
  SummonRandomBotBoss();
end;
« Last Edit: June 14, 2010, 04:38:49 pm by VirtualTT »

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #5 on: June 14, 2010, 04:39:04 pm »
HT and VirtualTT You are very nice guy i hope there is not just me who know that !  :D
But now i want that when the boss is killed that kick him !

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: Script question ! (learning ...)
« Reply #6 on: June 14, 2010, 04:44:23 pm »
Just make NewBossName as a global variable and write some new handler to the OnPlayerKill event which will check the victim and kick the boss bot if it was him...

Code: (Pascal) [Select]
const
  PlainTextColour=$EE81FAA1;

var
  NewBossName:string;
 
// function description goes here
procedure SummonRandomBotBoss();
begin
  case Random(1,6) of // note that Random(1, 6) can return 1-5, but not 6!
    1: NewBossName:='boss 1';
    2: NewBossName:='boss 2';
    3: NewBossName:='boss 3';
    4: NewBossName:='boss 4';
    5: NewBossName:='boss 5';
  end;
  Command('/addbot2 '+NewBossName);
  WriteConsole(0, NewBossName+' has been summoned! Kill him for reward!', PlainTextColour);
end;

// function description goes here
procedure CheckBotBoss(Victim:byte);
begin
// assume that bot name is the same as bot file name
  if (IdToName(Victim)=NewBossName) then begin
    Command('/kick '+NewBossName);
    WriteConsole(0, NewBossName+' has been defited!', PlainTextColour);
  end;
end;

// function description goes here
procedure InitScript();
begin
  NewBossName:=''; // never forget to initialize all your variables!!!
end;

// STD event description goes here
procedure ActivateServer();
begin
    InitScript();
end;

// STD event description goes here
procedure OnMapChange(NewMap: String);
begin
  SummonRandomBotBoss();
end;

// STD event description goes here
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
  CheckBotBoss(Victim);
end;

I really have nothing to do right now... Another 2 hours of video encoding (((
« Last Edit: June 14, 2010, 05:05:56 pm by VirtualTT »

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #7 on: June 14, 2010, 05:02:12 pm »
Code: [Select]
[*] boom -> [Error] (9:29): colon (':') expected
Code: [Select]
const 
 PlainTextColour=$EE81FAA1; 
 
var 
 NewBossName:string; 
   
// function description goes here 
procedureSummonRandomBotBoss(); 
begin 
 caseRandom(1,6) of// note that Random(1, 6) can return 1-5, but not 6! 
   1: NewBossName := 'ViRuS ZoMbIe'; 
   2: NewBossName := 'GlAdIaToR ZoMbIe'; 
   3: NewBossName := 'CoWbOy ZoMbIe'; 
   4: NewBossName := 'SpArTaAa ZoMbIe'; 
   5: NewBossName := 'WTF ZoMbIe'; 
 end; 
 Command('/addbot2 '+NewBossName); 
 Writeconsole(0, NewBossName+' has been summoned! Kill him for reward!', PlainTextColour); 
end; 
 
// function description goes here 
procedureCheckBotBoss(Victim:byte); 
begin 
 
end; 
 
procedureInitScript(); 
begin 
 NewBossName:=''; 
end; 
 
// STD event description goes here 
procedureActivateServer(); 
begin 
    InitScript(); 
end; 
 
// STD event description goes here 
procedureOnMapChange(NewMap: String); 
begin 
 SummonRandomBotBoss(); 
end; 
 
// STD event description goes here 
procedureOnPlayerKill(Killer, Victim: byte; Weapon: string); 
begin 
 CheckBotBoss(Victim); 
end; 

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: Script question ! (learning ...)
« Reply #8 on: June 14, 2010, 05:06:19 pm »
why half of the spaces gone?

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #9 on: June 14, 2010, 05:07:46 pm »
What ??????

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: Script question ! (learning ...)
« Reply #10 on: June 14, 2010, 05:14:33 pm »
Just copy-paste my script correctly... it's working fine...

« Last Edit: June 14, 2010, 05:16:14 pm by VirtualTT »

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #11 on: June 14, 2010, 05:24:17 pm »
D'ont work !
which version of server youre using ?

Offline Centurion

  • Flagrunner
  • ****
  • Posts: 699
Re: Script question ! (learning ...)
« Reply #12 on: June 14, 2010, 06:17:20 pm »
If I was you then I'd be hella pissed off.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #13 on: June 14, 2010, 07:04:00 pm »
VirtualTT post your script with code,/code
cause when i copy i got number next to each line

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Script question ! (learning ...)
« Reply #14 on: June 14, 2010, 07:28:32 pm »
mich, click "view plain" then try to copy it from the new window. You can try "copy to clipboard" also, but it may not be supported by your browser.

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #15 on: June 14, 2010, 07:44:55 pm »
Thanks DorkeyDear !  ;)
But now i have my shop script and for reward i want to give money !
i already have this part of script for OnPlayerKill
Code: [Select]
procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
  begin
    if Killer = Victim then
      begin
         writeConsole(Killer, 'you cant kill yourself for money !', Color);
      end else
      begin
        money[Killer] := money[Killer]+1;
        writeConsole(Killer, 'You just got $1 your money is now: $' + inttostr(money[Killer]), Color);
      end;
  end;

this is the name of boss!
Code: [Select]
   
    GlAdIaTor ZoMbIe
    SpArTaAa ZoMbIe
    ViRuS ZoMbIe
    WTF ZoMbIe
how can i put that when one of this boss is killed that give X money ?

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: Script question ! (learning ...)
« Reply #16 on: June 15, 2010, 05:53:41 am »
1. Don't write any stuff in the standard events procedures - make a new procedure with some reasonable name and call it.
2. You are missing very basics... Lean pascal syntax first, read some existing scripts and only then write your own...

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #17 on: June 15, 2010, 05:59:56 am »
Do you have a pascal tutorial ?

Offline Centurion

  • Flagrunner
  • ****
  • Posts: 699
Re: Script question ! (learning ...)
« Reply #18 on: June 15, 2010, 06:06:03 am »

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 557
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Script question ! (learning ...)
« Reply #19 on: June 15, 2010, 08:00:39 am »
Sorry !  :-\
But i found the error by myself !
I forgot that in this procedure there is no ID its Killer
Code: [Select]
OnPlayerKill(Killer, Victim: byte;Weapon: byte);And i delete ' at some place !
I fix it and now it work ! Thanks all, i hope i will learn faster !  ;)  ;D
« Last Edit: June 15, 2010, 09:29:29 am by mich1103 »