Author Topic: Disable Weapon Help?  (Read 3080 times)

0 Members and 1 Guest are viewing this topic.

Offline koolazngy94

  • Major(1)
  • Posts: 41
    • Clan [H]avoc
Disable Weapon Help?
« on: June 19, 2009, 08:44:43 pm »
I'm new to making script and I finish reading the tutorial. I made a test script but it didn't work.

Code: [Select]
procedure SetWeaponActive(ID, WeaponNum: byte; State: boolean);
begin
SetWeaponActive(0,1,false);
SetWeaponActive(0,2,false);
SetWeaponActive(0,3,false);
end;

SetWeaponActive won't work or WeaponChange. What do I need to add?

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Disable Weapon Help?
« Reply #1 on: June 19, 2009, 09:28:36 pm »
I'm not 100% certain, but player id. 0 may not work for all players in this function. Try SetWeaponActive(1, ...) and see if that works. If so, you'll have to create a var i: byte; and a for i := 1 to 32 do if (GetPlayerStat(i, 'Active') = true) then begin SetWeaponActive(i, 1, false); SetWeaponActive(i, 2, false); SetWeaponActive(i, 3, false); end;

Lol I just realized.. your procedure name is SetWeaponActive as well, and I don't think you cave have multiple of the same procedure with the same name.

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Disable Weapon Help?
« Reply #2 on: June 20, 2009, 02:28:28 am »
ie just try this:
Code: [Select]
procedure RestrictWeapons();
begin
SetWeaponActive(0,1,false);
SetWeaponActive(0,2,false);
SetWeaponActive(0,3,false);
end;

and call this RestrictWeapons() procedure in onweaponchange or wherever you want it to be called

Offline koolazngy94

  • Major(1)
  • Posts: 41
    • Clan [H]avoc
Re: Disable Weapon Help?
« Reply #3 on: June 23, 2009, 01:22:06 pm »
ie just try this:
Code: [Select]
procedure RestrictWeapons();
begin
SetWeaponActive(0,1,false);
SetWeaponActive(0,2,false);
SetWeaponActive(0,3,false);
end;

and call this RestrictWeapons() procedure in onweaponchange or wherever you want it to be called

So how I call RestrictWeapons() in OnWeaponChange() ?

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Disable Weapon Help?
« Reply #4 on: June 23, 2009, 01:26:56 pm »
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte); begin RestrictWeapons; end;

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Disable Weapon Help?
« Reply #5 on: June 23, 2009, 03:10:12 pm »
The whole code should look like this:

Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
   RestrictWeapons;
end;

procedure RestrictWeapons();
begin
   SetWeaponActive(0,1,false);
   SetWeaponActive(0,2,false);
   SetWeaponActive(0,3,false);
end;

or

Code: [Select]
var
i: Integer;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
   RestrictWeapons;
end;

procedure RestrictWeapons();
begin
   for i := 1 to 3 do
   SetWeaponActive(0,i,false);
end;

Offline koolazngy94

  • Major(1)
  • Posts: 41
    • Clan [H]avoc
Re: Disable Weapon Help?
« Reply #6 on: June 23, 2009, 03:55:42 pm »
It said RestrictWeapons() is not defined.

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Disable Weapon Help?
« Reply #7 on: June 23, 2009, 04:01:52 pm »
place that procedure above OnWeaponChange

Offline koolazngy94

  • Major(1)
  • Posts: 41
    • Clan [H]avoc
Re: Disable Weapon Help?
« Reply #8 on: June 23, 2009, 04:08:20 pm »
place that procedure above OnWeaponChange

Thank you it works now!

--Edit--
But how can we disable when player join?
« Last Edit: June 23, 2009, 04:11:30 pm by koolazngy94 »

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Disable Weapon Help?
« Reply #9 on: June 23, 2009, 04:15:58 pm »
place that procedure above OnWeaponChange

Thank you it works now!

--Edit--
But how can we disable when player join?
put it in onjointeam. But since you disable the weapons for everyone (ID 0), i'd just put it in activateserver ::)

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Disable Weapon Help?
« Reply #10 on: June 23, 2009, 06:06:24 pm »
But since you disable the weapons for everyone (ID 0), i'd just put it in activateserver ::)

Then I'd change soldat.ini
Come join: EliteCTF
Listen to: My Music

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Disable Weapon Help?
« Reply #11 on: June 23, 2009, 06:14:25 pm »
Then I'd change soldat.ini
way better.

Offline koolazngy94

  • Major(1)
  • Posts: 41
    • Clan [H]avoc
Re: Disable Weapon Help?
« Reply #12 on: June 23, 2009, 08:15:22 pm »
Well I just want to enabled it back when it gets * kills.

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Disable Weapon Help?
« Reply #13 on: June 24, 2009, 06:29:21 am »
then tell us exactly what you want and we'll tell you how, or we'll make it.

Offline shantec

  • Soldier
  • **
  • Posts: 140
  • Get ANGREH!!
Re: Disable Weapon Help?
« Reply #14 on: June 24, 2009, 06:30:38 am »
Quote
procedure Activateserver;
var
   i: Integer;
begin
   for i := 1 to 3 do //Might wanna change to 10?
   SetWeaponActive(0,i,false);
end;


procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
   If GetPlayerStat(Killer,'Kills') > 1 then SetWeaponActive(0,1,true);
   If GetPlayerStat(Killer,'Kills') > 2 then SetWeaponActive(0,2,true);
   //etc. etc, i suggest using ">", if its used on CTF mode
end;

Also Known As REIMA


Lol Happles (happy apples)

Offline koolazngy94

  • Major(1)
  • Posts: 41
    • Clan [H]avoc
Re: Disable Weapon Help?
« Reply #15 on: June 24, 2009, 12:28:12 pm »
then tell us exactly what you want and we'll tell you how, or we'll make it.

What I want is all weapons to be disabled beside the first gun. When they get 10 kills, first gun is disabled and the second gun is enabled then next gun then .etc.

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Disable Weapon Help?
« Reply #16 on: June 24, 2009, 03:43:47 pm »
then tell us exactly what you want and we'll tell you how, or we'll make it.

What I want is all weapons to be disabled beside the first gun. When they get 10 kills, first gun is disabled and the second gun is enabled then next gun then .etc.
k, ill do it.

EDIT: this huge code should do the trick, but it seems that in doesn't works for soldat...

Code: (Pascal) [Select]
var
i, b: Integer;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
if GetPlayerStat(Killer,'Kills') in [11..20] then begin //If kill amount is needed
for i := 1 to 10 do //To call all weapons inactive
SetWeaponActive(Killer,i,false); //Set all weapons inactive
SetWeaponActive(Killer,2,true); //Set next weapon active
end; //End block if guy has 11 to 20 kills
if GetPlayerStat(Killer,'Kills') in [21..30] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,3,true);
end;
if GetPlayerStat(Killer,'Kills') in [31..40] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,4,true);
end;
if GetPlayerStat(Killer,'Kills') in [41..50] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,5,true);
end;
if GetPlayerStat(Killer,'Kills') in [51..60] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,6,true);
end;
if GetPlayerStat(Killer,'Kills') in [61..70] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,7,true);
end;
end;
//Damn this turned out in a huge code... fix anyone?

procedure OnJoinTeam(ID, Team: byte);
begin
for b := 2 to 10 do
SetWeaponActive(ID,b,false);
end;
« Last Edit: June 24, 2009, 04:41:57 pm by ~Niko~ »

Offline koolazngy94

  • Major(1)
  • Posts: 41
    • Clan [H]avoc
Re: Disable Weapon Help?
« Reply #17 on: June 24, 2009, 10:39:56 pm »
then tell us exactly what you want and we'll tell you how, or we'll make it.

What I want is all weapons to be disabled beside the first gun. When they get 10 kills, first gun is disabled and the second gun is enabled then next gun then .etc.
k, ill do it.

EDIT: this huge code should do the trick, but it seems that in doesn't works for soldat...

Code: (Pascal) [Select]
var
i, b: Integer;

procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
if GetPlayerStat(Killer,'Kills') in [11..20] then begin //If kill amount is needed
for i := 1 to 10 do //To call all weapons inactive
SetWeaponActive(Killer,i,false); //Set all weapons inactive
SetWeaponActive(Killer,2,true); //Set next weapon active
end; //End block if guy has 11 to 20 kills
if GetPlayerStat(Killer,'Kills') in [21..30] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,3,true);
end;
if GetPlayerStat(Killer,'Kills') in [31..40] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,4,true);
end;
if GetPlayerStat(Killer,'Kills') in [41..50] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,5,true);
end;
if GetPlayerStat(Killer,'Kills') in [51..60] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,6,true);
end;
if GetPlayerStat(Killer,'Kills') in [61..70] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,7,true);
end;
end;
//Damn this turned out in a huge code... fix anyone?

procedure OnJoinTeam(ID, Team: byte);
begin
for b := 2 to 10 do
SetWeaponActive(ID,b,false);
end;

That is alot. One question tho, what you mean [51..60]?

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Disable Weapon Help?
« Reply #18 on: June 25, 2009, 12:21:11 am »
That is alot. One question tho, what you mean [51..60]?
I believe the left part must be between (inclusivly) 51 and 60. But I can't say this for certain.

Replacement for the in operator as a function i guess
Code: [Select]
function WithinInt(const Value, Low, High: integer): boolean;
begin
  Result := (Value >= Low) and (Value <= High);
end;
For other types, simply change the time (and preferably the function name; wouldn't be appropiate to leave Int at the end if its for doubles)
« Last Edit: June 25, 2009, 12:22:59 am by DorkeyDear »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Disable Weapon Help?
« Reply #19 on: June 25, 2009, 03:35:02 am »
Code: [Select]
const Kills4Weap=2;

procedure SetWeapons(ID: byte);
var i: byte;
begin
  for i:= 1 to 10 do SetWeaponActive(ID,i,false);
  SetWeaponActive(ID, (((GetPlayerStat(ID,'Kills') div Kills4Weap) mod 10) + 1), true);
end;
Call it in OnPlayerKill and OnJoinTeam.
« Last Edit: June 25, 2009, 03:37:20 am by Gizd »

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Disable Weapon Help?
« Reply #20 on: June 25, 2009, 06:50:02 am »
Code: [Select]
if GetPlayerStat(Killer,'Kills') in [11..20] then begin
Just a question, what is 'in', does it check if one of the arrays is the number of kills, because iv'e  never heard about that.

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: Disable Weapon Help?
« Reply #21 on: June 25, 2009, 06:59:31 am »
if the number of kills is into these numbers, it will do something.

Offline y0uRd34th

  • Camper
  • ***
  • Posts: 325
  • [i]Look Signature![/i]
Re: Disable Weapon Help?
« Reply #22 on: June 25, 2009, 09:38:26 am »
Thanks for answer. Sounds quite helpfull.

Offline utkesmer

  • Major(1)
  • Posts: 44
Re: Disable Weapon Help?
« Reply #23 on: July 14, 2009, 06:09:01 am »
Can we create a procedure or function?

Like this...

Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;
begin
   Result := false;

   MyProcedure;

end;

procedure MyProcedure(Text: string; ID: byte);
begin

   if MaskCheck(Text, '/alpha') then Command('/setteam1 '+INTTOSTR(ID) );
   // Just an example...

end;

Offline Polifen

  • Soldier
  • **
  • Posts: 127
Re: Disable Weapon Help?
« Reply #24 on: July 14, 2009, 09:05:10 am »
You must call it like you declare.

For:
Code: [Select]
procedure MyProcedure(Text: string; ID: byte);
Example:
Code: [Select]
MyProcedure(Text, ID);

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Disable Weapon Help?
« Reply #25 on: July 14, 2009, 10:23:24 am »
Also note that functions/procedures you make bust be declared/defined above where you want to call them. So in the example, above OnCommand u can say what MyProcedure is.