Author Topic: Multiplying  (Read 1543 times)

0 Members and 1 Guest are viewing this topic.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Multiplying
« on: June 10, 2009, 03:19:32 pm »
Hello guyz !
I have a problem, i was scripting a money script and i wanted to multiply money after row of kills. The problem is that it add 80 of money the first kills then it multiplies x2 for others kills if you do not die. But the problem is that it multiplies ALL the money if player dies and kill again. I hope you understod
Here is the part of the script
Code: [Select]
Var

Multiplier: Array [1..32] of boolean;
Money: Array [1..32] of integer;
Killz: Array [1..32] of integer;

procedure OnPlayerRespawn(ID: Byte);
 Begin
  Multiplier[ID] := false;
  Killz[ID] := 0;
 end;
 
procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
 Begin
 
   Killz[Killer] := Killz[Killer] + 1;
    if Killz[Killer] = 1 then   
    Money[Killer] := Money[Killer] + 8;
    Multiplier[Killer] := true; 
    if (Killz[Killer] > 1) and (Multiplier[Killer] = true) then
    Money[Killer] := Money[Killer] * 2
   if Killer = Victim then begin
   Multiplier[Killer] := False;
   Killz[Killer] := 0;
   Money[Killer] := Money[Killer] + 0;
   end;
   Money[Killer] := Money[Killer];
 end;

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Multiplying
« Reply #1 on: June 10, 2009, 03:26:04 pm »
You must create another array for the current money that will be added once the player dies, some kind of temporally value, so you would be multiplying the money you will get once you die, and not your total money.

Also    Money[Killer] := Money[Killer] + 0; and    Money[Killer] := Money[Killer];
are kinda pointless, no?

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Multiplying
« Reply #2 on: June 10, 2009, 03:49:34 pm »
It unallows player to have kills if he kills himself. I tried wih another array, i knew it, but i don't know HOW to script it.
Edit : Oh Money[Killer] := Money[killer] can be removed
« Last Edit: June 10, 2009, 03:52:54 pm by VinceBros »

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Multiplying
« Reply #3 on: June 10, 2009, 04:00:34 pm »
get in #soldat.devs @ Quakenet, the scripters will lend you a hand.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Multiplying
« Reply #4 on: June 10, 2009, 04:08:46 pm »
I'm not too familar with IRC.. I prefer forums :p

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Multiplying
« Reply #5 on: June 10, 2009, 04:14:46 pm »
I wasnt familiar with IRC either, give it a try...

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Multiplying
« Reply #6 on: June 10, 2009, 04:28:43 pm »
I'm gonna give it a try :P
I don't understand how to use that array so my money do not x 2 the whole money..

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Multiplying
« Reply #7 on: June 10, 2009, 04:52:05 pm »
this is what I have... but it gives me a syntax error on 12:23, dammit.

Code: [Select]
var
Money: Array [1..32] of integer;
Temp: Array [1..32] of integer;
Killz: Array [1..32] of integer;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
Killz[Killer] := Killz[Killer] + 1;
   if Killz[Killer] = 1 then //If first kill since respawn
      Temp[Killer] := Temp[Killer] + 8; //Only +8 money
   if Killz[Killer] >= 1 then  //If he has killed more than a guy
      Temp[Killer] := Temp[Killer] * 2; //Multiply your TEMP money by 2
   if Killer = Victim then begin //If he's killed
      Killz[Killer] := 0; //Set killcount to 0
      Money[Killer] := Money[Killer] + Temp[Killer]; //Add the TEMP money to your TOTAL money
   end;
 end;
//Now it's fixed and compiled.
« Last Edit: June 10, 2009, 05:09:15 pm by ~Niko~ »

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Multiplying
« Reply #8 on: June 10, 2009, 05:03:37 pm »
remove space between => on line 12

edit.. make that >= aswell
Come join: EliteCTF
Listen to: My Music

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Multiplying
« Reply #9 on: June 10, 2009, 05:07:30 pm »
such a thing... edited above. also fixed a few mistakes when changing from tempmoney to just temp.
« Last Edit: June 10, 2009, 05:10:07 pm by ~Niko~ »

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Multiplying
« Reply #10 on: June 10, 2009, 05:13:21 pm »
don't I miss set all the variables to 0 when someone joins in?

Code: [Select]
var
Money: Array [1..32] of integer;
Temp: Array [1..32] of integer;
Killz: Array [1..32] of integer;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
Killz[Killer] := Killz[Killer] + 1;
   if Killz[Killer] = 1 then //If first kill since respawn
      Temp[Killer] := Temp[Killer] + 8; //Only +8 money
   if Killz[Killer] >= 1 then  //If he has killed more than a guy
      Temp[Killer] := Temp[Killer] * 2; //Multiply your TEMP money by 2
   if Killer = Victim then begin //If he's killed
      Money[Killer] := Money[Killer] + Temp[Killer]; //Add the TEMP money to your TOTAL money
      Killz[Killer] := 0; //Set killcount to 0
   end;
 end;

procedure OnJoinGame(ID, Team: byte);
begin
Killz[ID] := 0;
Temp[ID] := 0;
Killz[ID] := 0;
end;

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Multiplying
« Reply #11 on: June 10, 2009, 05:16:18 pm »
It doesn't work, i always have 0 money =/

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Multiplying
« Reply #12 on: June 10, 2009, 05:28:38 pm »
can you paste the WHOLE script?

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Multiplying
« Reply #13 on: June 10, 2009, 05:33:50 pm »
Code: [Select]
// This is a cash system made by Vince
// You can buy items by the shop. You win money by killing others.
Var

Multiplier: Array [1..32] of boolean;
Temp: Array [1..32] of integer;
Money: Array [1..32] of integer;
Killz: Array [1..32] of integer;
NadesPrice, MedicPrice, ClustersPrice, VestPrice, PredPrice, FlammerPrice : integer; 

Procedure ActivateServer();
 Begin
    NadesPrice := 30;
    MedicPrice := 40;
    ClustersPrice := 40;
    VestPrice := 60;
    PredPrice := 120;
    FlammerPrice := 140;
 end;
 
procedure OnJoinGame(ID, Team: byte);
 Begin
  Killz[ID] := 0;
  Temp[ID] := 0;
   WriteConsole(ID, ' You actually have ' + IntToStr(Money[ID]), RGB(251,102,1));
   WriteConsole(ID, ' For more informations type /help ', RGB(251,102,1));
 end;

procedure OnPlayerRespawn(ID: Byte);
 Begin
    Killz[ID] := 0;
  Temp[ID] := 0;
 end;
 
procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
Killz[Killer] := Killz[Killer] + 1;
   if Killz[Killer] = 1 then //If first kill since respawn
      Temp[Killer] := Temp[Killer] + 8; //Only +8 money
   if Killz[Killer] >= 1 then  //If he has killed more than a guy
      Temp[Killer] := Temp[Killer] * 2; //Multiply your TEMP money by 2
   if Killer = Victim then begin //If he's killed
      Killz[Killer] := 0; //Set killcount to 0
      Money[Killer] := Money[Killer] + Temp[Killer]; //Add the TEMP money to your TOTAL money
   end;
 end;
//Now it's fixed and compiled.
 
function OnPlayerCommand(ID: Byte; Text: string): boolean;
 begin
 If Text = '/char' then WriteConsole(ID, ' You actually have ' + IntToStr(Money[ID]), RGB(251,102,1));
end;

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Multiplying
« Reply #14 on: June 10, 2009, 05:44:48 pm »
I'd make it less complicated and make it go by +10 increments...

ahahahahahahahahaha I just found the problem...
when you kill someone, the cash is assigned to Money[Killer], but then you have to buy things with Money[ID], that's why it finds no money at all in....

IT IS.

now, updated, and ready to put all the if money[ID] >= itemprice then Givebonus, etc...

You can replace the actual Onkill code by the old one that multiplies.

Code: (pascal) [Select]
// This is a cash system made by Vince
// You can buy items by the shop. You win money by killing others.
var
Money: Array [1..32] of integer;
NadesPrice, MedicPrice, ClustersPrice, VestPrice, PredPrice, FlammerPrice: integer;

procedure ActivateServer();
begin
    NadesPrice := 30;
    MedicPrice := 40;
    ClustersPrice := 40;
    VestPrice := 60;
    PredPrice := 120;
    FlammerPrice := 140;
end;
 
procedure OnJoinGame(ID, Team: byte);
begin
WriteConsole(ID, ' You actually have ' + IntToStr(Money[ID]), RGB(251,102,1));
WriteConsole(ID, ' For more informations type /help ', RGB(251,102,1));
end;

procedure OnPlayerKill(ID, Victim: byte;Weapon: string);
begin
Money[ID] := Money[ID] + 8;
end;
 
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/char' then WriteConsole(ID, ' You actually have ' + IntToStr(Money[ID]), RGB(251,102,1));
if Text = '/buy gre' then begin
if Money[ID] >= 30 then //stuff
if Text = '/buy med' then begin //same with these
if Text = '/buy clu' then begin
if Text = '/buy ves' then begin
if Text = '/buy pre' then begin
if Text = '/buy fla' then begin
end;

By the way, I'm going to bed, nice to solve this problem. Seeya dude.
« Last Edit: July 07, 2009, 07:59:57 am by ~Niko~ »